Re: how does one represent an alternating set of elements?

At 2002-02-16 08:14 -0500, Steve Baker wrote:
>Sorry John: the all in my last post should of course have been a
>sequence.  IE
>
><?xml version = "1.0" encoding = "UTF-8"?>
><xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema">
>
>   <xsd:element name='A' type='xsd:anyType'/>
>   <xsd:element name='B' type='xsd:anyType'/>
>
>   <xsd:element name='seqAB'>
>     <xsd:complexType>
>       <xsd:sequence>
>         <xsd:group ref='seqABgroup' minOccurs='0' maxOccurs='unbounded'/>
>         <xsd:element ref='A' minOccurs='0'/>
>       </xsd:sequence>
>     </xsd:complexType>
>   </xsd:element>
>
>   <xsd:group name='seqABgroup'>
>     <xsd:sequence>
>         <xsd:element ref='A'/>
>         <xsd:element ref='B'/>
>     </xsd:sequence>
>   </xsd:group>
>
></xsd:schema>

When I try the above with the sequence (A, B, A) as requested by the 
original poster, the MSV tool complains that it is missing a B.

I think this is because of "Schema Component Constraint: Unique Particle 
Attribution" in that you cannot have "A" selectable both from the group and 
from the subsequent following standalone element.  This is because the 
validator jumps into the group on the detection of the second "A" and is, 
therefore, looking for the mandatory following "B".

The old DTD ambiguity rule, though I could be mistaken and hope that 
someone will correct me if that is the case.

T:\ftemp>type utz3.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<seqAB>
   <A/>
   <B/>
   <A/>
</seqAB>
T:\ftemp>msv baker.xsd utz3.xml
start parsing a grammar.
warnings are found. use -warning switch to see all warnings.
validating utz3.xml
Error at line:6, column:9 of file:/T:/ftemp/utz3.xml
   uncompleted content model. expecting: <B>

the document is NOT valid.

T:\ftemp>

(The warning above has to do with the anyType)

I still haven't worked it out for myself, but I've run out of time today to 
look at it.  But I think the solution proposed is incomplete.

My gut feel is that due to the ambiguity rule that this cannot be done in 
XSD, but I haven't proven that to myself yet.  I hope to look at it later.

I hope this helps.

....................... Ken


--
Upcoming: 3-days XSLT/XPath and/or 2-days XSLFO - Feb 18-22, 2002

G. Ken Holman                mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.         http://www.CraneSoftwrights.com/x/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995)
ISBN 0-13-065196-6                        Definitive XSLT & XPath
ISBN 1-894049-08-X  Practical Transformation Using XSLT and XPath
ISBN 1-894049-07-1               Practical Formatting Using XSLFO
XSL/XML/DSSSL/SGML/OmniMark services, books(electronic, printed),
articles, training(instructor-live,Internet-live,web/CD,licensed)
Next public training:         2002-02-18,21,27,03-04,05,06,11,15,
-              04-08,09,10,11,05-06,07,09,10,06-04,07,10,11,13,14

Received on Saturday, 16 February 2002 11:29:29 UTC