simple xsd question...

F

foolproofplan

I am new to making schema for xml and am not exactly sure on a certain
restriction i need to make within an xsd. Take for example, a
complexType Car. I am trying to restrict certain elements from being
used when others are present. When I have an element leatherType
within Car, I do not want to allow the element fabricType to be used
in the same Car anymore.

If my explanation is a little confusion, here is the xml sructured I
want to restrict from happening:
<Car name=mine>
<leatherType>nice<leatherType/>
<fabricType>okay<fabricType/>
</Car>

(note: these are not the only two elements allowed for Car, many other
different elements may occur in there also but I only want to restrict
fabric because leather is there.)

Thanks for the help guys!
 
F

foolproofplan

After thinking about this for a little while, I figured I should
explain what this solution is really going to be used for. The xml
elements I am trying to restrict are 3 against 1. For example, if one
certain element is a child of the Car "mine" , there are three other
elements that cannot be.

At first I thought that choice could be made between each element and
the restrictive one. But then, what if I have three choices for that
same restrictive element?

Is there some way a choice could be made between groups?
 
J

Joseph Kesselman

Is there some way a choice could be made between groups?

I believe the simplest answer is to make the choice between one element
and another which contains one or more of the group you're trying to
restrict. Or to make the choice at a higher level, so you have different
content models for the two groups.

Or, impose the restriction in the application rather than in the schema.
Schemas aren't intended to handle every possible content interaction,
and should be considered a first-cut description of a meaningful
document, NOT necessarily a complete guarantee thereof.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top