The purpose of life is not to win. The purpose of life is to grow and to share. When you come to look back on all that you have done in life, you will get more satisfaction from the pleasure you have brought into other people's lives than you will from the times that you outdid and defeated them.

'either or' using XML Schema

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>

No comments: