XML technologies / DocBook / Customizing DocBook / Removing attributes / Removing specific attributes

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

To remove a specific attribute from an element, for example width from screen, proceed as follows for DocBook 4:

Procedure: Removing width from screen in DocBook 4

  1. Identifying the element definition
    In the DocBookDTD files, find the definition of the attributes of screen. The line looks like this:

<!ENTITY % screen.attlist "INCLUDE"> 
<![ %screen.attlist; [ 
  <!ATTLIST screen 
          %width.attrib; 
          %linespecific.attrib; 
          %common.attrib; 
          %screen.role.attrib; 
          %local.screen.attrib;> 
]]>

  1. Creating a customization file
    Create a customization file and first disable the attribute definition for the element screen. You identified its name in the previous step, "Identifying the element definition":

<!ENTITY % screen.attlist "IGNORE"> 

  1. Loading the DocBook DTD
    Add the following 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. Redefining the attribute list
    Insert the attribute definition from step 1, "Identifying the element definition", but remove the parameter entity %width.attrib;

<!ENTITY % local.screen.attrib ""> 
<!ATTLIST screen 
   %linespecific.attrib; 
   %common.attrib; 
   %screen.role.attrib; 
   %local.screen.attrib;>

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

For DocBook 5, add the following code to your customization file:

<define name="db.screen.width.attribute">
    <empty/>
</define>

include "docbook.rnc" {
   db.screen.width.attribute = empty
}

  

back to top