Re: Datatype constraints in DCDs

Murray Maloney (murray@muzmo.com)
Fri, 9 Oct 1998 16:38:36 -0400


At 02:09 PM 10/9/98 -0400, Dean Roddey wrote:
>
>><AttributeDef Name="Colour" Datatype="string">
>> <ValidIf rule="Equals" value="Red"/>
>> <ValidIf rule="Equals" value="Green"/>
>> <ValidIf rule="Equals" value="Blue"/>
>></AttributeDef>
>>
>
>It looks like the consensus is definitely that the more wordy XML encoding of
>the constraint information is preferable. And I'm not too stressed out about
>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 proposed
>DCD enumeration mechanism, but I think the above scheme would get way wordy
>just to (for instance) check that something was one of the months of the year,
>one of the possible XML encodings, one of the countries of the world, etc...
>I'd definitely like to have some way to get the possible values all into some
>slightly less versbose chunk. Even if human convenience is not an issue,
>bandwidth still remains a concern, right?
>
>I'd almost, in the name of reuse, argue for an EnumDecl that defined such enums
>for reuse by name, though someone might easily poke holes in that argument
>because I've not thought it out.

In SOX, we have one form of datatype declaration that specifies
an enumeration of values. So, for example:

<datatype name="color">
<enumeration datatype="NMTOKEN">
<option>red</option>
<option>green</option>
<option>blue</option>
</enumeration>
</datatype>

Now you can write:

<attdef name="colour" datatype="color" />

and the "colour" attribute is constrained to be one
of the three values enumerated in the "color" datatype.
And you can use the "color" datatype on any attribute
or any element whose content model is string.

<elementtype name="colour">
<model>
<string datatype="color" />
</model>
</elementtype>

Truth is, in this case one would probably want something
more like this:

<interface name="rgb">
<attdef name="red" datatype="RGB"><required/></attdef>
<attdef name="green" datatype="RGB"><required/></attdef>
<attdef name="blue" datatype="RGB"><required/></attdef>
</interface>

<datatype name="RGB">
<scalar minvalue="0" maxvalue="65535" decimals="0" />
</datatype>

The interface can be attached to any element as a collection
of attribute definitions.

<elementype name="colour">
<empty/>
<implements name="rgb"/>
</elementtype>

The value of each attribute must be a number (scalar) in the
range 0-65535 (0000-FFFF). So, you would write an instance thus:

<colour red="255" green="255" blue="255"/>

Regards,

Murray

Murray Maloney, Esq. Phone: (905) 509-9120
Muzmo Communication Inc. Fax: (905) 509-8637
671 Cowan Circle Email: murray@muzmo.com
Pickering, Ontario Email: murray@yuri.org
Canada, L1W 3K6