W3C home > Mailing lists > Public > xmlschema-dev@w3.org > October 2001

Re: attribute constraints

From: Eric van der Vlist <vdv@dyomedea.com>
Date: Tue, 09 Oct 2001 13:30:19 +0200
Message-ID: <3BC2DFCB.1020407@dyomedea.com>
To: David Carlisle <davidc@nag.co.uk>
Cc: xmlschema-dev@w3.org
David,

David Carlisle wrote:

> I'm currently trying to recast the OpenMath DTD into W3C Schema (and
> relax ng and schematron) Many of the extra prose restrictions not
> specified in the dtd can be encapsualted (regexp restrictions, mainly) 
> 
> but one is alluding me at present (for W3C Schema)
> The "Float" element has two attributes, taking either a hex or decimal
> value. You have to have exactly one of these present.
> 
> If it were child elements rather than attributes I'd use xsd:choice


Right.


> and if it were simple types rather than attributes I could use a union


Yes.

> but it seems that both of these constructs are not available here.
> Unless I missed something (which is quite possible) so the question:
> 
> 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).

Eric


 
> thanks,
> 
> 
> David
> 


-- 
Rendez-vous  Paris pour une visite guidee de la nebuleuse XML.
                                           http://dyomedea.com/formation/
------------------------------------------------------------------------
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
http://xsltunit.org      http://4xt.org           http://examplotron.org
------------------------------------------------------------------------
Received on Tuesday, 9 October 2001 07:30:04 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:24 GMT