Re: Nillable complex type with simple content (PR#92)

Hi Erik,

This is a very technically interesting issue you have raised.

The working group agrees that nillable appears to be a statement about the
content of an element. However, our hands are a bit tied here because XML Schema
Part 1 Section 3.3.4 associates the notion of nillable with "Element Locally
Valid (Element)" and not "Element Locally Valid (Type)".  By comparison, XForms
associates the type MIP with the type validation, and more specifically with the
simple content part of a schema type.

Hence, we agree with your assessment that a type MIP assignment does not
associate nillable with a node.  Moreover, a clarification note in the
specification does not appear to be necessary because a type MIP also *cannot*
refer to an element declaration, which is the only place where nillable can
occur in an XML schema.  Because nillable is associated with element validity
and not type validity, it cannot be attached to a schema type declaration.  

If your schema below were modified to include a named complexType for
"state-element", it would be clearer that the nillable attribute is attached to
the xs:element that declares "state-element" and not the complexType for
"state-element".  However, this modification is necessary in order for you to
have a correct XForm, as the type MIP must refer to the complexType for
"state-element" and not the element declaration itself.

Please let us know if you have any further concerns about this issue.

Thank you,
John Boyer

> 
> All,
> 
> I am sending this following an interesting comment about schema types
>  from a user.
> 
> XForms 1.1 specifies that:
> 
>     "The type model item property associates a datatype (as defined in
>      [XML Schema part 2]) with the string-value (as defined in [XPath
>      1.0]) of an instance node. The datatype being associated can be
>      obtained from a simpleType definition or a simpleContent definition
>      from a complexType. If the datatype cannot be obtained as just
>      described, then the Default Value of xsd:string is used."
> 
> Now, I assume that this means I can write something like this:
> 
>       <xs:element name="state-element">
>           <xs:complexType>
>               <xs:simpleContent>
>                   <xs:extension base="test:state-type">
>                      <xs:attribute name="code" type="xs:integer"/>
>                   </xs:extension>
>               </xs:simpleContent>
>           </xs:complexType>
>       </xs:element>
> 
> use it as follows:
> 
>       <xforms:bind nodeset="state" type="test:state-element"/>
> 
> and I should expect the validator to validate the content of my
> <state> instance element using the datatype part of my xs:element
> definition.
> 
> First, is this correct?
> 
> Second, what if my type is as follows instead:
> 
>       <xs:element name="state-element" nillable="true">
>           <xs:complexType>
>               <xs:simpleContent>
>                   <xs:extension base="test:state-type">
>                      <xs:attribute name="code" type="xs:integer"/>
>                   </xs:extension>
>               </xs:simpleContent>
>           </xs:complexType>
>       </xs:element>
> 
> and my instance element:
> 
>     <state xsi:nil="true">CA</state>
> 
> Is XForms supposed to honor xsi:nil in this case, and accept an empty
> content for <state>?
> 
> My guess is that it is not in fact part of the dataype. XML Schema says:
> 
>     "If {nillable} is true, then an element may also be ?valid? if it
>      carries the namespace qualified attribute with [local name] nil
>      from namespace http://www.w3.org/2001/XMLSchema-instance and value
>      true (see xsi:nil (?2.6.2)) even if it has no text or element
>      content despite a {content type} which would otherwise require
>      content."
> 
> So the nil thing seems to apply to the validity of the element, not of
> its datatype part.
> 
> However, after all the form author is binding a nillable element type
> to an XForms instance element, and it is not very intuitive that
> xsi:nil won't work in this case.
> 
> Whatever the answer, I think that it would be very valuable to clarify
> this in the spec.
> 
> -Erik
> 
> -- 
> Orbeon Forms - Web Forms for the Enterprise Done the Right Way
> http://www.orbeon.com/
> 
> 

Received on Wednesday, 17 October 2007 22:52:16 UTC