Chapter 9. XPointer Beyond XPath

Using XPath, in conjunction with XPointer, provides a wide (seemingly infinite) variety of ways to locate XML content. But it stops short of being able to “locate” everything. This chapter covers XPointer extensions to XPath’s already rich facilities, extensions that plug the gap between what XPath does and what users might expect of a full-fledged “point to some XML-based content” standard.

In this chapter, when I refer to “XPointer” or “the XPointer spec,” I’m referring to the XPointer xpointer( ) Scheme Working Draft dated July 10, 2002.

Why Extend XPath?

After you’ve worked with XPath for a while — especially in XSLT — you may start to get a little cocky. It seems impossible that something in an XML document might be unlocatable. From everything in the document down to individual PIs, comments, even individual characters (in the sense of using functions such as substring( ) and translate( )) — what’s left? The reason your cockiness may be unjustified is that you’ve overlooked a small but disproportionately significant class of activities for which XPointer would be useful, but for which XPath provides absolutely no support.

Consider XPointer’s unintelligent counterpart in XHTML: simple fragment identifiers that use named anchors; then consider the activity XHTML supports: web browsing. The Web is already driven by content authors and browser capabilities, no? What could possibly be missing?

What’s missing is the third party in a web-based transaction: ...

Get XPath and XPointer now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.