2. Example of XSLT 2.1 How to convert XML 2.2 An instance 2.3 Process analysis 2.4 XSLT Use 2.1 How to convert XML to our play, you play the rubberine, you can make it with different molds. The shape is needed. If we assume that the XML data document is a big plasticine, XSLT is like a mold, and it is necessary to make a needed shape. Specifically look at the following procedure: We use XML original documentation, use XSL as a template, through the conversion engine, the final output required HTML document. The conversion engine is the process of "force one according to force" in the metaphor. In specific applications, there are special software to implement this conversion process, named XML Processor. There is already a lot of Processor software (hereinafter referred to in detail below), and XML Processor has been embedded in IE5.5. 2.2 An instance Now let's take a simple XSLT actual application example to get some sense of understanding. Many web designers see the code similar to HTML will be relieved, the code is kind and familiar. Example 1: "Hello, World!" Hello World as the first tutorial is already a practice in the program language. We also follow this practice to see how to use XSLT to display "Hello World". Although this example doesn't have any practical use, please don't worry, there is more detailed example. Step 1: Create to enter the XML document Hello.xml. XML Version = "1.0" encoding = "ISO-8859-1"?> Hello, World! greeting> This is a very simple XML document that contains only a node XML tree. Step 2: Establish a XSLT document Hello.xsl. Tip: The default XSLT file has the name of .xsl. XML Version = "1.0" encoding = "ISO-8859-1"?> first xslt example title> head> p> Body> html> xsl: template> xsl: styleSheet> You can now open this hello.xsl file with IE5.0 or above, see the XSL tree. Step 3: Call this XSL file in XML.
Modify Hello.xml code is: XML Version = "1.0" encoding = "ISO-8859-1"> Xml-stylesheet type = "text / xsl" href = "hello.xsl"?> Hello, World! Greeting> OK, all code has been completed in principle, followed by using an XSLT processor (XML processor) to perform Hello.xml, you can see "Hello World" The result is displayed. The popular processor software has the following: (1) .james Clark XT. Download Website: http://www.jclark.com/xml/xt.html (2) XML for Java package named LotusxSL. Download Website: www.alphaworks.ibm.com/tech/xml4j (3) .saxon. Download URL: http://www.wrox.com (4). Microsoft's MSXML3. Download URL: http://www.microsoft.com/xml Some netizens should ask, I want to see what the "Hello World" is doing in the browser? In Microsoft's IE5.5 embeds the MSXML3 interpreter, you can use IE5.5 to open the Hello.xml file, you can see the result. If you only see the XML tree, not a separate "Hello World" word, indicating that your browser does not have MSXML3 version. What should I do if I don't want to see it? Then use the old approach in our XML tutorial, use JS implementation. (This has exceeded the scope of this article, but in order to be more intuitive, we provide example code here.) The following is an implementation code that can be saved as hello.htm, Hello.xml, Hello .xsl is placed in the same directory. Finally, you can see the effect with IE5.0 or later.