XML technologies / DocBook / Modular documents / Partial inclusion with XPointer / Defining namespaces

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

The previous section showed XPointer expressions that return parts of a DocBook 4 document. Since all DocBook 5 elements belong to a namespace, those expressions return no results for DocBook 5.

For DocBook 5, you need a way to define a namespace in XPointer. This is provided by the xmlns() XPointer scheme. Define the DocBook 5 namespace as follows:

Example: Defining the DocBook 5 namespace with xmlns() XPointer

xmlns(db=http://docbook.org/ns/docbook) 

The DocBook namespace is bound to the prefix db. To select elements belonging to this namespace, prepend the prefix. The complete XPointer expression is as follows, on a single line:

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

If you need more Namespaces, define them as follows:

xmlns(db=http://docbook.org/ns/docbook)
xmlns(svg=http://www.w3.org/2000/svg)
xpointer(/db:chapter/db:section/db:figure/svg:svg)

Note: Predefined namespace prefix xml
The prefix xml is already predefined for the namespace "http://www.w3.org/XML/1998/namespace". In DocBook 5, for example, you need this prefix to access the attributes xml:base or xml:lang.

  

back to top