?
Solved

Allow an element with unlimited content

Posted on 2006-04-11
3
Medium Priority
?
292 Views
Last Modified: 2013-11-19
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
Comment
Question by:mrichmon
  • 2
3 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 1000 total points
ID: 16428375
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
 
LVL 35

Author Comment

by:mrichmon
ID: 16429733
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
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 16429842
welcome
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question