• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 295
  • Last Modified:

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...
0
mrichmon
Asked:
mrichmon
  • 2
1 Solution
 
Geert BormansInformation ArchitectCommented:
Hi mrichmon,

it could be this

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

settings can contain mixed content
and a number of "any" elements
the content of these "any" elements will not be processed

hope this helps

Cheers!
0
 
mrichmonAuthor Commented:
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
0
 
Geert BormansInformation ArchitectCommented:
welcome
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now