Re: Attribute Restriction

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 UTC