xs:sequence and xs:all

J

JBB

Hello,

I'd like to have an xsd schema representing an XMl looking like this:

<Object>
<PARAM_A>456</PARAM_A>
<PARAM_B>45</PARAM_B>
<Value>0</Value>
<Value>10</Value>
<Value>12</Value>
<Value>63</Value>
<Value>41</Value>
<Value>53</Value>
<Value>62</Value>
....
<Value>10</Value>
</Object>

it works whith using xs:sequence

<xs:element name="Object">
<xs:complexType>
<xs:sequence>
<xs:element name="PARAM_A" />
<xs:element name="PARAM_B" />
<xs:element name="Value" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>

but I'd like to be able to switch the order on PARAM_A and PARAM_B
so that
<Object>
<PARAM_B>45</PARAM_B>
<PARAM_A>456</PARAM_A>
<Value>0</Value>
<Value>5</Value>
<Value>10</Value>
</Object>
wotks too.

then I try the xs:all attribute in stead of xs:sequence but it doesn't work.
<xs:element name="Object">
<xs:complexType>
<xs:all>
<xs:element name="PARAM_A" />
<xs:element name="PARAM_B" />
<xs:element name="Value" maxOccurs="unbounded" />
</xs:all>
</xs:complexType>
</xs:element>

Is it possible to do that?

Thanks,
 
P

Pavel Lepin

JBB said:
it works whith using xs:sequence

<xs:element name="Object">
<xs:complexType>
<xs:sequence>
<xs:element name="PARAM_A" />
<xs:element name="PARAM_B" />
<xs:element name="Value"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>

but I'd like to be able to switch the order on PARAM_A and
PARAM_B

<xs:complexType>
<xs:sequence>
<xs:choice>
<xs:sequence>
<xs:element name="PARAM_A"/>
<xs:element name="PARAM_B"/>
</xs:sequence>
<xs:sequence>
<xs:element name="PARAM_B"/>
<xs:element name="PARAM_A"/>
</xs:sequence>
</xs:choice>
<xs:element name="Value" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>

Beware of combinatorial explosion. Down this path lies
madness.
 
J

JBB

Pavel Lepin a écrit :
<xs:complexType>
<xs:sequence>
<xs:choice>
<xs:sequence>
<xs:element name="PARAM_A"/>
<xs:element name="PARAM_B"/>
</xs:sequence>
<xs:sequence>
<xs:element name="PARAM_B"/>
<xs:element name="PARAM_A"/>
</xs:sequence>
</xs:choice>
<xs:element name="Value" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>

Beware of combinatorial explosion. Down this path lies
madness.
Yes, in my real problem I've got 5 PARAM ...

why is that not correct?
<xs:complexType>
<xs:sequence>
<xs:all>
<xs:element name="PARAM_A" type="xs:string"/>
<xs:element name="PARAM_B" type="xs:string"/>
</xs:all>
<xs:element name="Value" maxOccurs="unbounded" type="xs:string"/>
</xs:sequence>
</xs:complexType>

Is there a rule that says: you can use sequence in choice, choice in sequence, but you can't use all in sequence...
Where can i find such rules?link?
Is there an xsd schema on xsd syntax?
 
P

Pavel Lepin

JBB said:
Pavel Lepin a écrit :

Yes, in my real problem I've got 5 PARAM ...

So use a restrictive schema. There are few reasons not to,
and fewer of them are truly valid.
why is that not correct?

Because the spec says so.
Where can i find such rules?link?

Google is your friend.
Is there a rule that says: you can use sequence in choice,
choice in sequence, but you can't use all in sequence...
http://www.w3.org/TR/xmlschema-1/#Model_Groups

Is there an xsd schema on xsd syntax?

http://www.w3.org/TR/xmlschema-1/#normative-schemaSchema
 

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,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top