I have a use case where I need to validate pipe-separated string in XSD attribute value.
Example: XML Attribute
<Fruits Names="Apple|Grapes|Banana">
I want to write a XSD pattern where Fruits attribute Name allows following and other valid combination from above 3 values.
Apple
Banana
Grapes
Apple|Banana
Grapes|Banana
Apple|Grapes
Banana|Grapes
Grapes|apple
Apple|Grapes|Banana
I currently wrote something like
<xs:simpleType name="Fruits">
<xs:restriction base="xs:string">
<xs:pattern value="Apple*|Grapes*|Banana" ></xs:pattern>
</xs:restriction>
</xs:simpleType>
I want to use this in C#, so I guess I can only use XSD 1.0.
I'd recommend that you give up the
|
separator and use space () instead.
I.e:
Then, the following XSD will meet your requirements: