Specifying Patterns for the select AttributeI've taken a look at the kinds of expressions you can use with the <xsl: template> element's match attribute. You can use an even more involved syntax with the select attribute of the <xsl:apply-templates> , <xsl:value-of> , <xsl:for-each> , <xsl:copy-of> , and <xsl: sort > elements. The select attribute uses XPath expressions, and XPath is a W3C recommendation as of November 16, 1999. You can find the XPath recommendation (the current version is 1.0) at www.w3.org/TR/xpath.
We've seen that you can use the match attribute to find nodes by name , child element(s), attributes, or even descendants. And we've seen that you can make some tests to see if elements or attributes have certain values. You can do all that and more with the XPath specification supported by the select attribute, including finding nodes by parent or sibling elements and performing much more involved tests. XPath is much more of a true language than the expressions you can use with the match attribute; for example, XPath expressions can return not only lists of nodes, but also Boolean, string, and numeric values. XPath expressions are more powerful than the match expressions we've seen; for one thing, they're not restricted to working with the current node or child nodes because you can work with parent nodes, ancestor nodes, and more. Specifying the node in relation to which you want to work is called specifying an axis in XPath. I'll take a look at XPath syntax in detail next . |