O'Reilly logo

XPath and XPointer by John Simpson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. XPointer Syntax

Like XPath, XPointer is not in itself an XML vocabulary. Rather, it’s meant to be used within the markup in XML documents — most often in XLink or XLink-like situations requiring a URI. This chapter covers the details of coding the various XPointer forms. There are two approaches to defining XPointers as described in the XPointer Framework. Shorthand pointers use a very brief syntax, while scheme-based XPointers use a more complex syntax composed of pointer parts.

Shorthand Pointers

In XHTML hyperlinking, as you know, you can locate a subresource using a combination of a named anchor (the <a name=" mybookmark "/> sort of tag) and a normal anchor (<a href=" #mybookmark ">...). Notwithstanding the limitations of XHTML subresource hyperlinking, the XPointer spec’s authors recognized its principal value: simplicity. Thus, they carried it forward into XPointer, enhanced slightly for the new standard’s use with XML documents of any vocabulary. This form of an XPointer is called a shorthand pointer; it includes neither scheme nor XPath expression, just the “name” of the target resource:

            name

In an XPointer, as in an XHTML fragment identifier, the pound sign/hash mark, #, is not itself part of the XPointer or other fragment identifier. It merely serves to delimit the fragment from the full URI preceding it. Section 8.3 at the end of this chapter addresses this issue more fully.

The value of name is the value of an ID-type attribute assigned to some element in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required