[DM] Typed value for elements

The rules for dm:typed-value() are confusing and inconsistent for
elements and document nodes. Here is an example that illustrates one
set of problems: what is the result of the following query?

  <Cities>
    <City>
        <CityId>01</CityId>
        <Longitude>100</Longitude>
        <Latitude>32</Latitude>
    </City>
    <City>
        <CityId>02</CityId>
        <Longitude>54</Longitude>
        <Latitude>24</Latitude>
    </City>
  </Cities> * 2

In the current specification, this question can not be answered unless
we know the schema information associated with the Cities
element. Here is the current set of rules:

1. If the element has a known complex type, and it does not allow
mixed content, then it raises a type error.

2. If this element's type is xdt:untypedAny, the typed value of the
element is its string value, as an instance of xdt:untypedAtomic, so
this query evaluates to (2 * 0110032025424). This is surprising, and
it is not useful for users.

3. If this element's type is known, and it allows mixed content, the
typed value of the element is its string value, as an instance of
xdt:untypedAtomic, so this query evaluates to (2 * 0110032025424).

It would be much simpler and cleaner to say that dm:typed-value()
returns an error for any node with child elements. This is
incompatible with the behavior of XPath 1.0, but so is the current
behavior for elements of known complex type.

Jonathan

Received on Wednesday, 11 February 2004 21:05:24 UTC