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

Re: Difficult logical relationship in complex type

From: C. M. Sperberg-McQueen <cmsmcq@blackmesatech.com>
Date: Tue, 24 Aug 2010 07:30:29 -0600
Cc: "C. M. Sperberg-McQueen" <cmsmcq@blackmesatech.com>, "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Message-Id: <8F69DAE3-D27F-4008-A52E-988BAB41A6E7@blackmesatech.com>
To: "McBride, David" <dmcbride@quicinc.com>

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 13:28:43 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:57 UTC