Page 1 of 1

How can I do this in a Schema?

Posted: Fri May 26, 2006 6:50 pm
by Douha
Hi all,

I have a question about how to create a schema that will validate this format.

I have a file that used to have a format like this.

element type 1
element type 2
element type 2
element type 2
element type 3
element type 3
element type 3
element type 3

It has been changed to this format.


element type 1
element type 2
element type 3
element type 3
element type 2
element type 3
element type 3
element type 2
element type 3

I have a schema that works for the former format. I haven't been able to figure out how to get one to validate the new format.

Could someone please point me in a direction to help figure it out?

Thanks much,

Doug

Posted: Fri May 26, 2006 8:49 pm
by george
Hi Doug,

I'm not sure what you want the schema model to cover, if you want for instance element type 1 followed by any of element type 2 or 3 aany numner of times then you can encode that as

Code: Select all


<xs:sequence>
<xs:element name="element1" type="type1">
<xs:choice maxOccurs="unbounded">
<xs:element name="element2" type="type2">
<xs:element name="element3" type="type3">
</xs:choice>
</xs:sequence>
If that is not what you want then please provide more details.

Best Regards,
George

Posted: Fri May 26, 2006 9:14 pm
by Douha
Thanks George,

What I am trying to accomplish is this.

For every element 1 there will be at least 1 element 2 that will immediatly follow element 1.
For every element 2 there will be at least 1 element 3 that will immediately follow element 2.

So the following would be what I am trying to model.

E1
E2
E3
E3
E3
E2
E3
E2
E3
E3

The following would be incorrect and cause an error.

E1
E3
E2

E1
E2
E2
E3
E3

or

E2
E3
E1

Does this make sense?

Thanks,

Doug

Posted: Fri May 26, 2006 9:56 pm
by george
Hi Doug,

That seems something like:

Code: Select all


      <xs:sequence>
<xs:element name="E1"/>
<xs:sequence maxOccurs="unbounded">
<xs:element name="E2"/>
<xs:sequence maxOccurs="unbounded">
<xs:element name="E3"/>
</xs:sequence>
</xs:sequence>
</xs:sequence>
Best Regards,
George