sequence - no, all - no, choice - no

M

melograno

Sorry if this question or a similar one was already submitted into
this newsgroup, but my investigations on this topic were not
successfull.

An external application that is not under my control generates an XML
documents with 5 fields. 3 of them (f1, f3, f5) are mandatory, 2 of
them (f2 and f4) are optionals. The field order is unpredictable. A
couple of examples follow.

<?xml version="1.0"?>
<thedocument>
<f1>11</f1>
<f3>13</f3>
<f5>14</f5>
<f2>15</f2>
</thedocument>

<?xml version="1.0"?>
<thedocument>
<f4>11</f4>
<f1>12</f1>
<f5>13</f5>
<f3>14</f3>
</thedocument>

I'm trying to define an XSD for this legacy document, but
- sequence does not work, since the order is not fixed
- all does not work, since some of elements are optional
- sequence of choice does not work

Do you have any suggestion for solving this problem?

Thanks

pierre
 
P

Priscilla Walmsley

Hi Pierre,

"all" should work for what you want. You can make the elements in an
all group optional, as in:

<xs:all>
<xs:element name="f1"/>
<xs:element name="f2" minOccurs="0"/>
<xs:element name="f3"/>
<xs:element name="f4" minOccurs="0"/>
<xs:element name="f5"/>
</xs:all>

Hope that helps,
Priscilla
 
M

melograno

Thanks a lot, Priscilla, it worked. Part of my understanding on "all" was wrong.
pierre
 
A

Arthur

Hi, I have a similar dilema, however the elements f1,f2,f3... as well as
appearing in any order, can also appear any number of times. e.g.

<?xml version="1.0"?>
<thedocument>
<f1>11</f1>
<f1>12</f1>
<f1>16</f1>
<f3>13</f3>
<f5>14</f5>
<f2>15</f2>
<f3>21</f3>
<f3>22</f3>
</thedocument>

I understand 'all' can only occur 0 or 1 times, this is no good.
sequence is no good because of the order. What else can I do?

Thanks a lot, Priscilla, it worked. Part of my understanding on "all" was wrong.
pierre
 

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

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,841
Latest member
WilmerBelg

Latest Threads

Top