Technologies XML / DocBook / Documents modulaires / Inclusion partielle avec XPointer / Inclure du contenu par autoréférence

(Extrait de « DocBook-XML : publication multiformat et indépendante de la plateforme" de Thomas Schraitle)

Il faut parfois référencer des informations contenues dans des éléments du même fichier, plutôt que d’un autre fichier. Ici aussi, vous pouvez obtenir l’information au moyen d’une expression XPointer :

Exemple : Inclusion par une expression XPointer sans attributs href.

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>

Notez que, pour le même fichier, vous n’avez besoin d’aucun href comme attribut.

  

haut de page