Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Schema element contain text or elements, but not both.

Thread Tools

Schema element contain text or elements, but not both.

Alan Johnson
Posts: n/a
I am trying to specify that an element may contain simple content (an
integer), or complex content (a sequence of two other elements), but not
both. The listMember element in the following XML fragment demonstrates
what I'm trying to accomplish:



I cannot, however, figure out any way to create such a restriction. The
following (invalid) schema sort of shows what it is I would like, but of
course it is invalid because listMember is redeclared.

<?xml version="1.0"?>


<xs:element name="list" type="List"/>

<xs:complexType name="List">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="listMember" type="ListMember"/>
<xs:element name="listMember" type="xs:integer"/>

<xs:complexType name="ListMember">
<xs:element name="indent" type="xs:integer"/>
<xs:element name="name" type="xs:string"/>


Do any of you know how I could accomplish this?

Alan Johnson
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
RCR: String#contain? and Array#contain? Roger Pack Ruby 3 09-28-2010 04:13 PM
Does string contain A, and if so, does a section of string contain B Jason Carlton Javascript 11 12-08-2009 06:07 PM
how to Update/insert an xml element's text----> (<element>text</element>) HANM XML 2 01-29-2008 03:31 PM
Including element from one schema namespace in another schema namespace XML 1 07-20-2006 06:48 AM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM