Easy to start with XSLT Chapter fourth: XPath syntax

Source: Internet
Author: User
Tags count functions numeric value xpath xsl xslt
Grammar

4.4 Functional Functions (functions)

There are many functional functions in XPath that can help us pinpoint the nodes we need.

Count () feature
Function: Statistics count, returns the number of nodes that meet the criteria.
For example: <p><xsl:value-of select= "count (Person[name=tom])"/></p>
Description: The purpose of the code is to display the name attribute value for the person element as Tom has several.

Number () feature
Action: Converts the text in the value of a property to a numeric value.
Example: <p>the number is: <xsl:value-of select= "number (book/price)"/></p>
Description: The purpose of the code is to display the price of the book.

SUBSTRING () function
Syntax: substring (value, start, length)
Function: Intercepts a string.
For example: <p><xsl:value-of select= "substring (name, 1, 3)"/></p>
Description: The purpose of the code is to intercept the value of the name element, starting with the first letter and showing it to the third.

SUM () feature
function: Sum.
Example: <p>total price = <xsl:value-of select= "sum (//price)"/></p>
Description: The purpose of the code is to calculate the and of all prices.

These features are just a few of the XPath syntax, and a lot of functional functions are not covered, and XPath syntax is still evolving. These functions allow us to implement more complex queries and operations.

See here, our introductory tutorial is almost over. By quick Learning, I hope you have a basic idea of XSLT: XSLT is a language that transforms XML documents, and it contains two processes: transformation and formatting. XSLT is much more powerful than CSS, and it has syntax for similar data queries. If you are interested in XSLT, then the above knowledge is far from enough, you need to query more information. Atzie in the last chapter provides you with the main XSLT resources.



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.