XML technologies / DocBook / Customizing DocBook / Removing elements / Removing an entire class

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

You may need to remove an entire class of elements, such as inline graphics or inline equations. In DocBook 4, this is slightly more complex than the previous customizations. Proceed as follows:

Customizing DocBook 4

Procedure: Removing inline graphics, equations, etc. in DocBook 4

  1. Disabling %informal.class;
    Add this line to your customization file:

<!ENTITY % informal.class "">

  1. Enabling redeclaration parameters
    Add these lines:

<!ENTITY % dbhier.redecl.module "INCLUDE"> 
<!ENTITY % rdbhier SYSTEM "db-informal.rdbhier.mod">

<!ENTITY % dbpool.redecl.module "INCLUDE"> 
<!ENTITY % rdbpool SYSTEM "db-informal.rdbpool.mod">

  1. Loading the DocBook DTD
    Add these lines to your customization file to load the DocBook DTD:

<!ENTITY % DocBookDTD PUBLIC 
   "-//OASIS//DTD DocBook XML V4.5//EN" 
   "http://www.docbook.org/xml/4.5/docbookx.dtd"> 
%DocBookDTD;

  1. Creating the file db-informal.rdbpool.mod
    Create a file db-informal.rdbpool.mod. This file no longer contains any %informal.class;-entities:

<!ENTITY % local.component.mix ""> 
<!ENTITY % component.mix 
                "%list.class;           |%admon.class; 
                |%linespecific.class;   |%synop.class; 
                |%para.class; 
                |%formal.class;         |%compound.class; 
                |%genobj.class;         |%descobj.class; 
                |%ndxterm.class;        |beginpage 
                %local.component.mix;"> 

<!ENTITY % local.sidebar.mix ""> 
<!ENTITY % sidebar.mix 
                "%list.class;           |%admon.class; 
                |%linespecific.class;   |%synop.class; 
                |%para.class; 
                |%formal.class;         |procedure 
                |%genobj.class; 
                |%ndxterm.class;        |beginpage 
                %local.sidebar.mix;"> 

<!ENTITY % local.qandaset.mix ""> 
<!ENTITY % qandaset.mix 
                "%list.class;           |%admon.class; 
                |%linespecific.class;   |%synop.class; 
                |%para.class; 
                |%formal.class;         |procedure 
                |%genobj.class; 
                |%ndxterm.class; 
                %local.qandaset.mix;"> 


<!ENTITY % local.revdescription.mix ""> 
<!ENTITY % revdescription.mix 
                "%list.class;           |%admon.class; 
                |%linespecific.class;   |%synop.class; 
                |%para.class; 
                |%formal.class;         |procedure 
                |%genobj.class; 
                |%ndxterm.class; 
                %local.revdescription.mix;"> 

<!ENTITY % local.footnote.mix ""> 
<!ENTITY % footnote.mix 
                "%list.class; 
                |%linespecific.class;   |%synop.class; 
                |%para.class; 
                %local.footnote.mix;"> 

<!ENTITY % local.example.mix ""> 
<!ENTITY % example.mix 
                "%list.class; 
                |%linespecific.class;   |%synop.class; 
                |%para.class; 
                |%ndxterm.class;        |beginpage 
                %local.example.mix;"> 

<!ENTITY % local.highlights.mix ""> 
<!ENTITY % highlights.mix 
                "%list.class;           |%admon.class; 
                |%para.class; 
                |%ndxterm.class; 
                %local.highlights.mix;"> 

<!ENTITY % local.para.mix ""> 
<!ENTITY % para.mix 
                "%list.class;           |%admon.class; 
                |%linespecific.class; 
                |%formal.class; 
                %local.para.mix;"> 

<!ENTITY % local.admon.mix ""> 
<!ENTITY % admon.mix 
                "%list.class; 
                |%linespecific.class;   |%synop.class; 
                |%para.class; 
                |%formal.class;         |procedure|sidebar 
                |anchor|bridgehead|remark 
                |%ndxterm.class;        |beginpage 
                %local.admon.mix;">

  1. Creating the file db-informal.rdbhier.mod
    Create a file db-informal.rdbhier.mod. This file contains all %*.mix; entities present in dbhierx.mod:

<!ENTITY % local.divcomponent.mix ""> 
<!ENTITY % divcomponent.mix 
                "%list.class;           |%admon.class; 
                |%linespecific.class;   |%synop.class; 
                |%para.class; 
                |%formal.class;         |%compound.class; 
                |%genobj.class;         |%descobj.class; 
                |%ndxterm.class;        |beginpage 
                %forms.hook; 
                %local.divcomponent.mix;"> 

<!ENTITY % local.refcomponent.mix ""> 
<!ENTITY % refcomponent.mix 
                "%list.class;           |%admon.class; 
                |%linespecific.class;   |%synop.class; 
                |%para.class; 
                |%formal.class;         |%compound.class; 
                |%genobj.class;         |%descobj.class; 
                |%ndxterm.class;        |beginpage 
                %local.refcomponent.mix;"> 

<!ENTITY % local.indexdivcomponent.mix ""> 
<!ENTITY % indexdivcomponent.mix 
             "itemizedlist|orderedlist  |variablelist|simplelist 
             |%linespecific.class;      |%synop.class; 
             |%para.class; 
             |anchor|remark 
             |%link.char.class; 
             |beginpage 
             %local.indexdivcomponent.mix;">

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

Customizing DocBook 5

DocBook 5 customizations are much simpler. Proceed as follows:

Procedure: Removing inline graphics, equations, etc. in DocBook 5

  1. Creating the customization file
    Create a customization file with this content:

<grammar ns="http://docbook.org/ns/docbook" xmlns:db="http://docbook.org/ns/docbook" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0"> 
    <include href="docbook.rng"> 
        <!-- Ihre Anpassungen --> 
    </include> 
</grammar>

namespace db = "http://docbook.org/ns/docbook" 
default namespace = "http://docbook.org/ns/docbook" 
include "docbook.rnc" { 
# Ihre Anpassungen 
}

  1. Identifying pattern names
    Find the db.*.inlines you want to remove from DocBook 5. For the requirement above, these are db.graphic.inlines and db.math.inlines. Add:

<!-- Ihre Anpassungen --> 
<define name="db.graphic.inlines"> 
    <notAllowed/> 
</define> 
<define name="db.math.inlines"> 
    <notAllowed/> 
</define>

# Ihre Anpassungen 
db.graphic.inlines = notAllowed 
db.math.inlines = notAllowed

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

  

back to top