Conditional MinOccurs in an XSD

L

linushung

With the following XML

<ProductTypeID>1</ProductTypeID>
<A/>
<B/>
<C/>
<D/>

I'd like to achieve the following scenario in my xsd:

if ProductTypeID = 1 then the XML should be

<ProductTypeID>1</ProductTypeID>
<A/>
<B/>

if ProductTypeID = 2 then the XML should be

<ProductTypeID>2</ProductTypeID>
<C/>
<D/>

Is this possilbe to be enforced in an XSD?
 
J

Joseph J. Kesselman

Is this possilbe to be enforced in an XSD?

Schemas can not express this kind of cross-dependency constraint. Check
it in your application code?
 
T

Thorsten Stumpf

Joseph said:
Schemas can not express this kind of cross-dependency constraint. Check
it in your application code?

I'd suggest Relax NG. Perhaps even Schematron. Most applications and
parsers are capable to use Relax NG. Schematron is a bit different in
concept but if you've got many cross constraints it's quite helpfull IMHO.

Salut,

Thorsten
 

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,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top