Introduction to XSL Functions (4)

Source: Internet
Author: User
Tags object model xsl xsl file

This period learns the XSL style method for use with XSL elements < Xsl:for-each >, < xsl:value-of >, < xsl:template > select Properties, < xsl: Apply-templates > 's Match properties, < Xsl:if >, < xsl:when > 's Test attribute, filter the scope of the element to provide greater flexibility.

XML is the same as DHTML (Dynamic HTML), these nodes are all objects, and these objects are layered, starting from the root node to form a hierarchical clear tree structure, which formed the Document Object Model DOM, through the object's properties, methods to access control of XML nodes.

We are not going to elaborate on the XML DOM in detail, as it can be written in a more extensive tutorial, and we'll discuss some common methods to get a general idea of the DOM's object approach.

Note: From the beginning of this period, all samples no longer provide complete source code, if you do not understand, please read the previous seven, and practicing.

One, End ()

Meaning: Returns the last element in the collection.

Example: Output last Resume

Suppose the XML file format is:

......< Resume >...</resume >......< resume >...</resume .....

The contents of the corresponding XSL file are:

< Xsl:for-each select= "Resume[end ()]" >......</xsl:for-each >

Or

< Xsl:templates match= "Resume[end ()]" >......</xsl:templates >

Or

< Xsl:apply-template select= "Resume[end ()]" >......</xsl:apply-template >

Second, index ()

Meaning: Returns the position of the element in the collection, the return value being an integer, where the first element returns 0

Example: Return to the previous three resumes

Resume[index () $le $3]

Note: index () is related to the parent element, see the following example:

< x >

< y/>

< y/>

</x >

< x >

< y/>

< y/>

</x >

Returns the first < Y > in all < x >

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.