W3C home > Mailing lists > Public > public-qt-comments@w3.org > April 2016

[Bug 29571] New: [XQ31] [FO31] 3.18.3 Cast

From: <bugzilla@jessica.w3.org>
Date: Tue, 12 Apr 2016 09:11:12 +0000
To: public-qt-comments@w3.org
Message-ID: <bug-29571-523@http.www.w3.org/Bugs/Public/>

            Bug ID: 29571
           Summary: [XQ31] [FO31] 3.18.3 Cast
           Product: XPath / XQuery / XSLT
           Version: Candidate Recommendation
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XQuery 3.1
          Assignee: jonathan.robie@gmail.com
          Reporter: tim@cbcl.co.uk
        QA Contact: public-qt-comments@w3.org
                CC: mike@saxonica.com
  Target Milestone: ---

In XQ31 3.18.3 Cast it is written

"If the result of atomization is an empty sequence:

    If ? is specified after the target type, the result of the cast expression
is an empty sequence.

    If ? is not specified after the target type, a type error is raised

Suppose the target type is my:list which is a simple list type whose minLength
is zero, and we have the query:

() cast as my:list

Following the rules above:

1. the result of atomization is the empty sequence.
2. ? is not specified.  Therefore a type error is raised.

FO31 says "If the target type of a cast expression (or a constructor function)
is a type with variety list, the supplied value must be of type xs:string or
xs:untypedAtomic.".  So perhaps a type error is correct behaviour.

However in FO31 18.3 Constructor functions for XML Schema built-in list types,

"The return type, however, allows for the fact that when the argument to the
function is an empty sequence, the result is an empty sequence."

which makes it clear that

() cast as xs:NMTOKENS 

is not a type error.

In "18.5 Constructor functions for user-defined types", it is stated that

"For every user-defined simple type in the static context (See Section 2.1.1
Static Context XP31), there is a constructor function whose name is the same as
the name of the type and whose effect is to create a value of that type from
the supplied argument". 

The text goes on to state that

"In the case of an atomic type A, the return type of the function is A?,
reflecting the fact that the result will be an empty sequence if the input is
an empty sequence. For a union or list type, the return type of the function is
specified only as xs:anyAtomicType*. Implementations performing static type
checking will often be able to compute a more specific result type. For
example, if the target type is a list type whose item type is the atomic type
A, the result will always be an instance of A*; if the target type is a pure
union type U then the result will always be an instance of U?. In general,
however, applications needing interoperable behavior on implementations that do
strict static type checking will need to use a treat as expression to assert
the specific type of the result."

I can't find the text that states that the argument to the constructor function
is xs:anyAtomicType?.

It might be worth noting that a query such as

xs:NMTOKENS("a b c") cast as NMTOKENS is a type error, which seems odd.

You are receiving this mail because:
You are the QA Contact for the bug.
Received on Tuesday, 12 April 2016 09:11:15 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:57:59 UTC