RU beehive logo ITEC dept promo banner
ITEC 325
2015spring
ibarland

homelectsexamshws
D2Lbreeze (snow day)

lect36-xpath-functions
XPath functions
and, some functions over children

Originally based on XML Visual Quickstart Guide by Kevin Howard Goldberg, and notes therefrom by Jack Davis (jcdavis@radford.edu).

Chapter 4 - XML

Location paths are used for further processing by templates (xsl:template and xsl:apply-templates), or in test conditions (xsl:if, and the xsl:whens inside xsl:choose). In both of these cases, there are often times that you will not want to use all the data in the node set returned. With XPath functions, you can apply additional logic to these node sets to return only the data you need.

Location paths can be used to extract the contents of a node using xsl:value-of. Remember, xsl:value-of returns the string value of the first node in a node set. With XPath functions, you can perform further operations on that string.

Note that xsl:value-of's attribute “select” can be any expression, not just a single node (variable): e.g. The monument is <xsl:value-of select="round(height div 3.28)" /> meters tall.
This is the same as Java expressions, which can of course be more than a single variable; they include constants and function-calls as well1 (e.g. wage*Math.round(40*weeksWorked)/52); and SQL SELECT statement which can select entire expressions instead of merely columns (SELECT wage*round(40*weeksWorked)/52 FROM )

XSLT functions


1 Expressions in Java don't end in semicolons. It's statements that need to end in a semicolon; statements are themselves built out of keywords, punctuation, and expressions (if-else statments, while-statements, block statements, etc.).      

2 This explanation is a bit backwards from history (originally a number was like an array-lookup, which they then generalized to boolean filters), however the more useful principle to remember is filter, not array-lookup; just be aware of what the shorthand means.      

homelectsexamshws
D2Lbreeze (snow day)


©2015, Ian Barland, Radford University
Last modified 2015.Apr.22 (Wed)
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Rendered by Racket.