This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 30238 - [XSLT30] xsl:context-item/@as no function conversion rules, but same error as for xsl:param, confuses me
Summary: [XSLT30] xsl:context-item/@as no function conversion rules, but same error as...
Status: NEW
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XSLT 3.0 (show other bugs)
Version: Recommendation
Hardware: PC Windows NT
: P2 minor
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-30 19:32 UTC by Abel Braaksma
Modified: 2019-02-19 21:13 UTC (History)
0 users

See Also:


Attachments

Description Abel Braaksma 2018-03-30 19:32:21 UTC
In the section on xsl:context-item (10.1.1) we say, among others:

"A type error is signaled if the supplied context item does not match its required type. No attempt is made to convert the context item to the required type (using the function conversion rules or otherwise). The error code is the same as for xsl:param: [see ERR XTTE0590]. "

I understand this as follows:

1) the type is not converted or cast, that is, for instance, that xs:anyURI is not promoted to xs:string and xs:float is not promoted to xs:double, instead, they cause a type error

2) the type is valid when it is an "instance of". That is, for instance, that a supplied context item of type xs:language is valid if the expected type for the context item is xs:string (the text is not clear on this, but I can't imagine anything else)

3) the error XTTE0590 says currently, explicitly, "It is a type error if the conversion of the supplied value of a parameter to its required type fails.".  But no conversion takes place for xsl:context-item. This error contradicts the paragraph in 10.1.1, but I think the latter to be leading.

At first read, I thought: does this mean xsl:param/@as and xsl:context-item/@as work the same? 

But on reading the details, the xsl:context-item/@as is stricter.

I would prefer if we make this clearer in either the error description, or the accompanying text, they appear to contradict one another.
Comment 1 Abel Braaksma 2019-02-19 21:13:06 UTC
A proposed erratum was published on 13 Feb 2019, HTML version: https://htmlpreview.github.io/?https://github.com/w3c/qtspecs/blob/master/errata/xslt-30/html/xslt-30-errata.html#E22

The erratum states:

"The rules for xsl:context-item and xsl:global-context-item say that no conversion is attempted to the declared type. But the error that occurs if the supplied item is of the wrong type is XTTE0590, whose description assumes that a conversion is taking place."

This is incorrect, the XSLT REC says that the function conversion rules apply to xsl:global-context-item. Conversely, they say that they do *not* apply to xsl:context-item.

I don't know why this difference exists and I don't know if we can fix it (I would prefer to bring them in line). 

Both xsl:context-item and xsl:global-context-item refer to XTTE0590, which implies conversion of the parameter. The proposed erratum suggests the following text:

"[XTTE0590] It is a type error if the supplied value of a parameter, or of the context item, does not match the required type, after applying any permitted conversions."

I would like to suggest something along those lines instead (short of introducing different errors):

"[XTTE0590] It is a type error if the supplied value of a parameter, or of the <link: global context item>, does not match the required type after applying the function conversion rules, or if the context item does not match the type of a locally declared <link: context item>."