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.