This presentation will serve as an introduction to XPath, including patterns and expressions, and test expressions and functions.
Xpath - An introduction to using XPath in XML
The files in this section are in the xpath folder. Note that many of the examples in this chapter use the same files as examples from the XSLT chapter. That's because we've already seen some of these patterns and expressions, but they are explained and highlighted here. Note also that the HTML files shown were generated by transforming the tigers_rhinos.xml file with the given XSLT file, using Saxon.
| Page | Section | Code |
|---|---|---|
| 154 | Determining the Current Node | same as sort.xsl, sort.html (from page 150 in Chapter 10) |
| 155 | Referring to the Current Node | same as sort.xsl, sort.html (from page 150 in Chapter 10) |
| 156 | Selecting a Node's Children | same as sort.xsl, sort.html (from page 150 in Chapter 10) |
| 157 | Selecting a Node's Parent or Siblings | siblings.xsl, siblings.html |
| 158 | Selecting All of the Descendants | descend.xsl, descend.html |
| 159 | Disregarding the Current Node | disregardnode.xsl, disregardnode.html |
| 160 | Selecting a Node's Attributes | same as siblings.xsl, siblings.html |
| 161 | Selecting Subsets | same as siblings.xsl, siblings.html |
The files in this section are in the expressions folder. Note that the first seven HTML files (pages 164-170) shown were generated by transforming the tigers_rhinos.xml file with the given XSLT file, using Saxon. The examples from pages 171-173 are generated by transforming the tigers_rhinos_noinitials.xml file with the given XSLT file, also using Saxon. Also note that up until page 169, for simplicity's sake, I did not include the picture template. It appears again from page 170 on. You can find more information about the picture template in the Generating Attributes section on page 151 in Chapter 10.
| Page | Section | Code |
|---|---|---|
| 164 | Comparing Two Values | same as choose.xsl, choose.html (from page 149, Chapter 10) |
| 165 | Testing the Position | position.xsl, position.html |
| 166 | Subtotaling Values | sum.xsl, sum.html |
| 167 | Counting Nodes | count.xsl, count.html |
| 168 | Multiplying, Dividing, Adding, Subtracting | multiply.xsl, multiply.html |
| 169 | Formatting Numbers | formatnumber.xsl, formatnumber.html |
| 170 | Rounding Numbers | ceiling.xsl, ceiling.html (again, notice that the picture template from page 151 is used here--for the first time in this chapter) |
| 171-172 | Extracting Substrings |
Figure 12.19: tigers_rhinos_noinitials.xml (All the other XSLT files refer to the tigers_rhinos.xml file.) Figures 12.20 and 12.21: substring.xsl, substring.html Figures 12.22 and 12.23: substring_after.xsl, substring_after.html |
| 173 | Capitalizing Strings | translate.xsl, translate.html |
Click here to return to the course outline.
Last revision September 10, 2001
http://www.informaticus.org/COIN78/week9/index.htm