XML technologies / DocBook / Customizing DocBook / Extending DocBook 5 / Extending DocBook with SVG

(Excerpt from "DocBook-XML: Medienneutrales und plattformunabhängiges Publizieren" by Thomas Schraitle)

SVG (Scalable Vector Graphics) is used to draw vector graphics. In DocBook, SVG is supported through the pattern db._any.svg, which, like db._any.mml, acts as an ‘anchor’. Override it with SVG elements to make the graphic markup elements available within imageobject.

To add these elements to DocBook, proceed as follows:

  1. Downloading the SVG RELAX NG schema
    Download the SVG RELAX NG schema.

  2. Creating a customization file
    Create a customization file (for example dbsvg.rnc or dbsvg.rng):

    Example: Customization file for DocBook with SVG

<?xml version="1.0"?> 
<grammar xmlns="http://relaxng.org/ns/structure/1.0"> 
    <include href="docbook.rng"> 
        <define name="db._any.svg"> 
            <externalRef href="svg11.rng" ns="http://docbook.org/ns/docbook"/> 
        </define> 
        <define name="db._any"> 
            <element> 
                <anyName> 
                    <except> 
                        <nsName ns="http://docbook.org/ns/docbook"/> 
                        <nsName ns="http://www.w3.org/1999/xhtml"/> 
                        <nsName ns="http://www.w3.org/2000/svg"/> 
                    </except> 
                </anyName> 
                <zeroOrMore> 
                    <choice> 
                        <attribute> 
                            <anyName/> 
                        </attribute> 
                        <text/> 
                        <ref name="db._any"/> 
                    </choice> 
                </zeroOrMore> 
            </element> 
        </define> 
    </include> 
</grammar>

default namespace db = "http://docbook.org/ns/docbook" 
namespace svg ="http://www.w3.org/2000/svg" 
namespace html = "http://www.w3.org/1999/xhtml" 
include "docbook.rnc" { 
  db._any.svg = external "svg11.rnc" 
  db._any = element * - (db:* | html:* | svg:*) { 
      (attribute * { text } 
       | text 
       | db._any)* 
   } 
}

  1. Using the customization file
    Use the customization file instead of the original DocBook file (see Validating with a DocBook 5 customization file).

For information about the SVG specification, see W3C: Scalable Vector Graphics (SVG) 1.1.

  

back to top