Here is my XML:
I am trying to create a schema that will restrict the elements allowed in the [tt]<section/>[/tt] parent to [tt]<heading/>[/tt], [tt]<paragraph/>[/tt], and [tt]<list/>[/tt] but not necessarily in this order.
- I looked at [tt]<xs:all/>[/tt] but it requires that all elements appear atleast once, but [tt]<section/>[/tt] could be empty since all children elements are optional.
- I looked at [tt]<xs:choice/>[/tt] but it expects each child element to be a present once or not at all, but the children in [tt]<section/>[/tt] are multiply occurring.
- I looked at [tt]<xs:sequence/>[/tt] but it requires that the children elements be in a specific order, but the children in [tt]<section/>[/tt] can be in any order.
The closest option is [tt]<xs:choice/>[/tt] were it not for the restriction of only allowing non-multiply occurring children elements. Are there attributes to modify the behavior of any of these? I attempted to use the [tt]minOccurs[/tt] and [tt]maxOccurs[/tt] attributes but they did not help.
Code:
<document>
<title>Document Title</title>
<content>
<section>
<heading>Some Heading</heading>
<paragraph>Some paragraph.</paragraph>
<list>
<item>Some list item.</item>
</list>
</section>
<section>
<heading>First Heading</heading>
<heading>Second Heading</heading>
<paragraph>First paragraph.</paragraph>
<paragraph>Second paragraph.</paragraph>
<list>
<item>First list.</item>
</list>
<list>
<item>Second list.</item>
</list>
</section>
<section>
<heading>First Heading</heading>
<paragraph>First paragraph.</paragraph>
<list>
<item>First list.</item>
</list>
<heading>Second Heading</heading>
<paragraph>Second paragraph.</paragraph>
<list>
<item>Second list.</item>
</list>
</section>
</content>
</document>
I am trying to create a schema that will restrict the elements allowed in the [tt]<section/>[/tt] parent to [tt]<heading/>[/tt], [tt]<paragraph/>[/tt], and [tt]<list/>[/tt] but not necessarily in this order.
- I looked at [tt]<xs:all/>[/tt] but it requires that all elements appear atleast once, but [tt]<section/>[/tt] could be empty since all children elements are optional.
- I looked at [tt]<xs:choice/>[/tt] but it expects each child element to be a present once or not at all, but the children in [tt]<section/>[/tt] are multiply occurring.
- I looked at [tt]<xs:sequence/>[/tt] but it requires that the children elements be in a specific order, but the children in [tt]<section/>[/tt] can be in any order.
The closest option is [tt]<xs:choice/>[/tt] were it not for the restriction of only allowing non-multiply occurring children elements. Are there attributes to modify the behavior of any of these? I attempted to use the [tt]minOccurs[/tt] and [tt]maxOccurs[/tt] attributes but they did not help.