Altova Mailing List Archives>Archive Index >xmlschema-dev Archive Home >Recent entries >Thread Prev - Re: Merging schemas >Thread Next - [ANN] Xerces-C++ 2.8.0 released constraints on attributes as a validation check (ish)To: <xmlschema-dev@--.---> Date: 8/30/2007 12:10:00 PM
I'm a bit of an XSD newbie...
I have a set of xml files structured thus:
<root>
<row typ="g01">
<r>content1a</r>
<r>content1b</r>
</row>
<row typ="g02">
<r>content2a</r>
<r>content2b</r>
</row>
<row typ="g03">
<r>content3a</r>
<r>content3b</r>
</row>
<row type="g05">
<r>content4a</r>
<r>content4b</r>
<r>content4c</r>
</row>
</root>
I need to verify that each file contains one and one only row element of
typ="g04".
Row elements may occur in any order and more than once.
Here is the *broad form* of xsd that I am using:
<xs:element name="root">
<xs:complexType>
<xs:choice>
<xs:sequence>
<xs:element name="row" type="rowOther" />
<xs:element name="row" type="rowg05" minOccurs="1"/>
</xs:sequence>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:complexType name="rowg05" abstract="true">
<xs:sequence>
<xs:element name="r"/>
</xs:sequence>
<xs:attribute name="typ" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="g05"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType name="rowOther" abstract="true">
<xs:sequence>
<xs:element name="r"/>
</xs:sequence>
<xs:attribute name="typ" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="g01"/>
<xs:enumeration value="g02"/>
<xs:enumeration value="g03"/>
<xs:enumeration value="g04"/>
<!--excluded <xs:enumeration value="g05"/>-->
<xs:enumeration value="g06"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
I have tried various combinations of <complexType>,
abstract/non-abstract elements and such to get a result, but keep
getting hung up on declaring a row element with different types.
Am I making a daft mistake?
Is this actually possible with XSD?
Should I be using a different toolset?
Thanks
Andy Harris
UK Biobank
The information contained in this e-mail is confidential and solely for the=
intended addressee(s). Unauthorised reproduction, disclosure,=
modification, and/or distribution of this e-mail may be unlawful. If you=
have received this e-mail in error, please notify the sender immediately=
and delete it from your system. The views expressed in this message do=
not necessarily reflect those of UK Biobank.
UK Biobank Limited is registered as a charity in England and Wales (number=
1101332) and is a company limited by guarantee (incorporated in England=
and Wales, registered number 4978912). It's registered office is at 1-2=
Spectrum Way, Adswood, Stockport, Cheshire SK3 0SA. | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
