ACTION-1979 - Send mail listing options for the bind to multiple types problem

All,

During the last call, we discussed whether it was a good idea to allow
multiple type model item properties on a given node.

As a reminder, the type MIP:

1. is used to validate data.
2. provides a type annotation
  a. used by controls so that they can determine how to present themselves.
  b. used by XPath 2 expressions.

In cases 2a and 2b, controls and XPath expressions require having a
single type or no type at all. Multiple types do not make sense.

If we decide to disallow multiple type properties, we need to specify
what "disallow" means. The following options come to mind:

1. Stop XForms processing. However with XForms 2.0 we are moving away
from this, so this is an option easy to eliminate.
2. Take the first applicable type property only.
3. Take the last applicable type property only.
4. Ignore all type properties that try to apply to the node.

With options 2, 3 and 4, we could in addition dispatch an error event.

If we decide to "allow" multiple type properties, we need to decide
what it means for the various applications of this property.

For validation, we could simply say, as the spec already does right
now, that all types are checked. This is easy to understand and to
implement. But it also rarely makes much sense (feedback needed here).

The main problem arises when there is a need to obtain a type
annotation, as that type annotation must be unique. Options:

1. Find the least specific type, or the most specific type.
2. Take the first applicable type property only.
3. Take the last applicable type property only.
4. Ignore all type properties that try to apply to the node.

(Options 2, 3 and 4 mirror options 2, 3 and 4 in the "not allowed" case above.)

Option 1 is difficult to define and implement. There is not much
meaningful type inheritance in the XPath type hierarchy [1]. This
would make the most sense when XML Schema is in used, as XML Schema
support inheritance. But this might be a can of worms and I don't
think we have much of a use case for it at this time.

Our implementation only associates a single type with a node,
following the "last type MIP wins" logic:

    <form>
        <name>42</name>
    </form>

    <bind ref="name"  type="xs:string"/>
    <bind ref="name" type="xs:integer"/>

would associate the `xs:integer` type with the `name` node. This type
is used for validation as a the unique type annotation for the node.

The "last" type MIP is determine during rebuild of the binds tree, so,
with dynamic dependencies, can change over the course of time.
Example:

    <form>
        <name type="integer">42</name>
    </form>

    <bind ref="name[@type = 'string']"  type="xs:string"/>
    <bind ref="name[@type = 'integer']" type="xs:integer"/>

This solution doesn't seem too bad to me.

-Erik

[1] http://www.w3.org/TR/xpath-datamodel/#types-hierarchy

Received on Tuesday, 21 October 2014 22:45:56 UTC