Corrections to Chapter 11 of XML in a Nutshell, XPointers

p. 183: An XPointer with multiple XPointer parts does not select the union of all the different XPointer parts. Rather it indicates the node set returned by the first XPointer part that returns a non-empty node set. The bottom of the page should read:

If you're uncertain whether a given XPointer will locate something, you can back it up with an alternative XPointer. For example, this XPointer looks first for first_name elements. However, if it doesn't find any it will look for last_name elements instead:

xpointer(//first_name)xpointer(//last_name)

The last_name elements will be found only if there are no first_name elements. You can string as many of these xpointer() parts together as you like. For example, this XPointer looks first for first_name elements. If it doesn't find any, it then seeks out last_name elements. If it doesn't find any of those, it looks for middle_initial elements. If it doesn't find any of those, it returns an empty node set:

xpointer(//first_name)xpointer(//last_name)xpointer(//middle_initial)

No special separator character or white space is required between the individual xpointer() parts.

p. 185: In the second code fragment each XPath expression should be preceded by here(). That is, the entire example and the paragraph that follows should read as follows:

<slide xmlns:xlink="http://www.w3.org/1999/xlink">

  <point>Acme Wonder Goo is a delicious dessert topping!</point>  
  <point>Acme Wonder Goo is a powerful floor cleaner!</point>  
  <point>It's two products in one!</point>  

  <previous xlink:type="simple" xlink:href= 
     "#xpointer(here()/ancestor::slide/preceding-sibling::slide[position()=1])">
    Back
  </previous>
  <next xlink:type="simple" xlink:href=
     "#xpointer(here()/ancestor::slide/following-sibling::slide[position()=1])">
    Back
  </next>
</slide>

The here() function, an XPointer extension to XPath, indicates that the context node is the node in the XML document where the XPointer appears, the xlink:href attribute nodes in this example.

pp. 187-188: points are not found along the child axis. They can only be located using the start-point() and end-point() functions introduced. Points inside text nodes can only be identified using the string-range() function introduced later in the chapter.

p. 189: In the second to last paragraph, change xpointer(range(//title)) to xpointer(range-inside(//title)).


[ XML in a Nutshell Corrections | XML in a Nutshell Home Page | Table of Contents | Examples | Order from Amazon ]

Copyright 2001 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified November 12, 2001