Click to See Complete Forum and Search --> : XSD question: using multiple restriction patterns


moschen
10-13-2009, 08:46 AM
Hi,

I would like the content of an element to match one of two possible string patterns. How can I implement this?

Goal:
<myElement>abcd</myElement>
or
<myElement>a1b2</myElement>

Something like:

<xs:simpleType name="myElement_Type">
<xs:restriction base="xs:string">
<xs:choice>
<xs:pattern value="\w\w\w\w"/>
<xs:pattern value="\w\d\w\d"/>
</xs:choice>
</xs:restriction>
</xs:simpleType>


Please note, that the example is a huge simplification. In reality the pattern for each of the choices is a lot more complex.

Looking forward to receivign your comments.

Regards,Mos

moschen
10-13-2009, 09:03 AM
Oh well, sometimes it can be so easy...It seems that this will do the trick:


<xs:simpleType name="myElement_Type">
<xs:restriction base="xs:string">
<xs:pattern value="\w\w\w\w"/>
<xs:pattern value="\w\d\w\d"/>
</xs:restriction>
</xs:simpleType>