Before reading this tutorial, you should at least make sure that you are familiar with XML. you have edited XML, DTD, and XSLT documents using Notepad or other tools and are familiar with their syntax and usage, otherwise, you must complete the course and then read this tutorial. XMLSpy is an IconInformationSystem editor that supports XML, XSL, XSLT, DTD, Schema, and other file formats. It can display XML as a perfect tree structure,
Before reading this tutorial, you should at least make sure that you are quite familiar with XML. you have used notepad or other tools to edit XML, DTD, and XSLT documents and are familiar with their syntax and usage, otherwise, you must complete the course and then read this tutorial.
XML Spy is an editor that supports XML, XSL, XSLT, DTD, Schema, and other file formats developed by the Icon Information System. It can display XML as a perfect tree structure and easily use various HTML, XML, and XSLT tags, which can greatly save our development time, you do not have to waste a lot of time on code input. Next we will learn how to use XML Spy through an instance that stores movie information.
Step 1: Design three files: saveit. xml, saveit. dtd and saveit. xslt; saveit. xml is responsible for storing specific movie content data, saveit. the dtd is responsible for the saveit. xml verification, while saveit. xslt is responsible for the saveit. xml for style conversion, determine its final display effect in the browser. Let's take a look at the code of the three files we need to create:
---------- Saveit. xml ------------------ <? Xml version = "1.0" encoding = "GB2312"?> <! DOCTYPE movies SYSTEM "G: \ xmlspy \ saveit. dtd"> <? Xml-stylesheet type = "text/xsl" href = "G: \ xmlspy \ saveit. xslt"?> <Movies type = "action movie"> <id> 1 </id> <name> Cradle of Death </name> <brief> Jet Li's latest masterpiece! </Brief> <time> 2003 </time> </movies> ---------- saveit. dtd ------------------ <? Xml version = "1.0" encoding = "GB2312"?> <! ELEMENT movies (id, name, brief, time)> <! ATTLIST movies type CDATA # REQUIRED> <! ELEMENT id (# PCDATA)> <! ELEMENT name (# PCDATA)> <! ELEMENT brief (# PCDATA)> <! ELEMENT time (# PCDATA)> ---------- saveit. xslt ---------------- <? Xml version = "1.0" encoding = "UTF-8"?> <Xsl: stylesheet version = "1.0" xmlns: xsl =" http://www.w3.org/1999/XSL/Transform "> <Xsl: output method =" xml "version =" 1.0 "encoding =" GB2312 "indent =" yes "/> <xsl: template match = "/">
Step 2: Use XML Spy to create the saveit. dtd document.
1) create a root node movies
Choose File> New to bring up the Create new document dialog box, and select the dtd (Document Tpye Definition) in it. in this way, an empty DTD document is created in the editing area, as shown in 1. Click the black triangle in the upper left corner. We set the default value of encoding method item enconding to UTF-8, and we changed it to GB2312. double-click at Elm and enter movies. 3 after completion. Select Elm movies and double-click sequence of in the Elements box on the right. Result 4 is displayed. In this way, the root node movies is created.
8
The above is the detailed description of the XML Spy instance code (figure). For more information, see other related articles in the first PHP community!