XPath 2.0 is an expression language that is absolutely fundamental to XSLT 2.0 in several important ways.
A common use of XPath in XSLT is selecting nodes in an XML document. For example, you can make a very wide selection and refer to all the
<li> elements in a document using the expression
select="//li", or be very specific by pointing to the class attribute in the first
<p> in the third
<div> of a document using
XPath expressions are also used by an XSLT processor to match source tree nodes to template rules. As the XSLT processor traverses the element nodes in an XML source document, it looks for a corresponding XPath expression that you set in the
match attribute of an
XPath functions provide you with a wide range of features, enabling you to manipulate strings, dates and times, numbers, and nodes.
In this chapter you take a break from creating full-scale stylesheets and look into some XPath 2.0 features in some detail. You'll do all of the following:
Review node types and properties.
Look at the XPath data model.
Tackle the important topic of path expressions used to navigate the node trees in your source documents.
Get a brief overview of using the XPath Analyzer—a tool that can help you avoid problems along the XPath trail.
Study a rich set of XPath functions that you will encounter repeatedly as you develop your XSLT skills.
In the introduction you saw that XPath models the XML document as a tree of ...