Node Tests

Most of the time the node test part of the basis is simply an element name like PERSON or BORN. However, there are seven other possibilities:

  <CITATION CLASS="TURING" ID="C2">
    <AUTHOR>Turing, Alan M.</AUTHOR>
    "<TITLE>On Computable Numbers,
      With an Application to the Entscheidungs-problem</TITLE>"
    <JOURNAL>
      Proceedings of the London Mathematical Society</JOURNAL>,
    <SERIES>Series 2</SERIES>,
    <VOLUME>42</VOLUME>
    (<YEAR>1936</YEAR>):
    <PAGES>230-65</PAGES>.
  </CITATION>

The following XPointer refers to the quotation mark before the TITLE element.

 id("C2")/child::text()[position()=2] 

The first text node in this fragment is the whitespace between <CITATION CLASS="TURING" ID="C2"> and <AUTHOR>. Technically, this XPointer refers to all text between </AUTHOR> and <TITLE>, including the whitespace and not just the quotation mark.

Because character data does not contain any child nodes, most relative location steps may not be attached to an XPointer that selects a text node. The exception is the point() node test which will be discussed later.

The comment() node test specifically refers to comments. For example, this XPointer points to the third comment in the document:

/descendant::comment()[position()=3]

Because comments do not contain attributes or elements, you cannot add an additional child, descendant, or attribute relative location step after the first term that selects a comment.

Finally, the processing-instruction() node test selects any processing instructions that occur along the chosen axis. You can use it without any arguments to select any processing instructions, or with arguments to specify the particular processing instruction targets you want to select. For example, /descendant::processing-instruction() selects all processing instructions in the document. However, /descendant::processing-instruction(xml-stylesheet) only finds processing instructions that begin <?xml-stylesheet. /descendant::processing-instruction(php) only finds processing instructions intended for PHP. As with comments, because processing instructions do not contain attributes or elements, you cannot add an additional child, descendant, or attribute relative location term after the first term that selects a processing instruction.

The point() and range() node tests refer to new ways of dividing an XML document. They will be discussed below.

Although the other node tests all end with parentheses, none of them except processing-instruction() actually take any arguments.


Previous | Next | Top | Cafe con Leche

Copyright 2000 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified November 8, 2000