XPath, The X-Teams Commando

 
xslt for dummies
Chapter 5 - XPath Espresso
XSLT For Dummies
by Richard Wagner
Hungry Minds 2002
  

XPath is the language used by XSLT to describe how to locate nodes in a source XML document. Think of XPath as the spy or commando who is charged with going into foreign soil, picking out the requested information, and returning it to the XSLT homeland. Every template rule contains one of these XPath commando units that has a mission something like: Go into the source tree and traverse each node. As you do so, look for a state parent that has city children. Bring each of the nodes that match back to me in this handy sack for further processing."

Unlike most languages, XPath has a vocabulary that is extremely targeted . Be it English, French, or Russian, any natural language spoken in the world has a rich, verbose vocabulary. Programming languages, like C or Java, are much more constrained, but you still can use these languages to create programs that have thousands or even millions of lines of code. In contrast, XPaths expressions are almost always placed on a single line.

 Technical Stuff   XPath was originally part of the W3Cs XSLT specification. But after the W3C working group discovered that other non-XSLT specifications, such as XPointer, can use XPath, the group pulled XPath out of the XSLT specification and standardized it on its own.

The primary use of XPath is to create location paths, which are instructions that specify what nodes to bring back to the template rule. More precisely, a location path is an XPath expression that is made up of a series of steps called location steps. A location paths return value is always a node set.

  
 
 
2000-2002    Feedback


XSLT For Dummies
XSLT for Dummies
ISBN: 0764536516
EAN: 2147483647
Year: 2002
Pages: 148

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