Link to home
Start Free TrialLog in
Avatar of mrichmon
mrichmon

asked on

Allow an element with unlimited content

I want to add an element (settings) to my schema which has the following conditions:

1) Element is optional sub element of root
2) Element can have unrestricted content - including other xml nodes.
3) My document still needs to validate against the schema

Example document:
<root>
   <name>Test</name>
   <description>test</description>
   <conditionList>
        <condition id="1" mode="include">
            <List>
                   <code>1234</code>
                   <code>3452</code>
            </List>
       </condition>
        <condition id="2" mode="include">
            <List>
                   <code>1234</code>
                   <code>3452</code>
            </List>
       </condition>
   </conditionList>
   <settings>
       Optional content goes here - could be just a tring like this.  Or could be xml nodes.
   </settings>
</root>

Current Schema

<xs:element name="root">
     <xs:complexType>
          <xs:sequence>
            <xs:element name="name" type="xs:string" minOccurs="1" maxOccurs="1" />
            <xs:element name="description" type="xs:string" minOccurs="1" maxOccurs="1" />
               <xs:element ref="conditionList" minOccurs="1" maxOccurs="1" />
          </xs:sequence>
     </xs:complexType>
</xs:element>

<xs:element name="conditionList">
     <xs:complexType>
          <xs:sequence>
               <xs:element ref="condition" minOccurs="1" maxOccurs="unbounded" />
          </xs:sequence>
     </xs:complexType>
     <xs:unique name="uniqueConditions">
          <xs:selector xpath="condition"/>
          <xs:field xpath="@id"/>
     </xs:unique>
</xs:element>

<xs:element name="condition">
     <xs:complexType>
          <xs:sequence>
               <xs:element ref="List" minOccurs="1" maxOccurs="1" />
          </xs:sequence>
          <xs:attribute name="id" type="xs:string" use="required" />
     </xs:complexType>
</xs:element>

<xs:element name="List">
     <xs:complexType>
          <xs:sequence>
               <xs:element name="Code" minOccurs="0" maxOccurs="unbounded" />
          </xs:sequence>
          <xs:attribute name="mode" type="ModeOptions" use="required" />
     </xs:complexType>
</xs:element>

etc...
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mrichmon
mrichmon

ASKER

I had to add the minOccurs to the settings

<xs:element name="settings" minOccurs="0" maxOccurs="1">
      <xs:complexType mixed="true">
            <xs:sequence minOccurs="0" maxOccurs="unbounded">
                  <xs:any processContents="skip"/>
            </xs:sequence>
      </xs:complexType>
</xs:element>

But that worked otherwise.

Thanks