S
Stephan Mann
Hi,
I want to give this one more try before I accept that this can't be
done. I did ask for this two weeks ago in this group[1] but did not
receive any answers, so I'm trying to rephrase my question.
I'm trying to remove the (inherent?) specification of the order of
occurrence from my XML schema. The goal is to allow elements to occur in
any order but still be able to set elements required or optional.
A "solution" I have found countless times in multiple variations while
searching for a way to do this is the use of a <choice>:
<xsd:element name="Root">
<xsd:complexType>
<xsd:group ref="group" maxOccurs="unbounded" />
</xsd:complexType>
</xsd:element>
<xsd:group name="group">
<xsd:choice>
<xsd:element name="Element1" minOccurs="0" maxOccurs="1" />
<xsd:element name="Element2" minOccurs="0" />
</xsd:choice>
</xsd:group>
On a first glance, this does what I want: Elements can be provided in
any order. But the side effects are severe! The attributes minOccurs and
maxOccurs are no longer in effect and - what's worse - even empty Root
tags are now valid.
This clearly makes any validation meaningless so it is no solution at
all. It seems to me that I'm ignorant of some basic concept or just
plain stupid, but in either case I would like to know/understand.
So again, could somebody provide me with some kind of hint regarding
this point? I settle for a link to the part of the XMLSchema spec where
it states, that this is not intended to be possible or for some other
group or mailing list I could trouble with this problem.
tia, stephan
[1]
http://groups.google.com/group/comp.text.xml/browse_thread/thread/dab30367a6ee5f9c#
I want to give this one more try before I accept that this can't be
done. I did ask for this two weeks ago in this group[1] but did not
receive any answers, so I'm trying to rephrase my question.
I'm trying to remove the (inherent?) specification of the order of
occurrence from my XML schema. The goal is to allow elements to occur in
any order but still be able to set elements required or optional.
A "solution" I have found countless times in multiple variations while
searching for a way to do this is the use of a <choice>:
<xsd:element name="Root">
<xsd:complexType>
<xsd:group ref="group" maxOccurs="unbounded" />
</xsd:complexType>
</xsd:element>
<xsd:group name="group">
<xsd:choice>
<xsd:element name="Element1" minOccurs="0" maxOccurs="1" />
<xsd:element name="Element2" minOccurs="0" />
</xsd:choice>
</xsd:group>
On a first glance, this does what I want: Elements can be provided in
any order. But the side effects are severe! The attributes minOccurs and
maxOccurs are no longer in effect and - what's worse - even empty Root
tags are now valid.
This clearly makes any validation meaningless so it is no solution at
all. It seems to me that I'm ignorant of some basic concept or just
plain stupid, but in either case I would like to know/understand.
So again, could somebody provide me with some kind of hint regarding
this point? I settle for a link to the part of the XMLSchema spec where
it states, that this is not intended to be possible or for some other
group or mailing list I could trouble with this problem.
tia, stephan
[1]
http://groups.google.com/group/comp.text.xml/browse_thread/thread/dab30367a6ee5f9c#