XPath: Seeking Out Your Data XPath is the spy or seeker of the X-Team who is charged with going into an XML document and picking out the requested information for XSLT. Without the ability to precisely locate information in an XML document, the ability to transform or do anything special with XML is minimal. Any XSLT transformation must be set up to answer two questions: Input: What information from the original XML document do you want? Output: How would you like that information structured in the output document? XSLT relies on XPath to answer the first question, as shown in Figure 1-4. XSLT looks at an XML document element by element, so XPath expressions are used to tell what your XSLT stylesheet should look for as it goes through the XML document. Looking closer at the preceding XSLT example, the XPath expression name tells XSLT what information to look for, which in this case is to look for all name elements. <xsl:template match=name> <fullname> <xsl:apply-templates/> </fullname> </xsl:template> This XPath expression is intuitive and easy to understand, but for more hearty needs, the syntax can be quite arcane and challenging. (I discuss XPath in detail in Chapter 5.) Interestingly, much of the effort required to develop XSLT stylesheets is related to the input side of the equation, so throughout this book, I spend a sizeable amount of time on how to use XPath. Source XML Document Target Output Document XPath Parts of an XSLT Stylesheet What info do you want from the source Document? XSLT Template Rules How would you like the new document structured? What format? Figure 1-4: XSLT uses XPath to retrieve data from XML documents. 16 Part I:  Getting Started with XSLT