RE: Difficult logical relationship in complex type

Thanks for your response.

Order does not matter.

I think you've misunderstood the constraints (or I haven't expressed them clearly).  Specifically, I'm trying to prohibit the case where element 'A' is the only content.  The rexex you proposed would allow this case to occur.

I think the regex would be more like the following:

(?([BCD]+)A*)

i.e.,

IF one or more instanced of B, C, or D,
THEN zero or more instances of A

DJM

-----Original Message-----
From: C. M. Sperberg-McQueen [mailto:cmsmcq@blackmesatech.com] 
Sent: Tuesday, August 24, 2010 6:30 AM
To: McBride, David
Cc: C. M. Sperberg-McQueen; xmlschema-dev@w3.org
Subject: Re: Difficult logical relationship in complex type


On 23 Aug 2010, at 10:39 , McBride, David wrote:

> I'm having difficulties defining a logical relationship within a  
> complex type.  The complex type contains 4 sub-elements.  Let's call  
> them A, B, C, D.  The logical relationship is this:
>
> 1.       One, or more of elements B, C, or D are required.
> 2.       There may be zero or more instances of element A.
> 3.       Element A may never be the only element.  In other words,  
> there may only be an instance of A, if there is also at least one  
> instance of B, C, or D.
>
> If I was just dealing with B, C, and D, I could handle that.   
> However, adding the requirements for A has thrown me.

If one of B, C, and D is required, then your constraint 3 seems
always to be satisfied.  Element A will never be the only element,
since there will always be a B, C, or D.  Or have I misunderstood
the constraints?

If you do not care about the order, then the simplest thing
might be the XSD equivalent of the regular expression

   (A*, (B | C | D)+)

If I've misunderstood the constraints, then this content model
may not do the job -- explaining why not would be a good step
towards clarifying the requirements.

HTH

-- 
****************************************************************
* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com
* http://cmsmcq.com/mib
* http://balisage.net
****************************************************************

Received on Tuesday, 24 August 2010 17:08:47 UTC