XML technologies / DocBook / Customizing DocBook / Removing attributes / Removing attributes from all elements

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

The following sections show how to remove common attributes in DocBook 4 and 5.

Customizing DocBook 4

For DocBook 4, proceed as follows:

Procedure: Removing conformance, remap, security, userlevel and vendor from all elements

  1. Identifying the attribute declaration
    There are two Parameter entities used in every element: %effectivity.attrib;, %common.attrib; and %idreq.common.attrib;. The latter differs only in the declaration of the id attribute (#REQUIRED instead of #IMPLIED). The parameter entities %effectivity.attrib; and %common.attrib; have this declaration after all references are resolved:

<!ENTITY % effectivity.attrib 
   "arch CDATA #IMPLIED 
   condition CDATA #IMPLIED 
   conformance CDATA #IMPLIED 
   os CDATA #IMPLIED 
   revision CDATA #IMPLIED 
   security CDATA #IMPLIED 
   userlevel CDATA #IMPLIED 
   vendor CDATA #IMPLIED 
   %local.effectivity.attrib;"> 
<!-- ... --> 
<!ENTITY % common.attrib 
   "id ID #IMPLIED 
   lang CDATA #IMPLIED 
   remap CDATA #IMPLIED 
   xreflabel CDATA #IMPLIED 
   revisionflag CDATA #IMPLIED 
   %effectivity.attrib; 
   %local.common.attrib;">

  1. Creating a customization file
    Create a customization file and insert the preceding declaration. Remove the lines for unwanted attributes. In this example, these are conformance, remap, security, userlevel and vendor:

<!ENTITY % effectivity.attrib 
   "arch CDATA #IMPLIED 
   condition CDATA #IMPLIED 
   os CDATA #IMPLIED 
   revision CDATA #IMPLIED 
   %local.effectivity.attrib;"> 
<!ENTITY % common.attrib 
   "id ID #IMPLIED 
   lang CDATA #IMPLIED 
   xreflabel CDATA #IMPLIED 
   revisionflag CDATA #IMPLIED 
   %effectivity.attrib; 
   %local.common.attrib;"> 
<!ENTITY % common.attrib 
   "id ID #REQUIRED 
   lang CDATA #IMPLIED 
   xreflabel CDATA #IMPLIED 
   revisionflag CDATA #IMPLIED 
   %effectivity.attrib; 
   %local.common.attrib;">

  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. 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 requires minimal changes: simply define the corresponding pattern as empty:

<grammar xmlns="http://relaxng.org/ns/structure/1.0">
    <include href="docbook.rng">
        <define name="db.conformance.attribute">
            <empty/>
        </define>
        <define name="db.security.attribute">
            <empty/>
        </define>
        <define name="db.userlevel.attribute">
            <empty/>
        </define>
        <define name="db.vendor.attribute">
            <empty/>
        </define>
    </include>
</grammar>

default namespace db = "http://docbook.org/ns/docbook"
include "docbook.rnc" {
  db.conformance.attribute = empty
  db.security.attribute = empty
  db.userlevel.attribute = empty
  db.vendor.attribute = empty
}

  

back to top