Easy Introduction to XSLT Chapter II: Examples of XSLT

Source: Internet
Author: User
Tags xsl xsl file xslt xslt example

. Instances of XSLT

2.1 How XSLT Transforms XML

2.2 An instance

2.3 Process Parsing

The purpose of 2.4 XSLT

2.1 How XSLT Transforms XML

Let's make an interesting analogy: you play with the dough, you press it in different molds, you can make the shape you need. If we assume that the XML data document is a big piece of dough, XSLT is like a mold, pressing it, making the desired shape to---the HTML document that fits the different needs.

Look at the following process diagram:

We input the original XML document, using XSL as the template, through the transformation engine, the final output of the required HTML document. The conversion engine is the metaphor of the "Force One press" process. In the specific application, there is a special software to implement this transformation process, called XML Processor. There are already a lot of Processor software (detailed below), and XML Processor is already embedded in IE5.5.

2.2 An instance

Now let's take a look at a simple XSLT practical application example to get some sense of perception. Many web designers see HTML-like code to be assured that the code is so cordial and familiar.

Example 1: "Hello, world!"

Hello World as the first tutorial is already a practice in the programming language. We also follow this practice and see how XSLT can be used to show "Hello World". Although this example has no practical use, please do not worry, there are more detailed examples.

Step one: Create Hello.xml to enter XML document.

<?xml version= "1.0" encoding= "Iso-8859-1"?>

<greeting>hello, world!</greeting>

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

Step two: Create an XSLT document HELLO.XSL. Tip: The default XSLT file has a suffix named. Xsl.

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<title>First XSLT example</title>
<body>
<p><xsl:value-of select="greeting"/></p>
</body>
</xsl:template>
</xsl:stylesheet>

You can now open the hello.xsl file in IE5.0 above browser and see the XSL structure tree.

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.