Datatype constraints in DCDs

Olivo Miotto olivo at
Mon Oct 12 04:41:40 BST 1998

Dean Roddey writes:

>It looks like the consensus is definitely that the more wordy XML encoding
>the constraint information is preferable. And I'm not too stressed out
>that, since I won't be the one reading them anyway :-) But I would
question the
>above scheme for enumerations. There was some desire to replace the
>DCD enumeration mechanism, but I think the above scheme would get way
>just to (for instance) check that something was one of the months of the
>one of the possible XML encodings, one of the countries of the world,
>I'd definitely like to have some way to get the possible values all into
>slightly less versbose chunk. Even if human convenience is not an issue,
>bandwidth still remains a concern, right?

Yes, of course. And that's the reason why I hypothesized that, with
"Equals" being the default, we would have:

<AttributeDef Name="Colour" Datatype="string">
    <ValidIf value="Red"/>
    <ValidIf value="Green"/>
    <ValidIf value="Blue"/>

which is 25% cheaper. Also, nothing stops us from allowing

<AttributeDef Name="Colour" Datatype="string">
    <ValidIf rule="OneOf" value="Red Green Blue"/>

which requires additional parsing, but with very limited complexity. In
fact, the main issue with your proposed scheme was the need to parse a
separate syntax, but something like space-separated name lists are of
course easy to process.

The main problem I see with space-separated lists is that they do not allow
for whitespace within strings. This is ok (though not great) for
attributes, but not for elements.

>I'd almost, in the name of reuse, argue for an EnumDecl that defined such
>for reuse by name, though someone might easily poke holes in that argument
>because I've not thought it out.

Actually that sounds like a very good idea, except I would do it for
datatypes, not just enum values, eg:

<DatatypeDef Name="Tristate" XmlDatatype="string">
    <ValidIf rule="OneOf" value="On Off DontCare"/>
<AttributeDef Name="Status" Datatype="Tristate"/>

and also

<DatatypeDef Name="RGBValue" XmlDatatype="string">
    <ValidIf rule="GE" value="0"><ValidIf rule="LE" value="255"/></ValidIf>

<AttributeDef Name="Red" Datatype="RGBValue"/>
<AttributeDef Name="Green" Datatype="RGBValue"/>
<AttributeDef Name="Blue" Datatype="RGBValue"/>

Hmm... just to throw ideas around- could one even have composite datatypes?
Such as

<DatatypeDef Name="Colour">
    <AttributeDef Name="Red" Datatype="RGBValue"/>
    <AttributeDef Name="Green" Datatype="RGBValue"/>
    <AttributeDef Name="Blue" Datatype="RGBValue"/>

And then, your ElementDef may look something like

<ElementDef Name="Background" Datatype="Colour"/>

and a valid XML tag would be

<Background Red="0" Green="255" Blue="127"/>

This is something like the AttributeGroup Concept, but somewhat more
abstract in its definition.

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at
Archived as:
To (un)subscribe, mailto:majordomo at the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at

More information about the Xml-dev mailing list