sequence inside a choice

R

Ryan

Is it legal to have something like:
<xs:complexType name="transaction">
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:element name="account_login"
type="login_data" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="create_id"
type="tbl_iv" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="org_create"
type="org" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:choice>
</xs:complexType>

Notice how there is a sequence inside a choice and nothing else.

Also, what do the minOccurs/maxOccurs modifiers do on the choice and
sequence grouping?
 
M

Martin Honnen

Ryan said:
Is it legal to have something like:
<xs:complexType name="transaction">
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:element name="account_login"
type="login_data" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="create_id"
type="tbl_iv" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="org_create"
type="org" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:choice>
</xs:complexType>

Notice how there is a sequence inside a choice and nothing else.

I think that is allowed but you can check yourself with a schema
validator like http://www.w3.org/2001/03/webdata/xsv
It is a different question whether it makes much sense and can not be
simplified, it seems to me that the above can be simplified to simply
put the sequence directly into the complexType.
Also, what do the minOccurs/maxOccurs modifiers do on the choice and
sequence grouping?

Saying that the whole choice or sequence can occur as often as the
maxOccurs specifies so unbounded or exactly once as the minOccurs="1"
specifies.
 
R

Ryan

I think that is allowed but you can check yourself with a schema
validator likehttp://www.w3.org/2001/03/webdata/xsv
It is a different question whether it makes much sense and can not be
simplified, it seems to me that the above can be simplified to simply
put the sequence directly into the complexType.


Saying that the whole choice or sequence can occur as often as the
maxOccurs specifies so unbounded or exactly once as the minOccurs="1"
specifies.

So, according to the original xsd, would this be valid:

<transaction>
<account_login>data</account_login>
<org_create>data</org_create>
<org_create>data</org_create>
<create_id>data</create_id>
<org_create>data</org_create>
</transaction>

Stipulating that data is valid data inside the pairs.
 
M

Martin Honnen

Ryan said:
So, according to the original xsd, would this be valid:

<transaction>

The original xsd you posted only defined a complexType named
transaction, not an element of that name.
If you define

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="transaction" type="transaction"/>
<xs:complexType name="transaction">
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:element name="account_login"
type="xs:string" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="create_id"
type="xs:string" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="org_create"
type="xs:string" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:choice>
</xs:complexType>
</xs:schema>

then I think your sample is valid.
 
R

Ryan

From your comments it sounds to me that if you have
<xs:choice minOccurs="1" maxOccurs="unbounded"><xs:sequence
minOccurs="1" maxOccurs="unbounded">
<!-- elements -->
</xs:sequence></xs:choice>

That the outer choice is ignored. Is this accurate?

-Ryan
 
M

Martin Honnen

Ryan said:
From your comments it sounds to me that if you have
<xs:choice minOccurs="1" maxOccurs="unbounded"><xs:sequence
minOccurs="1" maxOccurs="unbounded">
<!-- elements -->
</xs:sequence></xs:choice>

That the outer choice is ignored. Is this accurate?

I don't think it is ignored by the schema parser or the validator. But
it looks to me as if you could simplify the structure if you want to.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,187
Members
46,730
Latest member
AudryNolan

Latest Threads

Top