XML technologies / DocBook / Customizing DocBook / Adjusting permitted root elements
(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)
The DocBook 4 DTD does not allow the permitted root elements to be restricted. DocBook 5 supports this through RELAX NG. Several DocBook 5 elements may be used as roots. To restrict the choices, use the following customization file:
Example: Restricting available root elements
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<include href="docbook.rng">
<start>
<choice>
<ref name="db.article"/>
<ref name="db.book"/>
<ref name="db.section"/>
<ref name="db.refentry"/>
</choice>
</start>
</include>
</grammar>include "docbook.rnc"
{
start = (db.article | db.book | db.section | db.refentry )
}The previous example permits only the following root elements: article, book, section or refentry.
To extend the choices instead, use a slightly different syntax. For example, to permit the element exercise as an additional root element:
Example: Extending the permitted root elements
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<include href="docbook.rng">
<start combine="choice">
<ref name="db.exercise"/>
</start>
</include>
<!-- Definition von db.exercise -->
</grammar>include "docbook.rnc"
{
start |= db.exercise
}
# Definition von db.exercise
Copyright © 2009 Millin Verlag
You may print the online version for your private use.
Otherwise, this chapter from "DocBook-XML: Medienneutrales und plattformunabhängiges Publizieren" is subject to the same provisions as the printed edition: the work, including all its parts, is protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Millin Verlag, Siebengebirgsring 36, 53797 Lohmar, info(at)millin.de
back to top