(unknown charset) Re: how does one represent an alternating set of elements?

Ken and Steve;

On Sat, 16 Feb 2002, G. Ken Holman wrote:

> At 2002-02-16 11:29 -0500, I wrote:
> >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".
> 
> I tried a RELAX-NG version of your suggestion, Steve, and it works just 
> fine because there is no such unambiguous particle rule in RELAX-NG.  I've 
> copied it below.
> 
> So your proposal is sound, except for the ambiguity constraint ... the 
> wording in XML Schema Part 1 reads:
> 
>    A content model must be formed such that during ·validation· of an
>    element information item sequence, the particle contained directly,
>    indirectly or ·implicitly· therein with which to attempt to
>    ·validate· each item in the sequence in turn can be uniquely
>    determined without examining the content or attributes of that item,
>    and without any information about the items in the remainder of the
>    sequence.
> 
> I still can't figure out a way around this ambiguity to meet the original 
> poster's needs.

this is exactly the hair pulling part of the problem! :-)

This alternating sequence is a key paradigm in MPEG7's method of
describing some 'stuff'.

The original implementer probably used XMLSpy to develop the schema.  
i was one of the first people who tried to use the MPEG7 schema with
xerces-j.

xerces-j 2 found a problem with Uniform Particle Attribution in the
current version of the MPEG7 schema. The author trimmed it down to a
minimal example and shared it with me in the hope that i might be able to
fix it.

I looked at it and said 'that shouldnt be too hard'. That was a week ago.
:-)

so, i tried your (steve's) suggested implementation and i get the same
error that the original had:

bash-2.05$ java dom.ASBuilder -f -a Alt3.xsd -i Alt3.xml
[Error] :-1:-1: cos-nonambig: ("":A) and ("":A){0-1} (or elements from
their substitution group) violate "Unique Particle Attribution".

this supports Ken's assertion.

(The schema and xml are called Alt3 because this is the third independent
suggestion that i have tried )

ironically, another individual suggested a mixed mode XMLSchema/RELAX-NG
description ( i wonder if he knows Ken? :-) )

that would probably cause a lot of discontent at this time. :-)

it's astounding that this is working out to be this hard!

but that's software.....

again, i cant say enough about my level of appreciation for the time you
guys have put into looking at this.

if an answer is found for this, it would be a great FAQ entry somewhere...

> ..................... Ken
> 
> T:\ftemp>type utz1.xml
> <seqAB>
>    <A/>
> </seqAB>
> T:\ftemp>type utz2.xml
> <seqAB>
>    <A/>
>    <B/>
> </seqAB>
> T:\ftemp>type utz3.xml
> <seqAB>
>    <A/>
>    <B/>
>    <A/>
> </seqAB>
> T:\ftemp>type utz4.xml
> <seqAB>
>    <A/>
>    <B/>
>    <A/>
>    <B/>
> </seqAB>
> T:\ftemp>type utz5.xml
> <seqAB>
>    <B/>
>    <A/>
>    <B/>
> </seqAB>
> T:\ftemp>type utz6.xml
> <seqAB>
>    <A/>
>    <B/>
>    <B/>
>    <A/>
>    <B/>
> </seqAB>
> T:\ftemp>type holman.rnx
> start = element seqAB
>   {
>    (
>     element A { empty },
>     element B { empty }
>    )*,
>    element A { empty }?
>   }
> 
> T:\ftemp>rnx holman.rnx utz1.xml utz2.xml utz3.xml utz4.xml utz5.xml utz6.xml
> start parsing a grammar.
> validating utz1.xml
> the document is valid.
> --------------------------------------
> validating utz2.xml
> the document is valid.
> --------------------------------------
> validating utz3.xml
> the document is valid.
> --------------------------------------
> validating utz4.xml
> the document is valid.
> --------------------------------------
> validating utz5.xml
> Error at line:2, column:7 of file:/T:/ftemp/utz5.xml
>    tag name "B" is not allowed. Possible tag names are: <A>
> 
> the document is NOT valid.
> --------------------------------------
> validating utz6.xml
> Error at line:4, column:7 of file:/T:/ftemp/utz6.xml
>    tag name "B" is not allowed. Possible tag names are: <A>
> 
> the document is NOT valid.
> 
> T:\ftemp>
> 
> 
> --
> 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 17:06:01 UTC