Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > sequence inside a choice

Reply
Thread Tools

sequence inside a choice

 
 
Ryan
Guest
Posts: n/a
 
      06-19-2008
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?
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      06-19-2008
Ryan wrote:
> 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.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Ryan
Guest
Posts: n/a
 
      06-19-2008
On Jun 19, 11:28 am, Martin Honnen <mahotr...@yahoo.de> wrote:
> Ryan wrote:
> > 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 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.
>
> > 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.
>
> --
>
> Martin Honnen
> http://JavaScript.FAQTs.com/


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.
 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      06-20-2008
Ryan wrote:

> 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 xmlnss="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.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
Ryan
Guest
Posts: n/a
 
      06-20-2008
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

On Jun 20, 4:57 am, Martin Honnen <mahotr...@yahoo.de> wrote:
> Ryan wrote:
> > 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 xmlnss="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.
>
> --
>
> Martin Honnen
> http://JavaScript.FAQTs.com/


 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      06-20-2008
Ryan wrote:
> 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.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
c++ as choice for long term application choice. miles.jg C++ 16 11-14-2007 03:43 PM
sequence - no, all - no, choice - no melograno XML 3 04-29-2005 01:23 PM
<sequence> <choice> and <all> with Axis zorro Java 0 07-31-2004 09:49 AM
Can Choice components respond to keyboard input like HTML Choice components? Mickey Segal Java 0 02-02-2004 10:59 PM
Choice of DHCP-server? Is the "IOS-one" a good choice? Fred Cisco 1 12-11-2003 06:25 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57