473,608 Members | 2,264 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xs:choice and child elements with minOccurs=0

Is this really a valid schema design?

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefa ult="qualified" >
<xs:element name="root">
<xs:complexType >
<xs:sequence>
<xs:choice>
<xs:element name="e1" minOccurs="0" />
<xs:element name="e2" minOccurs="0"/>
<xs:element name="e3" minOccurs="0"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Doesn't the W3C specs say that xs:choice HAS to return at least one
element? Maybe I'm interpreting the "element" a bit too specific here
- because it even allows me to add maxOccurs="Unli mited" to a child of
a choice and it allows me to repeat the element of that has the
unlimited occurrence on it within the choice.

If the above is valid - which I sorta doubt - is that because it's
specifically NOT forbidden by the w3c specs (http://www.w3.org/TR/2001/
REC-xmlschema-1-20010502)?

My basic problem is that the modifiers on these particles violate the
xs:choice rules. And that seems to be allowed? I've also noticed it
just takes one of the child elements to have a minOccurs="0" to make
the whole choice construct optional. Is there any difference if just
one is "optional" versus all children of a xs:choice being optional?

xerces 2.8 seems to validate the above schema just fine - and run it
with data that (to me) violates the xs:choice. For instance, <root></
rootis valid in the above example. If the choice needs to be
optional why not simply use minOccurs="0" on the xs:choice element
instead of it's children?
Jul 21 '08 #1
0 2832

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1503
by: Don Bate | last post by:
I'm having a problem with the "unique" feature of XML Schema. I'm relatively new to using this feature so it may be that I'm misunderstanding something. Let's assume that I have the following schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="a">
3
510
by: dgaucher | last post by:
Hi, I want to consume a Web Service that returns a choice, but my C++ client always receives the same returned type. On the other hand, when I am using a Java client, it is working fine (of course, the generated proxy is not the same). When I am looking at the C++ generated code, it seems fine, but when I am executing the code, I always get the first choice type.
1
2910
by: Oleg Ogurok | last post by:
Hi all, I have a complex type defined as follows: <xs:complexType name="SchedulingMethodType"> <xs:choice maxOccurs="1"> <xs:element name="Interval" type="xs:duration" /> <xs:element name="DailyAt" type="xs:duration" /> </xs:choice> </xs:complexType>
4
1717
by: Sergey Poberezovskiy | last post by:
Hi, As part of my schema I need to ensure that at least one of two fields have values. I defined my schema as follows: .... <xs:choice> <xs:element ref="el1"/> <xs:element ref="el2"/> <xs:sequence> <xs:element ref="el1"/>
2
5647
by: pawel.pabich | last post by:
Hajo, I know only one way of forcing element to have one or more childes: <xs:element name="saleOrSupplyMethod"> <BR/> <xs:complexType> <xs:choice> <xs:sequence> <xs:element name="generalSale" type="emptyTagType" /> <xs:element name="prescription" type="emptyTagType"/>
7
2455
by: rbarschaw | last post by:
I have the following schema designed: <xs:complexType name="AzzFeature-BoxType" mixed="true"> <xs:choice minOccurs="1" maxOccurs="unbounded"> <xs:element ref="Sub-Head" minOccurs="1" maxOccurs="unbounded"/> <xs:element ref="Title-Text" minOccurs="0" maxOccurs="unbounded"/> <xs:element ref="Text" minOccurs="0" maxOccurs="unbounded"/> <xs:element ref="Link-List" minOccurs="0" maxOccurs="unbounded"/> </xs:choice> <xs:attribute...
2
1664
by: hooomee | last post by:
Given: <xs:choice maxOccurs=5> <xs:element name="Foo" type="bar" /> <xs:element name="Foo1" type="bar" /> <xs:element name="Foo2" type="bar" /> </xs:choice> Is the choice made once and then the choosen element can occur 5 times, or is the choice made once for each occurance?
2
1348
by: cmay | last post by:
I am beginning to wonder if it is not possible to get this working. I am trying to do: <root> <a/> <b/> <c/> </root>
0
2133
by: =?Utf-8?B?RGFtaWFu?= | last post by:
(This is using .net version 2.0.50727 and system.xml 2.0.50727.42) I am getting an error when serializing using classes generated by xsd.exe. The error is of the type "The Type <typewas not expected. Use the XmlInclude or SoapInclude etc" This error is appearing sprodically, with no obvious pattern. When it occurs, it happens every time we run the code, however changes to our code in creating the objects before they are serialized...
0
8063
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8496
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
6816
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6013
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5475
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3962
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2474
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1594
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.