Removing Attributes

Just as there may be more elements than you need, there may be more attributes.

Removing an Attribute

Suppose you want to remove the RenderAs attribute from the Sect1 element. RenderAs allows the author to "cheat" in the presentation of hierarchy by specifying that the stylesheet should render a Sect1 as something else: a Sect3, perhaps. Example 5-11 details the removal of RenderAs.

Example 5-11. Removing RenderAs from Sect1


<!ENTITY % sect1.module "IGNORE">                (1)

<!-- load DocBook -->                            (2)
<!ENTITY % DocBookDTD PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
%DocBookDTD;

<!ENTITY % local.sect1.attrib "">                (3)
<!ENTITY % sect1.role.attrib "%role.attrib;">    (4)
<!ELEMENT Sect1 - O (Sect1Info?, (%sect.title.content;), (%nav.class;)*,  (5)
        (((%divcomponent.mix;)+, 
        ((%refentry.class;)* | Sect2* | SimpleSect*))
        | (%refentry.class;)+ | Sect2+ | SimpleSect+), (%nav.class;)*)
        +(%ubiq.mix;)>
<!ATTLIST Sect1                                  (6)
        %label.attrib;
        %status.attrib;
        %common.attrib;
        %sect1.role.attrib;
        %local.sect1.attrib;
>
(1)
Turn off the Sect1 module so that the element and attribute declarations in the DTD will be ignored.
(2)
Include the DocBook DTD.
(3)
By keeping the local attribute declaration, we leave open the possibility of a simple customization layer on top of our customization layer.
(4)
Similarly, we keep the parameterized definition of the Role attribute.
(5)
We're changing the attribute list, not the element, so we've simply copied the Sect1 element declaration from the DocBook DTD.
(6)
Finally, we declare the attribute list, leaving out the RenderAs.

Subsetting the Common Attributes

DocBook defines eleven common attributes; these attributes appear on every element. Depending on how you're processing your documents, removing some of them can both simplify the authoring task and improve processing speed.

Some obvious candidates are:

Effectivity attributes (Arch , OS,...)

If you're not using all of the effectivity attributes in your documents, you can get rid of up to seven attributes in one fell swoop.

Lang

If you're not producing multilingual documents, you can remove Lang.

Remap

The Remap attribute is designed to hold the name of a semantically equivalent construct from a previous markup scheme (for example, a Microsoft Word style template name, if you're converting from Word). If you're authoring from scratch, or not preserving previous constructs with Remap, you can get rid of it.

XrefLabel

If your processing system isn't using XrefLabel, it's a candidate as well.

The customization layer in Example 5-12 reduces the common attributes to just ID and Lang.

Example 5-12. Removing Common Attributes

<!ENTITY % common.attrib
"ID   ID    #IMPLIED
 Lang CDATA #IMPLIED"
>
<!ENTITY % idreq.common.attrib
"ID   ID    #REQUIRED
 Lang CDATA #IMPLIED"
>
<!-- load DocBook -->
<!ENTITY % DocBookDTD PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
%DocBookDTD;

By definition, whatever attributes you define in the common.attrib and idreq.common.attrib parameter entities are the common attributes. In dbpool.mod , these parameter entities are defined in terms of other parameter entities, but there's no way to preserve that structure in your customization layer.