XSL concise tutorial (2) XSL conversion

Source: Internet
Author: User
Tags xsl file
Original: JanEgilRefsnes translation: 2. XSL conversion 1. how does one convert XML to HTMLXSL to convert XML to HTML files? Let's look at an example. below is part of the XML document :? Xmlversion = 1.0 encoding = ISO8859-1? CATALOG

Original: Jan Egil Refsnes
II. XSL conversion

1. Convert XML into HTML

How does XSL convert XML files into HTML files? Let's look at an example. below is part of the XML document:




Empire Burlesque
Bob Dylan
USA
Columbia
10.90
1985

...

Then, we use the following XSL file as an HTML template to convert XML data to an HTML file:

















Title Artist




In the above code, the xsl: for-each element is used to locate which elements in the XML document need to be displayed according to the following template. The select attribute is used to define the element name in the source file. This syntax for specifying attributes is also called XML
Pattern (Pattern), similar to the performance of file subdirectories. The xsl: value-of element is used to insert the content template of the child element into the current level.

Because the XSL style sheet itself is also an XML document, the beginning of the XSL file begins with an XML declaration. Xsl: the stylesheet element is used to declare that this is a style sheet file. Match = "/"> The statement represents that the source document of XML is in the current directory.

If you add an XSL style table to an XML document, you can see the following code in line 2. your browser can accurately convert the XML document to an HTML file.





Empire Burlesque
Bob Dylan
USA
Columbia
10.90
1985


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.