Re: attribute constraints

> > Is it possible to change the following so that
> > <OMF/> and <OMF dec="2" hex="F"/>
> > do not  validate?
>
> No, it is impossible with "pure" W3C XML Schema and the best you can do
> is to define that those 2 attributes are not required (exactly like you
> would to in a DTD).
>
> This is one of the features allowed by RELAX NG (which treats attributes
> and elements in a more consistent way than XML Schema) and Schematron
> (which can test *almost* anything) that is not supported by W3C XML Schema.
>
> This is also a case where it makes sense to add Schematron rules to a
> W3C XML Schema using the xs:annotation/xs:appinfo extension mechanism
> provided by XML Schema (this is supported by a couple of tools).

There is also the third approach where you can use type substitution and
explicitly choose the correct datatype with the xsi:type attribute in the
instance document. In this case though I'm not sure it's worth the extra
trouble of creating two different types and then having to add the xsi:type
attribute...

Cheers,
/Eddie

Received on Tuesday, 9 October 2001 20:20:52 UTC