XML technologies / DocBook / Modular documents / Partial inclusion with XPointer / Chaining multiple XPointer

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

If the required information can occur in different elements, chained XPointer expressions provide a way to retrieve it. For example, a chapter title may appear directly after chapter or within chapterinfo. To retrieve either, chain the individual XPointer expressions:

xpointer(/chapter/title) xpointer(/chapter/chapterinfo/title)

If the first XPointer expression finds nothing, the second is evaluated. Chained XPointer expressions are processed until one returns an object or the end is reached. For DocBook 5, the equivalent expression is as follows (all on one line):

xmlns(db=http://docbook.org/ns/docbook) xpointer(/db:chapter/db:title) xpointer(/db:chapter/db:info/db:title)

  

back to top