RE: Difficult logical relationship in complex type

"McBride, David" <[email protected]>
Newsgroups gmane.text.xml.schema.devel
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:[email protected]] 
Sent: Tuesday, August 24, 2010 6:30 AM
To: McBride, David
Cc: C. M. Sperberg-McQueen; [email protected]
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
****************************************************************
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.