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

Re: Attribute Restriction

From: Eddie Robertsson <eddie@allette.com.au>
Date: Tue, 06 Mar 2001 09:42:32 +1100
Message-ID: <3AA41658.1EA3CCE6@allette.com.au>
To: Curtis Hatter <cmhatter@andersonpublishing.com>
CC: xmlschema-dev@w3.org


Curtis Hatter wrote:

> Hi, Currently working on a schema where I defined a top level
> complexType called caseSegmentDef. This type contains an attribute
> which references an enumeration of values. Here's a trimmed down
> example: <xsd:complexType name="caseSegmentType">    <!--
> complexContent here -->    <xsd:attribute name="type"
> type="caseSegmentType" /></xsd:complexType> <xsd:simpleType
> name="caseSegmentType">    <xsd:restriction base="xsd:string">
> <xsd:enumeration value="concur" />        <xsd:enumeration
> value="dissent" />        <xsd:enumeration value="judge" />
> <xsd:enumeration value="opinion />        <!-- more values here -->
> </xsd:restriction></xsd:simpleType> The actual question I have is
> inside the top level element case i want to reference caseSegmentDef,
> but to make it appear in a certain sequence depending on the attribute
> (caseSegmentType). I read through XML Schema Part 0: Primer and while
> some of the things looked promising none of them seemed to work for
> what i'm trying to do. Here's the top level element (haven't gotten
> very far): <xsd:element name="case">    <xsd:complexType>
> <xsd:sequence>            <!-- here i want to order the caseSegment
> elements based on the attribute -->        </xsd:sequence>
> <xsd:attribute name="newCase" type="xsd:boolean" />    <xsd:attribute
> name="reported" type="xsd:boolean" /><xsd:element>
> Thanks for any help you can provide and sorry if I wasn't very
> clear. Curtis Hatter

Unfortunately you can't do this with XML Schema. My suggestion is that
you define the case element in your schema to allow the elements in any
order and then you use for example Schematron [1] to validate your
instance after XML Schema validation. With Schematron you can check the
order of elements depending on the value of an attribute.

Cheers,
/Eddie

[1] http://www.ascc.net/xml/resource/schematron/
Received on Monday, 5 March 2001 17:43:21 GMT

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