Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » choice child under all
choice child under all [message #998376] Wed, 09 January 2013 22:04 Go to next message
Steve Prescott is currently offline Steve PrescottFriend
Messages: 1
Registered: January 2013
Junior Member
I have only done a couple XSD files, but here are two things I can't figure out.

I need an item that doesn't care what order its items are int <xs:all>. But it also has a <xs:choice> grouping directly under it. A <xs:choice> is allowed as a child of <xs:sequence> but not for <xs:all>

(See attachment but try making the sequence an all)

Second, how do you make an attribute optional?

(See attachment but I want the role to be optional)

The XML for this already exists, and I am trying to make an XSD for it.

<sample name="e1">
<label>first item</label>
<int-option value="5" />
</sample>

<sample name="e2" role="2">
<float-option value="2.5" />
<label>second item</label>
</sample>
Re: choice child under all [message #998518 is a reply to message #998376] Thu, 10 January 2013 06:48 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Steve,

Comments below.

On 10/01/2013 4:27 AM, Steve Prescott wrote:
> I have only done a couple XSD files, but here are two things I can't
> figure out.
>
> I need an item that doesn't care what order its items are int
> <xs:all>. But it also has a <xs:choice> grouping directly under it. A
> <xs:choice> is allowed as a child of <xs:sequence> but not for <xs:all>
Yes, <all> is quite restrictive in what's allowed; essentially just a
set of elements... What you describe doesn't sound expressible in XML
Schema 1.0.
>
> (See attachment but try making the sequence an all)
I don't see attachments...
>
> Second, how do you make an attribute optional?
use="optional"
>
> (See attachment but I want the role to be optional)
>
> The XML for this already exists, and I am trying to make an XSD for it.
Note that EMF will not validate the order of elements in a sequence, it
will accept then in any order (much like it does for attributes where
there is no order constraint). It will then serialize them in the order
in which they're defined in the model (corresponding to the sequence
order if it's schema derived).
>
> <sample name="e1">
> <label>first item</label>
> <int-option value="5" />
> </sample>
>
> <sample name="e2" role="2">
> <float-option value="2.5" />
> <label>second item</label>
> </sample>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:The 'no duplicates' constraint is violated
Next Topic:How to find XML structures directly from the XSD
Goto Forum:
  


Current Time: Tue Apr 23 13:22:27 GMT 2024

Powered by FUDForum. Page generated in 0.03823 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top