By embedding choice in sequence, 'either or' type can be enforced in XML schema. In the below example, somethingType would allow either foo or bar. Since 'choice' is inside the sequence which can max occur twice, either or is enforced. So foo/bar can appear once or twice or they can both co-exist.
<xsd:complexType name="somethingType">
<xsd:sequence minOccurs="1" maxOccurs="2">
<xsd:choice>
<xsd:element name="foo" type="xsd:string"/>
<xsd:element name="bar" type="xsd:string"/>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
<?xml version="1.0" encoding="UTF-8"?>
<tns:EitherOr xmlns:tns="http://www.example.org/EitherOr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/EitherOr eitheror.xsd ">
<foo>foo</foo>
<bar>bar</bar>
</tns:EitherOr>
The Motorcycle Diaries
-
The journey of a man which changed his life forever! What more one could
write about this movie with the preceding line aptly describing the movie?
I fe...
No comments:
Post a Comment