You cannot make up for it ~ Use XSL to modify XML

Source: Internet
Author: User
Tags xsl xsl file
Concepts

XSL is the abbreviation of extensible style sheet language. It is a language used to present XML (a subset of standard General Markup Language) data in readable format.

Started with XSL

The reason why the World Wide Web Consortium (W3C) began to develop XSL is that there is a need for XML-based style sheet languages.

CSS = html style sheet

HTML uses predefined tags, and the meaning of each tag is easy to understand.
The <Table> label in HTML defines the table and the browser knows how to display it.
It is easy to add styles to HTML elements. With CSS, it is easy to tell the browser to display an element with a specific font or color.

XSL = XML style sheet

XML does not use pre-defined labels (we can use any tag name we like), and the meaning of each tag is not so easy to understand.
<Table> A tag means an HTML table, a piece of furniture, or something else-the browser does not know how to display it.
XSL describes how to display XML documents!

XSL-not just the style sheet language

XSL consists of three parts:

XSLT-a language used to convert XML documents.
XPath-a language used for navigation in XML documents.
XSL-FO-a language for formatting XML documents.

XSL-key keywords

<XSL: Template> element used to build a template
<XSL: value-of> element is used to extract the value of a selected node and add the value to the converted output stream.
<XSL: For-each> the element can be used to select each XML Element in the specified node set.
<XSL: Sort> to sort the results, simply add an <XSL: Sort> element to the <XSL: For-each> element in the XSL file.
<XSL: If> to place a conditional test on the content of an XML file, add the <XSL: If> element to the XSL file.
The <XSL: Choose> element is used to express multi-condition tests in combination with <XSL: When> and <XSL: otherwise>.
<XSL: Apply-templates> An element can apply a template to the current element or the subnode of the current element.
<XSL: When expression> similar to the previous judgment, it indicates the code executed when expression is established.
<XSL: otherwise expression> used with <XSL: When> to indicate the code executed when the when condition is invalid.

Code-related XML file content
<? XML version = "1.0" encoding = "gb2312"?> <? XML-stylesheet type = "text/XSL" href = "templete. XSL"?> <Root> <food> <Name> eggs </Name> <price> $5 </price> <info> very nutritious </INFO> <unit> 2 </Unit> </Food> <food> <Name> pancake </Name> <price> $4.5 </price> <info> breakfast essentials </INFO> <unit> 1 </ unit> </Food> <food> <Name> pitfall porridge </Name> <price> $2 </price> <info> my favorites </INFO> <unit> 1 </unit> </Food> </root>
XSL File Content
<? XML version = "1.0" encoding = "gb2312"?> <XSL: stylesheet xmlns: XSL = "http://www.w3.org/1999/XSL/Transform" version = "1.0"> <XSL: template match = "/"> <HTML> Program

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.