Concepts

The XPointer standard provides a way to create hypertext links that does not depend on the target object being an XML element, or on a target element having a unique identifier. Although primarily aimed at support for hypertext linking for user navigation through documents, it may also be used in other application areas.

Absent identifiers

There may be times when it is necessary to provide a link to an object that has no unique identifier. Those responsible for preparing the text may not be able to identify the elements that will later be the target of hypertext links, and the cost of adding unique values to all elements (just in case) may not be justifiable.

Ranges and text

Consider a very large paragraph that contains a single short phrase of interest. A link to the element containing the entire paragraph is hardly helpful in this circumstance. The ability to link directly to the embedded range of text is preferable.

XPath and beyond

The navigation techniques provided by the XPath standard (described in Chapter 13) are exploited by the XPointer standard. This is a very flexible technique, as a selection of examples demonstrates. Using XPointer expressions, it is possible to target:

  • the third chapter

  • the second child element of the third chapter

  • the second paragraph in the section with an identifier of 'Sec12'

  • the fifth paragraph of the fourth chapter

  • all chapter titles

  • the last-but-one item in the first list of the third chapter

  • the second list with a Type attribute value of 'indented'

  • the first paragraph with a Level attribute value of 'top-secret', in the first section with a Level attribute value of 'secret'

  • the second occurrence of the phrase 'A little learning is a dangerous thing' in the fifth chapter

  • the word 'dangerous' within the string 'A little learning is a dangerous thing'.

Most of these examples should not be surprising to those already familiar with XPath. However, a few of the later examples could not be supported by XPath alone.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.84.32