473,395 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Schema element contain text or elements, but not both.

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:

<list>
<listMember>
<ident>1</ident>
<name>Name1</name>
</listMember>
<listMember>
<ident>2</ident>
<name>Name2</name>
</listMember>
</list>

<list>
<listMember>1</listMember>
<listMember>2</listMember>
</list>

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:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="exampleSchema"
targetNamespace="exampleSchema"
elementFormDefault="qualified">

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

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

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

</xs:schema>

Do any of you know how I could accomplish this?

--
Alan Johnson
Jul 24 '07 #1
0 1641

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: C. M. Sperberg-McQueen | last post by:
wooks (wookiz@hotmail.com) wrote: > <?xml version='1.0'?> > <userlogin xmlns="urn:faster:userlogin" > xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> > <login>mick</login> > ...
6
by: Pieter | last post by:
I've read a lot of posts on "why relax ng is so very good" and on "why w3c xml schema should be the only schema language". I'm, however, still not clear on why I should prefer one over the other. ...
1
by: ruthless | last post by:
hello. i've got a question can i in XML Schema define tag that works as lists knows from e.g. C,C++ - recurrent tags? i'm talking about e.g. genealogical tree every level of this tree is...
3
by: Razvan | last post by:
Hi After playing with XML Spy I saw that in DTDs the element of type "any" could contain text and any element that was declared in the DTD. In XML Schema an element of type anyType can...
0
by: Steve Jorgensen | last post by:
In a schema I've been working on recently, a convention I evolved was to use a consistent naming pattern such that, for instance, a Resident could appear in a ResidentSet, and could be referred to...
5
by: Damiano ALBANI | last post by:
Hello, I'd like to write a single XML Schema for both these documents : <Items> <Item xml:id="id1"> <Name>ABC</Name> ... </Item> <Item xml:id="id2">
5
by: Grant Robertson | last post by:
I am only just learning about schema basics. I am trying to understand some fundamental principles about what can be specified within a schema. If I define an enumerated list of values for an...
2
by: Fred Chateau | last post by:
Is there a problem with the HTML 4.01 schema in Visual Studio 2005? When I set the target schema for validation to HTML 4.01, I receive closing tag errors. Example: Validation (HTML 4.01):...
6
by: Grant Robertson | last post by:
If I use the 'any' element in my schema to allow elements from another schema to be used in instance documents based on my schema, is there a way to force that the contents of that element must be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.