ENGLISH | JAPANESE |
$Id: step10.sdoc 1.8 2000/11/01 13:46:38 murata Exp $
In this section, we consider embedding of tag
elements in elementRule
elements.
In STEPs 0 thru 9, attributes and tag names are separated from hedge models. Attributes and tag names are described by tag
and attPool
elements, while hedge models are described by elementRule
and hedgeRule
elements. An elementRule
references to a tag
via a role, and the tag
may in turn reference to attPool
elements.
When an elementRule
and a tag
is so closely related, it may be convenient to merge them into a single element rather than separating them.
As an example of elementRule
-tag
separation, we duplicate an example in STEP 8 below.
<!-- Case 1: type="integer" --> <tag name="val" role="val-integer"> <attribute name="type" type="NMTOKEN" required="true"> <enumeration value="integer"/> </attribute> </tag> <elementRule role="val-integer" label="val" type="integer"/> <!-- Case 2: type="string" --> <tag name="val" role="val-string"> <attribute name="type" type="NMTOKEN" required="true"> <enumeration value="string"/> </attribute> </tag> <elementRule role="val-string" label="val" type="string"/>
Suppose that roles val-integer
and val-string
are referenced from these two elementRule
elements only. Rather than introducing two names val-integer
and val-string
for referencing, authors might want to directly embed tag
elements within elementRule
elements.
<!-- Case 1: type="integer" --> <elementRule label="val" type="integer"> <tag> <attribute name="type" type="NMTOKEN" required="true"> <enumeration value="integer"/> </attribute> </tag> </elementRule> <!-- Case 2: type="string" --> <elementRule label="val" type="string"> <tag> <attribute name="type" type="NMTOKEN" required="true"> <enumeration value="string"/> </attribute> </tag> </elementRule>
An advantage of this style is that roles do not need names. Before this rewrite, we needed names which are different from the tag names or labels. Omission of these names enhance readability.
Some people find it attractive to describe attributes and hedge models together. For example, points with the x-coordinate and y-coordinate can be represented in two alternative manners. The first example uses attributes, while the second uses elements. Their differences are minor and can be easily rewritten from each other.
<elementRule label="point" type="emptyString"> <tag> <attribute name="x" type="integer"/> <attribute name="y" type="integer"/> </tag> </elementRule>
<elementRule label="point"> <tag/> <sequence> <element name="x" type="integer"/> <element name="y" type="integer"/> </sequence> </elementRule>
An elementRule
containing a tag
may not have the role
attribute. The label
attribute is mandatory, instead.
An embedded tag
may not have the role
attribute. The name
attribute is permitted, but it is not present in this example.
tag
elementsAn embedded tag
element is moved from the elementRule
and placed as a sibling element. We show how the first example in this STEP is handled.
<elementRule label="val" type="integer"> <tag> <attribute name="type" type="NMTOKEN" required="true"> <enumeration value="integer"/> </attribute> </tag> </elementRule>
First, we generate a role that does not conflict with any other role. In this example, we generate role val$1
.
Next, we move the embedded tag
element from the elementRule
and place as a sibling element. We then add the role
attribute and specify the generated role as the attribute value.
Only when this tag
element does not have the name
attribute, we introduce this attribute. As the attribute value, we use the value of the label
attribute of the elementRule
element. In this example, we specify "val"
as the value of the name
attribute.
Finally, we add the role
attribute to the elementRule
and specify the role generated above.
<elementRule label="val" type="integer" role="val$1"> </elementRule> <tag name="val" role="val$1"> <attribute name="type" type="NMTOKEN" required="true"> <enumeration value="integer"/> </attribute> </tag>
To describe elements and attributes together, embedded tag
elements provides concise and comprehensible description. Enjoy and RELAX!