W3C home > Mailing lists > Public > xmlschema-dev@w3.org > August 2003

The same element in two choice segments

From: Xuejun Li (SH/RDC) <xuejun.li@ericsson.com>
Date: Tue, 26 Aug 2003 12:30:46 +0800
Message-ID: <55CF389EF371D511B67C00508BADDC2F02892A91@ecnshnt514.itc.ericsson.se>
To: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>

Hi schema experts,
I want to define a schema like the following:
<xs:schema targetNamespace="http://schemas.ericsson.com/snf/cpm1.0/" xmlns:cai3g="http://schemas.ericsson.com/cai3g1.0/2003/05/30/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cpm="http://schemas.ericsson.com/snf/cpm1.0/" elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xs:element name="OfferedService" >
		<xs:complexType>
			<xs:choice>
				<xs:sequence>
					<xs:element name="cdsOSId" type="xs:unsignedLong"/>
					<xs:element name="cdsOSName" type="xs:string" minOccurs="0"/>
					<xs:element name="provisioningData" minOccurs="0">
						<xs:complexType>
							<xs:sequence>
								<xs:any namespace="##any" processContents="lax" maxOccurs="unbounded"/>
							</xs:sequence>
						</xs:complexType>
					</xs:element>
				</xs:sequence>
				<xs:sequence>
					<xs:element name="cdsOSId" type="xs:unsignedLong"/>
					<xs:element name="cdsUId" type="xs:unsignedLong"/>
					<xs:element name="provisioningData" minOccurs="0">
						<xs:complexType>
							<xs:sequence>
								<xs:any namespace="##any" processContents="lax" maxOccurs="unbounded"/>
							</xs:sequence>
						</xs:complexType>
					</xs:element>
				</xs:sequence>
			</xs:choice>
			<xs:attribute name="cdsOSId" type="xs:unsignedLong" use="required"/>
		</xs:complexType>
	</xs:element>
</xs:schema>

What I did was, there is an element "cdsOSId" defined in two "xs:sequence" inside a "xs:choice". The same with another element "provisioningData". Then I used the xerces parser to parse the following document:

<OfferedService cdsOSId="123" xmlns="http://schemas.ericsson.com/snf/cpm1.0/" xmlns:cai3g="http://schemas.ericsson.com/cai3g1.0/2003/05/30/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.ericsson.com/snf/cpm1.0/ ./OfferedService.xsd">
	<cdsOSId>123</cdsOSId>
	<cdsOSName>cdsOSName</cdsOSName>
	<provisioningData><a>provisioningDataXML</a></provisioningData>
</OfferedService>

And I got two errors. One is "Duplicate element decl in the same scope: provisioningData", the error is reported on the schema. The other is " 'cdsOSId' and 'cdsOSId' violate the Unique Particle Attribution rule", the error is reported on the XML document. I wonder is it allowed to define the same element in two choice segments? Why provisioningData is refused during the schema parsing while cdsOSId is found wrong on the XML document?

Thanks
Li Xuejun
Received on Thursday, 28 August 2003 03:22:12 GMT

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