[Bug 1232] [XPath] schema-element() and nillable

http://www.w3.org/Bugs/Public/show_bug.cgi?id=1232





------- Additional Comments From mike@saxonica.com  2005-04-19 15:36 -------
This seems to raise some issues that require discussion.

>On second thought, however, I think your original comment may be correct. If
the element in question were 
>validated against a local declaration that is nillable, then its type
annotation would correspond to that 
>local declaration, not to the global declaration named in the Schema Element Test.

But the types might be the same. 
 
I'm struggling with this. Consider the scenario: 
 
<xs:element name="e" type="xs:integer" nillable="false">
 
<xs:element name="f">
  <xs:complexType>
    <xs:sequence>
       <xs:element name="e" type="xs:integer" nillable="yes"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>
 
let $f := validate strict { <f><e xsi:nil="true"/></f> } 
return ($f/e instance of schema-element(e)) 
 
The validation succeeds because the local e is nillable. The question I'm having
difficulty with now is, what is the type annotation on the e element? As far as
I can see from a careful reading of Schema Part 1 and the Data Model spec, e's
type annotation is xs:integer. Perverse, but that's what it seems to be. 
 
In applying the schema-element() test 
 
Rule 1 succeeds: the name of the candidate node is e.
 
Rule 2 succeeds: the type annotation is xs:integer

Rule 3 fails: the nilled property is not false, and the element declaration (the
global e declaration) is not nillable. But if the global element declaration had
said nillable="true", then rule 3 (and therefore the schema-element() test)
would succeed.

If this analysis is correct, then rule 3 does have some substance.

But I wonder what purpose is served by annotating e as an xs:integer in this
case? Why don't we say that if an element is nilled, its type annotation is
[absent] (or some similar nihilistic value)?

The Data Model section 3.3.1.2 says that if an element is annotated with an
atomic type T, then the typed value of the element is an instance of T. If my
reasoning above is correct, then this statement isn't true: the typed value of
<e xsi:nil="true"/> can surely only be ().

Mike

Received on Tuesday, 19 April 2005 15:36:23 UTC