W3C home > Mailing lists > Public > xmlschema-dev@w3.org > August 2010

RE: Difficult logical relationship in complex type

From: McBride, David <dmcbride@quicinc.com>
Date: Tue, 24 Aug 2010 10:08:13 -0700
To: "C. M. Sperberg-McQueen" <cmsmcq@blackmesatech.com>
CC: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Message-ID: <9D1BAF3185DB1C4AB699D189522340EC06256D21F8@NASCLEXMB01.na.qualcomm.com>
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:15:24 GMT