W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2005

RE: Need help with Unique Particle Attribution Rule

From: Michael Kay <mike@saxonica.com>
Date: Fri, 7 Jan 2005 15:03:33 -0000
To: "'Tom Moog'" <tmoog@sarvega.com>
Cc: <xmlschema-dev@w3.org>
Message-Id: <E1CmveL-0002wD-00@ukmail1.eechost.net>
What the spec says is:
 
 A content model must be formed such that during
<http://www.w3.org/TR/xmlschema-1/#key-vn> .validation. of an element
information item sequence, the particle component contained directly,
indirectly or  <http://www.w3.org/TR/xmlschema-1/#key-impl-cont>
.implicitly. therein with which to attempt to
<http://www.w3.org/TR/xmlschema-1/#key-vn> .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. 
 
That says you've got to be able to determine the particle uniquely (the
strict UPA), not just the element declaration. But it also says why: so that
you can determine how to validate each item in the sequence. The "loose" UPA
rule satisfies the "why" but not the "how". 
 
A conformant processor will of course implement the strict rule, even though
it serves no useful purpose.
 
I normally take conformance pretty seriously, this is one of the things
people like about Saxon. But there are always a few difficult cases on the
edges where the last ounce of conformance costs too much or is simply too
hard. In this case, I think I know how to extend the Thompson/Tobin
algorithm to implement the stricter rule for UPA, but closely associated
with that is the stricter rules in the spec for type subsumption, where the
spec just seems to be so buggy that I want to wait until it's fixed. I might
take a different view if the general level of conformance of schema
processors were higher.
 
Michael Kay



  _____  

From: Tom Moog [mailto:tmoog@sarvega.com] 
Sent: 07 January 2005 14:26
To: Michael Kay
Cc: xmlschema-dev@w3.org
Subject: Re: Need help with Unique Particle Attribution Rule




So which do you consider the appropriate check ?  The "loose" UPA or
the "strict" UPA ?  

 <xs:choice> 
    <xs:element ref="tns:A" />
    <xs:element ref="tns:A" />
</xs:choice>




Michael Kay wrote:


This is actually one of those examples where the Thompson/Tobin algorithm
used by XSV and Saxon doesn't give a UPA error, because the two particles
for element "error" both refer to the same element declaration. The
Thompson/Tobin algorithm lets a content model through if the element
declaration for each element can be determined unambiguously, even if the
particle can't.
 
I think the following content model is equivalent, and passes the stricter
version of the UPA test:
 
<xsd:element name="systemProvider">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:sequence minOccurs="0" maxOccurs="unbounded">
                <xsd:element ref="admin"/>
                <xsd:element ref="error" minOccurs="0"/>
            </xsd:sequence>
            <xsd:sequence minOccurs="0">
               <xsd:element ref="deviceTypeInfo" maxOccurs="unbounded"/>
               <xsd:element ref="error" minOccurs="0"/>
            </xsd:sequence>
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>
 
Michael Kay
http://www.saxonica.com/


  _____  

From: xmlschema-dev-request@w3.org [mailto:xmlschema-dev-request@w3.org] On
Behalf Of Vinotha Suntharalingam
Sent: 07 January 2005 05:33
To: xmlschema-dev@w3.org
Subject: Need help with Unique Particle Attribution Rule



Hi,

I'm trying to parse an xsd with Xerces and I'm running into UPA rule
violation problems. Attached below is relevant sections in the xsd where the
problem is encountered. I'm finding it difficult to define the
'systemProvider' element in such way it doesn't violate this rule. Could
someone please assist me on how it can be done? 

(I tried to follow the name, first-name, last-name example to fix the
problem, but this particular element definition seems to be a bit more
complicated. Any help would be much appreciated.)

<xsd:element name="systemProvider">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:sequence minOccurs="0" maxOccurs="unbounded">
                <xsd:element ref="admin"/>
                <xsd:element ref="error" minOccurs="0"/>
            </xsd:sequence>
            <xsd:element ref="deviceTypeInfo" minOccurs="0"
maxOccurs="unbounded"/>
            <xsd:element ref="error" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>

<!-- The following elements are referenced in the above piece of code -->

<xsd:element name="deviceTypeInfo">
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element ref="deviceType"/>
    <xsd:element ref="category"/>
    <xsd:element ref="maxPorts"/>
    <xsd:element ref="protocolSupported" maxOccurs="unbounded"/>
   </xsd:sequence>
  </xsd:complexType>
 </xsd:element>
 
<xsd:element name="protocolSupported">
  <xsd:complexType>
   <xsd:simpleContent>
    <xsd:extension base="xsd:string">
     <xsd:attribute name="default" use="optional">
      <xsd:simpleType>
       <xsd:restriction base="xsd:string">
        <xsd:enumeration value="true"/>
       </xsd:restriction>
      </xsd:simpleType>
     </xsd:attribute>
    </xsd:extension>
   </xsd:simpleContent>
  </xsd:complexType>
 </xsd:element>
 
<xsd:element name="error">
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element ref="id"/>
    <xsd:element ref="summary"/>
    <xsd:element ref="detail" minOccurs="0"/>
   </xsd:sequence>
  </xsd:complexType>
 </xsd:element>

<xsd:element name="admin">
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element ref="userId"/>
    <xsd:element ref="password" minOccurs="0"/>
    <xsd:element ref="userName" minOccurs="0"/>
   </xsd:sequence>
  </xsd:complexType>
 </xsd:element>


<xsd:element name="summary" type="xsd:string"/>

<xsd:element name="id" type="xsd:string"/>

<xsd:element name="detail" type="xsd:string"/>

<xsd:element name="userId" type="xsd:string"/>

<xsd:element name="password" type="xsd:string"/>

<xsd:element name="userName" type="xsd:string"/>

<xsd:element name="deviceType" type="xsd:string"/>

<xsd:element name="category" type="xsd:string"/>

<xsd:element name="maxPorts" type="xsd:string"/>


Thank you in advance.
Vino 
Received on Friday, 7 January 2005 15:03:39 GMT

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