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

attribute constraints

From: David Carlisle <davidc@nag.co.uk>
Date: Fri, 5 Oct 2001 16:27:27 +0100
Message-Id: <200110051527.QAA30123@penguin.nag.co.uk>
To: xmlschema-dev@w3.org

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
and if it were simple types rather than attributes I could use a union
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?



<!-- should derive from double not string, and if possible require exactly one of the hex and dec attributes -->
<xs:element name="OMF">
    <xs:attribute name="dec" type="omDecFloat" use="optional" />
    <xs:attribute name="hex" type="omHexFloat" use="optional" />

<xs:simpleType name="omDecFloat" >
    <xs:restriction base="xs:string">
    <xs:pattern value="(-?)([0-9]+)?(\.[0-9]+)?(e([+-]?)[0-9]+)?" />

<xs:simpleType name="omHexFloat">
    <xs:restriction base="xs:string">
    <xs:pattern value="[0-9A-F]+" />

This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.
Received on Friday, 5 October 2001 11:28:25 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:14:54 UTC