<!-- ==================================================== XML Construct Domain Module Author: your name here Copyright (c) 2010 copyright holder license to use or not use or whatever ==================================================== --> <!ENTITY % xmlelem "xmlelem" > <!-- LONG NAME: XML Element --> <!ENTITY % xmlelem.content " (#PCDATA)* " > <!ENTITY % xmlelem.attributes ' %univ-atts; keyref CDATA #IMPLIED outputclass CDATA #IMPLIED ' > <!ELEMENT xmlelem %xmlelem.content; > <!ATTLIST xmlelem %xmlelem.attributes; >
Note that the content model for each element type must be at least as restrictive as the content model of the specialization base (in this case, <keyword>
, although we haven't declared that yet). Looking at the DITA language reference (or the declaration in commonElements.mod), we see that the content model for <keyword>
includes both #PCDATA as well as all other phrase-level elements. Since the XML component mentions don't need or want any subelements, we've reduced the content model down to just #PCDATA (just text), which is consistent with the content model of the <keyword>
element.
Note also that the content model and attribute lists are defined as parameter entities that are then used in the actual ELEMENT and ATTLIST declarations. This is a change from DITA 1.1 to DITA 1.2 made to enable overriding of individual element's content models and attribute lists through constraint modules. )In this case the only content model more restrictive than "(#PCDATA)*" is "EMPTY".)
Mistake to watch out for: Attributes with quoted default values quoted with the same quote character as the parameter entity text.
In parameter entity declarations you can use either single quotes or double quotes (" or ') to quote the entity value. Because attributes can have literal default values, you have to make sure the quotes used for the attribute value are different from the quotes used for the parameter entity text itself. This is most common with specializations of <data>
where you want to set the @name
attribute to a specific value (typically the tagname of the specialization).
For attribute declarations it's usually easiest to use single quotes so that attributes that specify literal default values can use double quotes, which is how most American's will declare them (and thus what you are most likely to copy from the base DITA declarations). Of course, if you're British you can swap that around.
<!ENTITY % myDataElem.attributes ' name CDATA "myDataElem" value CDATA #REQUIRED %univ-atts; ' >