CHAPTER 2 RELATED XML RECOMMENDATIONS preceding-sibling parent self The axis names are self-explanatory; it s beyond the scope of this book to go into them in too much detail. It s worth mentioning, however, that you can write a shortened form of XPath expressions for the child, parent, and self axes. Table 2-3 provides some examples of the long and short forms of expressions. Table 2-3. Examples of Long and Short Forms of XPath Expressions Long Form Abbreviation child::DVD DVD DVD/attribute::id DVD/@id self::node() . parent::node() .. You saw the use of abbreviated XPath expressions in the previous section on XSLT. For example, you could refer to the nodes using /library/DVD. When you want to refer to a child node, use title rather than child::title. Identifying Specific Nodes XPath allows you to navigate to a specific node within a collection by referring to its position: /library/DVD[2] This expression refers to the second node within the
node. You also can apply a filter within the expression: /library/DVD/[genre=’Comedy’] The preceding expression finds the nodes with a child node containing Comedy. Including Calculations and Functions XPath expressions can include mathematical operations, and you can use the + (addition), (subtraction), * (multiplication), div (division), and mod (modulus) operators. Obviously, you can t use the / symbol for division because it s included in the location path. These expressions might be useful if you want to carry out calculations during a stylesheet transformation. You can also include functions within XPath expressions. These include node set, string, Boolean, and number functions. Again, it s beyond the scope of this book to explore these in detail, but it s useful to know that they exist. If you want to find out more about the XPath recommendation, visit http://www.w3.org/TR/1999/REC-xpath-19991116.
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision best web hosting services
This entry was posted
on Monday, April 30th, 2007 at 7:20 am and is filed under Tomcat.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.