Re: Unique Particle Attribution

Veerappan Sravanan writes:

>> Is there a better tutorial with examples where can I learn more about UPA 
and how to get around? 

I must ask:  "better than what"?  Here's a quick intro:

First, what's a particle.  Consider:

        <sequence>
                <element ref="a"/>
                <element ref="b" maxOccurs="5"/>
                <element ref="c">
        </sequence>

In the above, there are 4 particles[1].  One is the outer sequence, the 
others are the three element references.  The maxOccurs is considered part 
of the particle.   Particles have recursive structure:

        <sequence>
                <element ref="a"/>
                <element ref="b" maxOccurs="5"/>
                <choice>
                        <element ref="x"/>
                        <element ref="y"/>
                </choice>
                <element ref="c">
        </sequence>

Anyway, UPA says that for a given content model to be legal, there can be 
no instance that would have an element matching more than one particle. 
The above are OK per UPA.  The following is not:

        <sequence>
                <element ref="a" minOccurs="0"/>
                <element ref="a" minOccurs="0"/>
        </sequence>

Why illegal?  Well, if I asked you to validate the instance:

        <a/>

you could match it against either of the element references, since both 
are optional and both match <a/>.  So, you cannot "uniquely attribute" the 
element to a particle.  UPA is violated. 

Note:  it's the original <sequence> that is not legal.  We can't really 
ask whether the instance is valid, because there is no legal schema 
against which to try (though clearly, if the schema were allowed, the 
instance would validate...for two reasons!)

UPA is an interesting tradeoff.  It makes validators simpler, because you 
don't have to go down two or more branches of the content model to try and 
see whether your instance matches.  At least as important, it makes things 
easier for tools that do things like binding schemas to Java, relational 
databases, etc.  In the first schema above you can map any valid instance 
to: a variable a, an array of up to 5 b's, and a c.  The sequence that 
violates UPA is somewhat harder to map;  done in the obvious way, the 
element <a/> could map to either of two variables, and crucially, 
different processors might reasonably make different decisions.

I hope this helps.

Noah

[1] http://www.w3.org/TR/2004/PER-xmlschema-1-20040318/#Particle_details

--------------------------------------
Noah Mendelsohn 
IBM Corporation
One Rogers Street
Cambridge, MA 02142
1-617-693-4036
--------------------------------------








Veerappan Saravanan-ESV007 <esv007@motorola.com>
Sent by: xmlschema-dev-request@w3.org
05/03/04 05:00 PM

 
        To:     "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
        cc:     (bcc: Noah Mendelsohn/Cambridge/IBM)
        Subject:        Unique Particle Attribution


Hello, 
Is there a better tutorial with examples where can I learn more about UPA 
and how to get around? 
I have problem in validating my schema due to UPA constraint. 
Thanks 
-Saravanan 

Received on Tuesday, 4 May 2004 22:49:50 UTC