Re: Issue: duplicate attributes

From
Norman Walsh <>
Date
2001-04-25T20:09:38+00:00
ID
Thread
Re: Issue: duplicate attributes
/ James Clark <> was heard to say:
| It's common to have a collection of common optional attributes:
| 
| <define name="common.atts">
|   <optional>
|     <attribute name="id">
|       <data type="xsd:ID"/>
|     </attribute>
|   </optional>
|   ...
| </define>
| 
| Sometimes, you want one of the common atts that is normally optional to
| be required on one particular element.  With TREX at the moment, you can
| simply do this:
| 
| <element name="def">
|   <ref name="common.atts"/>
|   <attribute name="id">
|     <data type="xsd:ID"/>
|   </attribute>
|   ...
| </element>
| 
| If the rule was that a pattern must not permit duplicate attributes,
| then the above approach would not be possible.

I don't think that's a great hardship. The ID case is just about the only
example of this case (where you have a collection of common atts but one
is sometimes required) and it's fairly easy to work around.

 <define name="common.atts">...</define>
 <define name="common.atts.idreq">...</define>

And then <ref> the one you want. You could even factor out the "core"
common attributes, if you wanted.

I think allowing multiple attributes is potentially confusing for
users, and not hard to work around, so I'm inclined to forbid it.

                                        Be seeing you,
                                          norm

-- 
    | The human race consists of the
XML Standards Engineer       | dangerously insane and such as are
Technology Development Group | not.--Mark Twain
Sun Microsystems, Inc.       |