OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Schema: defining occurences in choices?

[ Lists Home | Date Index | Thread Index ]
  • To: <xml-dev@lists.xml.org>
  • Subject: Schema: defining occurences in choices?
  • From: "Emmerich, Martin" <Martin.Emmerich@oew.de>
  • Date: Wed, 18 Dec 2002 13:59:47 +0100
  • Thread-index: AcKmlVe0Jcg/BT/MQq2SQemS/5qZYA==
  • Thread-topic: Schema: defining occurences in choices?

Hello *,

I have a question on defining occurences in choices within schema.

I need something like 

<?xml version="1.0" encoding="UTF-8"?>
<test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:noNamespaceSchemaLocation="testschema.xsd">
	<testentry>
		<name>value1</name>
		<content>at least once - 1st occurence</content>
	</testentry>
	<testentry>
		<name>value1</name>
		<content>at least once - 2nd occurence</content>
	</testentry>
	<testentry>
		<name>value2</name>
		<content>any</content>
	</testentry>
</test>

where testentry should be a base type which gets then restricted. The name element must have certain fixed values. Depending on some of these values I want to define occurences/restrictions (minOccurs, maxOccurs, etc.) for the whole element. How can I do that?

I tried 

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xs:element name="test">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="testentry" maxOccurs="unbounded">
					<xs:complexType>
						<xs:complexContent>
							<xs:restriction base="testType">
								<xs:choice>
									<xs:sequence>
										<xs:annotation>
											<xs:documentation>must occur at least once</xs:documentation>
										</xs:annotation>
										<xs:element name="name" type="xs:string" fixed="value1"/>
										<xs:element name="content" type="xs:string"/>
									</xs:sequence>
									<xs:sequence>
										<xs:annotation>
											<xs:documentation>any ocurrence</xs:documentation>
										</xs:annotation>
										<xs:element name="name" type="xs:string" fixed="value2"/>
										<xs:element name="content" type="xs:string"/>
									</xs:sequence>
								</xs:choice>
							</xs:restriction>
						</xs:complexContent>
					</xs:complexType>
				</xs:element>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:complexType name="testType">
		<xs:sequence>
			<xs:element name="name" type="xs:string"/>
			<xs:element name="content" type="xs:string"/>
		</xs:sequence>
	</xs:complexType>
</xs:schema>

But then I don't get these occurences/restrictions. Is it possible at all and when, how?

Best regards,
..............................
Martin Emmerich
Leitung IT

Oestreicher + Wagner 
Medientechnik GmbH
Frankenthaler Straße 20
D-81539 München

Fon   +49 (0)89-68961 171 
Fax   +49 (0)89-68961 271




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS