XML technologies / DocBook / Modular documents / Partial inclusion with XPointer / Including content through self-reference

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

Sometimes you need to reference information in elements located in the same file rather than another file. Here too, you can retrieve the information with an XPointer expression:

Example: Inclusion with an XPointer expression without href attributes

DocBook 4

<chapter>
    <chapterinfo>
        <author>
            <firstname>Tux</firstname>
            <surname>Penguin</surname>
        </author>
    </chapterinfo>
    ...
    <para>Der Autor dieses Kapitels ist <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" xpointer="xpointer(/chapter/chapterinfo/author)"/>.</para>    
</chapter>

DocBook 5

<chapter xmlns="http://docbook.org/ns/docbook">
    <info>
        <author>
            <personname>
                <firstname>Tux</firstname>
                <surname>Penguin</surname>
            </personname>
        </author>
    </info>
    ...
    <para>Der Autor dieses Kapitels ist <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(/db:chapter/db:info/db:author)"/>.
    </para>      
</chapter>

Note that, for the same file, you need no href attribute.

  

back to top