Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Allow Text In XSD Definition 1

Status
Not open for further replies.

BoulderBum

Programmer
Jul 11, 2002
2,179
US
I have a schema that contains a subset of XML elements:

Code:
  <xs:element name="root">
    <xs:complexType>
      <xs:group ref="elements" minOccurs="0" maxOccurs="unbounded"/>
    </xs:complexType>
  </xs:element>

Everything works great except for one detail: I don't know the notation for allowing text to be inside the root element with all the other elements.

In other words, while this works:

Code:
<root>
  <b>bolded</b>
  <br/>
  <p>
   <ul>
    <li>
      <b>test</b>
    </li>
   </ul>
  </p>
</root>

This currently does not:

Code:
<root>
  Here is text that makes the schema validation fail.

  <b>bolded</b>
  <br/>
  <p>
   <ul>
    <li>
      <b>test</b>
    </li>
   </ul>
  </p>
</root>

How exactly do I define "root" so that it allows text along with the other elements?
 
Try change this.
[tt]
<xs:element name="root">
<xs:complexType [blue]mixed="true"[/blue]>
<xs:group ref="elements" minOccurs="0" maxOccurs="unbounded"/>
</xs:complexType>
</xs:element>
[/tt]
 
I haven't tried that yet, but looking up what the fixed attribute does (I'm very new to hand-coding XSD) that looks perfect! Thanks!
 
As a follow-up is it possible to define a list of legal elments (no root elements) and also designate that text nodes are legal?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top