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:54:15 -0700
To: "C. M. Sperberg-McQueen" <cmsmcq@blackmesatech.com>
CC: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Message-ID: <9D1BAF3185DB1C4AB699D189522340EC06256D2217@NASCLEXMB01.na.qualcomm.com>
Ok - I see what you mean.  I misread your regex.

BTW - the regex I suggested is nothing unusual, it's simply a common perl extended regular expression.

The only remaining problem with the XSD form is that it implies order, but I may have to live with that.

Thanks again for your response.

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


On 24 Aug 2010, at 11:08 , McBride, David wrote:

> 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.

How?  The content model (A*, (B|C|D)+) allows zero or more A
elements, followed by one or more B, C, or D elements.
An A element by itself matches the initial token, but
then leaves nothing but the empty string to match
the sub-expression (B|C|D)+.  But the empty string does
not match that construct:  at least one of B, C, or D
is required. (It's a plus sign, meaning one-or-more, not
a star meaning zero-or-more.)

>
> 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

Perhaps we are simply using different notations for regular
expressions:  the expression you write is not legal in
any syntax I know, because the '?' operator does not follow
any regular expression.  (If it matters, the syntax I'm
using is that of DTDs.)

To put the content model into XSD form, you might write
either:

   <sequence>
     <element ref="A" minOccurs="0" maxOccurs="unbounded"/>
     <choice minOccurs="1" maxOccurs="unbounded">
       <element ref="B"/>
       <element ref="C"/>
       <element ref="D"/>
     </choice>
   </sequence>

(which puts the As first), or

   <sequence>
     <choice minOccurs="1" maxOccurs="unbounded">
       <element ref="B"/>
       <element ref="C"/>
       <element ref="D"/>
     </choice>
     <element ref="A" minOccurs="0" maxOccurs="unbounded"/>
   </sequence>

(which puts them last).  Does that help?

-- 
****************************************************************
* 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:54:54 GMT

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