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

Schema: defining occurences in choices?

  • To: <xml-dev@l...>
  • Subject: Schema: defining occurences in choices?
  • From: "Emmerich, Martin" <Martin.Emmerich@o...>
  • Date: Wed, 18 Dec 2002 13:59:47 +0100
  • Thread-index: AcKmlVe0Jcg/BT/MQq2SQemS/5qZYA==
  • Thread-topic: Schema: defining occurences in choices?

define occurences
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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-2013 All Rights Reserved.