XML technologies / DocBook / Modular documents / Partial inclusion with XPointer / Including using an XPath

(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)

Although an XML document is entered as a text file, the XML parser builds a tree in memory when reading it. A particular element in this tree can be identified by a path, called an "XPath". For example, if a DocBook 4 document starts with a chapter containing a section with a paragraph, the path to that paragraph is:

/chapter/section/para 

This creates an XPath expression. The XPointer specification requires this expression to be enclosed in xpointer(). The following lines are therefore valid XPointers:

xpointer(/chapter/section)
xpointer(/chapter/section[2])
xpointer(/chapter/title)
xpointer(id('foo')) 

Starting from chapter, these XPointer expressions select different items: line 1 selects all section elements; line 2 selects only the second section, line 3 selects the element title of chapter, and line 4 selects the element whose ID value is foo.

  

back to top