Personal tools
You are here: Home Tech Tidbits XPointer

XPointer

Making citations and identifying objects within XHTML documents.

XPointer provides a vital missing link to allow a URL to indicate a certain points or portions of an HTML page even for parts of the document that the publisher did not use named anchors or "id" attributes.

Since the URL provides the unique identifier and location of a web document, the URL can serve as an object database's object or as metadata. And then it may be possible to uniquely identify a sub-object within a document using the anchor/hashtag suffix of a URL (e.g. http://example.com/document.html#part1 ). However, uniquely identifying a sub-object within the main document is not possible within a URL without the document publisher having included the anchor or id'ed section and without using the XPointer standard (http://www.w3.org/TR/xptr-framework/). Using XPointer as part of a URL gives the power to a reader of the document to cite or point to any specific portion of a document as a web link. 

Unfortunately, browsers do not universally accept XPointer. For the examples below it is necessary to use a browser that can be modified to accept XPointer's. Fortunately, since the hashtag suffix is understood by almost browser to indicate something within a document, the browsers will at least take you to the top of the document indicated in the URL.

Note that although the XPointer enhanced URL can be used as a unique identifier, there may be multiple XPointer references to the same portion. There may be some uses of XPointers where being consistent is important. For this reason, using the internal "id"s is almost always preferable when available. When not possible to use an "id" and XPointer is the only method, then there should be best practices developed.

Potential Uses

The first and most obvious use is to link deep within a long document. Using an XPointer reference within a link also allows for a very clear and specific citation. Another use is for "tags" or metadata, when it is important to refer directly to a portion of a document rather than the whole.

A novel use is to let URLs be used to convey specific data from web documents that may have other data. For example, if you want to let someone find your contact info, you can point to a profile page with lots of information, but a clearly labeled portion has the contact information. For example, using RDFa for the FOAF method of embedding contact information, the XPointer can specifically identify the portion of a large document that has lots of extraneous data and even other contact information. Similarly, if a web page has many calendar items each embedded with Microformats, an XPointer reference can indicate which one to "grab."

One place where using an XPointer enhanced URL is for the QR Barcodes. Right now it is possible to either show a link or a relatively short data document. Contact information is one standard form of data for the QR barcode standard. Unfortunately, the limited length of the document that can be encoded in a cell phone readable barcode reader hampers sending multiple phone numbers, etc. If a URL could be scanned instead and the URL indicate a specific set of contact information in a profile page or any other web document, then the XPointer could "know" what it was looking for based on the RDFa or Microformat short-name, and then pull the specific data.

 

Examples:

Using normal HTML class attribute (note that position is not used or in this case needed). In order to test these I used the Codedread XPointer Firefox extension, though there seems to be a glitch in the current version that interferes with the address bar so I had to use actual links in a page.

 

http://openlylocal.com/members/4875-Robert-Wright#xpointer(//p[@class="attribution"])

Example on same page pointing to an RDFa object.

http://openlylocal.com/members/4875-Robert-Wright#xpointer(//span[@typeof="foaf:Person"])

 

Browser Support

Here are some of the browsers bug reports that discuss XPointer. Please note that you can vote and/or add comments.

Chrome: http://code.google.com/p/chromium/issues/detail?id=25026
Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=32832

Document Actions
What's News