Connecting Tech Pros Worldwide Forums | Help | Site Map

XML Schema: mixin any order and any quantity

Newbie
 
Join Date: Oct 2006
Posts: 1
#1: Oct 4 '06
Hi,

I'm trying to build a XML Schema for XMLs like that:

Expand|Select|Wrap|Line Numbers
  1. <book>
  2.    <title>...</title>
  3.    <chapter>...</chapter>
  4.    <chapter>...</chapter>
  5.    <chapter>...</chapter>
  6.    <author>...</autor>
  7. </book>
or like that

Expand|Select|Wrap|Line Numbers
  1. <book>
  2.    <title>...</title>
  3.    <author>...</autor>
  4.    <chapter>...</chapter>
  5.    <chapter>...</chapter>
  6.    <chapter>...</chapter>
  7. </book>
I mean, inside <book> there can be only one <title> (minOccurs=0, maxOccurs=1) and one <author> (minOccurs=0, maxOccurs=1) and many <chapter> (minOccurs=0, maxOccurs=unbounded), but combining them in any order (although all the <chapter>s could be together).

My first thoughts were using <xs:all>, but the problem is that <xs:all> only allows elements with maxOccurs=1, so it doesn't fit with <chapter> (that has maxOccurs=unboonded).

Anybody knows a solution or workaround? I'm getting crazy reviewing the XML Schema reference for some solution, but I'm not finding anything :). Please, any help is very welcome!

Regards,

Fermín

PD. Of course I could do something like:

Expand|Select|Wrap|Line Numbers
  1. <book>
  2.    <title>...</title>
  3.    <author>...</autor>
  4.    <chapters>
  5.       <chapter>...</chapter>
  6.       <chapter>...</chapter>
  7.       <chapter>...</chapter>
  8.    </chapters>
  9. </book>
and define <book> as a <xs:all> of <title>, <author> and <chapters>, but I would like to solve the problem without adding the <chapters> "grouping" element.

Reply