W3C home > Mailing lists > Public > public-qt-comments@w3.org > January 2007

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

From: <bugzilla@wiggum.w3.org>
Date: Tue, 23 Jan 2007 09:29:40 +0000
To: public-qt-comments@w3.org
Message-Id: <E1H9HyG-0001tN-8h@wiggum.w3.org>


           Summary: [FS] data on element()
           Product: XPath / XQuery / XSLT
           Version: Proposed Recommendation
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Formal Semantics
        AssignedTo: simeon@us.ibm.com
        ReportedBy: tim@cbcl.co.uk
         QAContact: public-qt-comments@w3.org

Consider the query:

declare variable $x as element(a, xs:integer) external;
declare variable $y as element() := $x;

let $z as xs:integer := fn:data($y)
  return $z;

>From FS 3.5.4, we know that:

element(a, xs:integer) = element a of type xs:integer
element() = element * of type xs:anyType

>From FS 3.5.1, we know that:

xs:integer <: xs:anyType

>From FS 5.14, we know that:

1. the static type of $x is element a of type xs:integer
2. the static type of $y is element * of type xs:anyType

$y is assignable from $x because:

element a of type xs:integer <: element * of type xs:anyType

Now consider the type checking of fn:data($y).  This depends on the "data on"
judgements in FS 7.2.6.  As these judgements get quite involved, I refer to
XQuery 2.5.2, point 4a:

"For an element node, the relationship between typed value and string value
depends on the node's type annotation, as follows: If the type annotation is
xs:untyped or xs:anySimpleType or denotes a complex type with mixed content
(including xs:anyType), then the typed value of the node is equal to its string
value, as an instance of xs:untypedAtomic"

Therefore fn:data($y) is of type xs:untypedAtomic.  Now,

not(xs:untypedAtomic <: xs:integer)

and therefore "let $z as xs:integer := fn:data($y) return $z;" will fail to
type check.

Consider the differences if the argument to fn:data had been $x instead of $y.

let $z as xs:integer := fn:data($x)
  return $z;

>From FS 7.2.6, "When applied to an element type whose type annotation denotes a
simple type or a complex type of simple content, data on returns the element's
simple type."  

So fn:data($x) is of type xs:integer, and therefore the query will type check

The strange thing is that $x and $y are the same value.  The only difference is
their static types at type check time - during evaluation their dynamic types
will be identical.  Thus an implementation which only performs type checking at
run time will execute both queries happily.

Have I made some mistake, or is there a problem here?
Received on Tuesday, 23 January 2007 09:29:52 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:45:32 UTC