Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

Conditional MinOccurs in an XSD

Question posted by: linushung@yahoo.com (Guest) on June 27th, 2008 07:07 PM
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?
Joseph J. Kesselman's Avatar
Joseph J. Kesselman
Guest
n/a Posts
June 27th, 2008
07:07 PM
#2

Re: Conditional MinOccurs in an XSD
Join Bytes! wrote:
Quote:
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?

Thorsten Stumpf's Avatar
Thorsten Stumpf
Guest
n/a Posts
June 27th, 2008
07:07 PM
#3

Re: Conditional MinOccurs in an XSD
Joseph J. Kesselman schrieb:
Quote:
Join Bytes! wrote:
Quote:
>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?


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

 
Not the answer you were looking for? Post your question . . .
190,079 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors