[Bug 1207] New: Is unsignedInt("+123") an error?

           Summary: Is unsignedInt("+123") an error?
           Product: XPath / XQuery / XSLT
           Version: Last Call drafts
          Platform: All
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Functions and Operators
        AssignedTo: ashok.malhotra@oracle.com
        ReportedBy: mike@saxonica.com
         QAContact: public-qt-comments@w3.org


Is the expression unsignedInt("+123") an error? 

Although the merging of text on casts and constructor functions is a great
improvement, the spec can still be read in two different ways. It hinges on the
question of whether section 17.1.1 is applicable when casting from a string to a
derived type.

If 17.1.1 is applicable, then we apply whitespace normalization and the
resulting string must be in the lexical space for the type. "+123" is not in the
lexical space of xs:unsignedInt, so this construct is an error.

If 17.1.1 is not applicable to derived types, then we find ourselves in section
17.2 (Casting to derived types) and thence 17.5, (Casting across the type
hierarchy). This tells us to (a) cast "+123" to a string (which succeeds), (b)
cast "+123" to an xs:integer (which succeeds), and (c) cast the integer 123 to
an xs:unsignedInt (which also succeeds).

So which is it? I don't think 17.1.1 makes sense unless it *is* applicable to
casting from string to a derived type, because otherwise the notion of
whitespace normalization is meaningless -  the distinctions between whitespace
handling for different target types only make sense where the target type is
derived from string. So the conclusion is that 17.1.1 should not be a subsection
of 17.1 (Casting from Primitive Types to Primitive Types) and that some better
introductory material is needed at the start of section 17 telling you which
section to turn to for each particular case.

Michael Kay

Received on Tuesday, 5 April 2005 19:13:02 UTC