XSL Tutorial: Understand the XSL selection mode

Source: Internet
Author: User
Tags xsl file
What is a select mode selection mode statement that extracts data from XML is a simple method to obtain data. these tags all have a select attribute, pay attention to the specific end-to-end data in XML. every xsl file needs to be imported into the xsl What is the selection mode?

The select mode statement extracts data from XML, which is a simple method to obtain data. all the tags have a select attribute and select the specific named data in XML.

Note that every xsl file needs to be imported into the xsl namespace, http://www.w3.org/tr/wd-example, for example, after the xmlheader is declared:

1,
 
This statement selects a condition one by one (select) and uses the condition. For example, there is a list of users in the following database:



5do8
1
. NET, PHP Design


Cjjer
2
DataBase Manage



You only need to output all Name columns. here there are two headers:
1: You need to select the data under each User node, that is, you need to locate the User node, we apply For-eachThe following Select.
2: Select the Name node. we apply it. Value-The following Select.

Create an xsl file:










Keep as UserList_for-each.xsl. add in the second line of the xml file:


In IE 5 or later browsers, the consequences are visible.

For-each also supports sorting. The order-by statement is separated by semicolons (;) and serves as a list of sorting scales. Add the plus sign () before the list element to sort the content of this tag in ascending order, and add the minus sign (-) to reverse order. As a simplified representation, the sorting scale list is the sequence of sub-tags specified by the select statement. each tag is separated.

2,

Value-of is the value of the current node.
For example Select the value of the Name node.

Xsl: sortSorting

For nodes that match with xsl: for-each or xsl: apply-templates, you can use xsl: sort to sort the content of the selected nodes.

Sort by case
Key words with id are prioritized by uppercase
Key words with id are prioritized by lower case
Sort by letter
Sort key words by letter in ascending order
Sort key words by letter in descending order
Sort by data type
The key words of id are sorted by text type. for example, for a group of id data of 44,305 and, the sorting result is, and 44.
Sort by data type with id as the key word. the result of sorting the above group of data is 101,305
In addition, there is also a way to specify the sort, that is, the order-by applied in the previous student roster example: You can also sort the output students by names.

3,

Xsl: apply-templates uses the defined Template

For example: ......
The preceding three methods have a common application method, that is, the Select statement must be selected. The Select statement syntax is XPath. The Application Specification of XPath will be described in the next section.

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.