Specifying Patterns for the select Attribute

Specifying Patterns for the select Attribute

I'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.

XPath 2.0 Working Draft

As with XSLT, version 2.0 of XPath is in the works, but it's only a working draft at this point, with frequent changes. No software supports it yet, except for some support in the Saxon XSLT processor (http://saxon. sourceforge .net/). You can see the current version of the XPath 2.0 Working Draft at www.w3.org/TR/xpath20/.

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 .



Real World XML
Real World XML (2nd Edition)
ISBN: 0735712867
EAN: 2147483647
Year: 2005
Pages: 440
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net