XPointer

from Wikipedia, the free encyclopedia

XPointer or XML Pointer Language is a query language developed by the World Wide Web Consortium (W3C) to address parts of an XML document. It is an extension of the XPath specification, with which parts of an XML document can also be addressed.

XPointer makes it possible in particular to refer to parts of an XML document in a URI . After the original XPointer definition was hesitantly implemented, the W3C decided to split the definition into several documents.

Simple references

Simple references are similar to local links in HTML documents. They refer to XML elements that are identified by an ID. An XLink should serve as an example . The "Rudolph" is the actual XPointer. The link points to the element with the ID "Rudolph" in the "Brief.xml" file:

xlink:href="Brief.xml#Rudolph"

Simple references belong to the shorthand notation of XPointer and are specified in the XPointer framework. This is where the basis for more complex XPointer in scheme-based notation is created.

The element () scheme

The element () schema can be used to create references to certain children in the tree structure of an XML document. The XLink in the following example points to the 2nd sub-element of the 1st (root) element in the XML document "index.xml":

xlink:href="index.xml#element(/1/2)"

The xpointer () scheme

Any complex references to parts of XML documents can be created with the xpointer () schema. An XPath expression can be used to address the desired parts of the document . There are also other options that are not available in XPath:

  • Points before or after XML structure elements ( start-point(), end-point(), ...)
  • Areas between XML structure elements ( range(), range-to(), ...)
  • Selected areas in free text ( string-range(), ...)

The following example provides the 1st to 4th element of the "Page" type within the "MobyDick" element in the "Bookshelf.xml" file:

xlink:href="Bücherregal.xml#xpointer(/MobyDick/Seite[position()=1]/range-to(/MobyDick/Seite[4]))"

The text after the hash (#) is again the actual XPointer. Any number of XPointer expressions can be written one after the other in the scheme-based notation. The result of the expression is the result of the first partial expression that returns a result. Example:

element(/1/4)xpointer(//Buch[4])

Web links

Wiktionary: XPointer  - explanations of meanings, word origins, synonyms, translations

Individual evidence

  1. http://www.w3.org/TR/xptr-framework