[Home] [By Thread] [By Date] [Recent Entries]

  • From: Jeni Tennison <mail@j...>
  • To: James Williams - Sun East Coast IR Development <James.P.Williams@S...>
  • Date: Fri, 20 Jul 2001 16:48:27 +0100

Hi James,

> Can anybody tell me how to represent the following content group in
> XML Schema?
>
> (a|b|c)*

The | separators mean its a choice, so you use an xs:choice element:

  <xs:choice>
    ...
  </xs:choice>

The * means that it can occur between 0 and any number of times - that
gets translated into minOccurs="0" maxOccurs="unbounded".

  <xs:choice minOccurs="0" maxOccurs="unbounded">
    ...
  </xs:choice>

The a, b and c are references to elements that you've declared
globally, so you use xs:element elements with ref attributes giving
the names of the elements:

  <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element ref="a" />
    <xs:element ref="b" />
    <xs:element ref="c" />
  </xs:choice>

Depending on the pattern you're using in your schema, you might
declare the elements locally within the group rather than referring to
globally declared elements.
  
I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member