473,395 Members | 1,473 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.

How to restrict elements by reference to another element using XML schema

Hi,
I need to restrict the allowed included elements dependent upon the value of
another element. How do I do this using XML Schema?

For example, the XML

<Petshop>
<Kind>Dog</Kind>
<Breeds>
<Breed>Poodle</Breed>
<Breed>Alsatian</Breed>
</Breeds>
</Petshop>

is valid because the element <Breeds> is allowed when the element <Kind> has
a value of 'Dog'. However

<Petshop>
<Kind>Fish</Kind>
<Breeds>
<Breed>Poodle</Breed>
<Breed>Alsatian</Breed>
</Breeds>
</Petshop>

is not valid because the element <Breeds> is not allowed when the element
<Kind> has a value of 'Fish'.

How do I describe this using XML schema? Also, how would I say the element
<Breeds> is mandated when the value is 'Dog', and the element <WaterType> is
mandated when the value is 'Fish'?

Many thanks,
Piers
Jul 20 '05 #1
0 1385

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> > ...
0
by: Meredith | last post by:
Question: Can the XML <any> element restrict what datatype it stores? I am trying to write an extensible schema that has an element containing unbounded <any> elements of boolean type. Is it...
1
by: Don Adams | last post by:
I would like to have the following XML: <phone type="work">555-123-1234</phone> <phone type="home">555-123-4321</phone> Is it possible to write a schema to restrict the contents of the type...
3
by: Pablo Gomes Ludermir | last post by:
Hello, I have the following case that I am trying to put in XML Schema. I have the classes HelpItem, Document and Message that work as follows: One HelpItem contains several Document and...
6
by: trexim | last post by:
Hi, I am trying to create a Web Reference for CSTA using the URL http://www.ecma-international.org/standards/ecma-348/csta-wsdl/csta-wsdl-all-operations.wsdl Visual .Net complains that: "...
1
by: Maksim | last post by:
Trying to find out a way how to restrict value of the element by name of an element, it might be not even possible, but anyhow. Let's consider following snippet: <xs:element name="tag1"...
0
by: XSD-optimist | last post by:
I am trying to generate the classes for an XSD schema using the Microsoft XSD Object Code Generator (XSDObjGen). I am having a schema that contains the definition of the following: 1. a complex...
1
by: da_pander | last post by:
Hi, Can anyone tell me if it is possible to create a XSD schema document that will only allow certain elements to be displayed as available within the instance document depending on say a...
4
by: BorisBoshond | last post by:
Hi all, Hope someone is able and willing to help me with following problem. I received a xsd file from another company, our company i supposed to return xml based on that xsd. Problem is that I...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.