[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

The same element in one content model with different type

From: Michael Stolp <Michael.Stolp@stud.tu-ilmenau.de>
Date: Thu, 03 Nov 2005 12:44:21 +0100
To: xmlschema-dev@w3.org
Message-ID: <op.sznxj7yst45kwc@faet>
different type of modeling

Hello list.

I have a problem to write a schema for the following:

<Bar id="Bar2" original_id="B5" zIndex="1">
	<Point posRef="pos2" id="Bar2.pt1" role="start"/>
	<Point posRef="pos3" id="Bar2.pt2" role="end"/>
	<Point posRef="pos5" id="Bar2.pt3" role="middle1"/>
</Bar>

A Bar _must_ have start and end Point and _can_ have 0 or more middle
Points.
But how to define this in the schema?
I did try the following:

<xs:element name="Point" type="point_type"/>

<xs:complexType name="point_type">
	<xs:attribute name="id" type="xs:NMTOKEN"/>
	<xs:attribute name="posRef" type="xs:NMTOKEN"/>
	<xs:attribute name="role" type="xs:NMTOKEN"/>
</xs:complexType>

<xs:element name="Bar">
	<xs:complexType>
		<xs:sequence>
			<xs:element name="Point" minOccurs="2" maxOccurs="2">
				<xs:complexType>
					<xs:complexContent>
						<xs:restriction base="point_type">
							<xs:attribute name="id" type="xs:NMTOKEN"/>
							<xs:attribute name="posRef" type="xs:NMTOKEN"/>
							<xs:attribute name="role" use="required">
								<xs:simpleType>
									<xs:restriction base="xs:NMTOKEN">
										<xs:pattern value="(start|end)"/>
									</xs:restriction>
								</xs:simpleType>
							</xs:attribute>
						</xs:restriction>
					</xs:complexContent>
				</xs:complexType>
			</xs:element>
			<xs:element name="Point" minOccurs="0" maxOccurs="unbounded">
				<xs:complexType>
					<xs:complexContent>
						<xs:restriction base="point_type">
							<xs:attribute name="id" type="xs:NMTOKEN"/>
							<xs:attribute name="posRef" type="xs:NMTOKEN"/>
							<xs:attribute name="role" use="required">
								<xs:simpleType>
									<xs:restriction base="xs:NMTOKEN">
										<xs:pattern value="middle(0|[1-9][0-9]*)"/>
									</xs:restriction>
								</xs:simpleType>
							</xs:attribute>
						</xs:restriction>
					</xs:complexContent>
				</xs:complexType>
			</xs:element>
		</xs:sequence>
		<xs:attribute name="id">
			<xs:simpleType>
				<xs:restriction base="xs:NMTOKEN">
					<xs:pattern value="Bar(0|[1-9][0-9]*)"/>
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
		<xs:attribute name="original_id" type="xs:string"/>
		<xs:attribute name="zIndex" type="xs:string"/>
	</xs:complexType>
	<xs:unique name="roleUnique">
		<xs:selector xpath="Point"/>
		<xs:field xpath="@role"/>
	</xs:unique>
</xs:element>

But an error occurs due to the Point element appears in the same content
model more than one time, but "does'nt refer to
a type definition of the highest level".

Please post your suggestions to solve my problem.


MfG Michael Stolp
Received on Thursday, 3 November 2005 11:57:27 GMT

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.