[Bug 4273] [FS] data on element()

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





------- Comment #7 from tim@cbcl.co.uk  2007-02-26 12:19 -------
This leads me to the conclusion that, when constructing nodes with construction
mode preserve, the associated type-name should not be element().  Rather it
should be a type I've named "xs:typed" (for want of anything better), defined
as:

 define type xs:typed restricts xs:anyType {
    attribute * of type xs:anySimpleType,
    ( element * of type xs:anyType | text | comment | processing-instruction )*
  }

I believe this to be correct because, 

1. Any copied attributes will retain their type annotations, therefore their
most specific common type is attribute() = attribute * of type
xs:anySimpleType.

2. Any copied elements will retain their type annotations, therefore their
most specific common type is element() = element * of type xs:anyType.

3. Text, comment and processing instructions nodes are copied through.

4. Enclosed expressions which are a subtype of xs:anySimpleType are converted
into text nodes.  i.e. <a>{1}</a> is an element containing a text node, not an
integer.

i.e. fn:data() on any constructed node (regardless of construction mode) will
can never return a value of any atomic type other than xs:untypedAtomic.

e.g. In the query 1 + <a>2</a>, fn:data(<a>2</a>) is of type xs:untypedAtomic,
regardless of construction mode.

In my original example, fn:data($y) is of xs:anySimpleType.  Since xs:integer
is a subtype of xs:anySimpleType, treat as type assertions (explicit if static
typing is required, otherwise implicit) will work.  

I've now implemented this, together with:

-------------------------------------------------------
data on element * of type xs:anyType : xs:anySimpleType

and it appears to work in all XQTS tests.

Received on Monday, 26 February 2007 12:19:40 UTC