Step 2: XSLT instances (2)

Source: Internet
Author: User
2.2 an example. now let's look at a simple example of using XSLT to gain some sensory familiarity. Many web designers can feel at ease when they see HTML-like code. the code is so friendly and familiar. Example 1: "Hello, world! "Hellowor

2.2 one instance



Now let's look at a simple example of using XSLT to get some sensory familiarity. Many web designers can feel at ease when they see HTML-like code. the code is so friendly and familiar.


Example 1: 'Hello, world! '

Hello world, as the first tutorial, is already a convention in programming languages. We also follow this convention to see how to use XSLT to display 'Hello world '. Although this example is of no practical use, please do not worry, there are more specific examples later.

Step 1: Create the hello. XML file to be imported.




Hello, world!


This is a simple XML document that only contains the XML structure tree of one node.

Step 2: Create the XSLT document hello. xsl. Tip: The default extension of the XSLT file is. xsl.












First XSLT example














Now you can open the hello. xsl file in IE5.0 or a later browser and see the structure tree of XSL.

Step 3: Call the XSL file in XML. The code for correcting hello. xml is:






Hello, world!


OK, all the code has been completed in this step. Next, you only need to use an XSLT Processor (XML Processor) to execute hello. xml and you will see 'Hello
World. Popular processor software includes the following types:

(1). James Clark's XT. Download URL: http://www.jclark.com/xml/xt.html

(2). IBM's XML for Java package, named Lotus XSL. Download URL: 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 asked me, what should I do if I want to see 'Hello world' in my browser? The MSXML3 interpreter is embedded in Microsoft IE5.5. you can use IE5.5 to open the hello. xml file to see the result. If you only see the XML structure tree, it is not a separate 'Hello
The word "world" indicates that MSXML3 is not installed in your browser.

What should I do if I don't have any installation? We still use the old measures in the XML tutorial and JS implementation. (This is beyond the scope of this article, but we provide the instance code here to make it more intuitive and easy to understand .) The following is a real code that can be reserved as hello.htm, which is placed in the same directory as hello. xml and hello. xsl above. Use ie5.0to open hello.htm in the upper-right corner to see the consequences.






Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.