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 24529 - Missing explicit default values for uses of xsl:context-item/@use
Summary: Missing explicit default values for uses of xsl:context-item/@use
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XSLT 3.0 (show other bugs)
Version: Last Call drafts
Hardware: PC Windows NT
: P2 normal
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: 2014-02-05 20:28 UTC by Abel Braaksma
Modified: 2014-02-24 15:03 UTC (History)
1 user (show)

See Also:


Attachments

Description Abel Braaksma 2014-02-05 20:28:26 UTC
Under 6.7 Declaring the Context Item (http://www.w3.org/TR/xslt-30/#declaring-context-item) the syntax for xsl:context-item defines the use attribute as optional attribute with one of three values, required, optional, prohibited.

Under the second paragraph of 6.7.1 the text says 

"When the xsl:context-item element appears as a child of xsl:mode, the only permitted value for the use attribute is required"

but doesn't mention what happens when the use attribute is omitted when xsl:context-item is used as child of xsl:mode (error? default to required?).

For other uses, as in a child of xsl:template, there is no mention either of what the default value for this attribute should be. Indirectly, from the first example at the bottom of 6.7.1 we can deduct that the default is "required".

Under 6.7.2, third paragraph, the text says (in the middle):

"If the containing xsl:template element has no name attribute then the only permitted value is required."

same applies here as for the xsl:context-item under xsl:mode. 

It is not trivial to deduct what the default should be. My guess is that the default for a template with a name attribute should be "optional" and the default for xsl:mode or an xsl:template without a name attribute should be "required". Or alternatively, not specifying the use attribute other than when the default is allowed to be "optional" (as that same third paragraph describes), is an error.

Note also the line under 6.7.1 (last line before example):

"If there is no xsl:context-item element for an xsl:mode that specifies initial="yes", this is equivalent to specifying <xsl:context-item as="item()"/>"

It's probably better that we be more explicit here, i.e., give the use attribute as well.
Comment 1 Abel Braaksma 2014-02-05 20:47:46 UTC
Just to illustrate:

<xsl:mode>
   <xsl:context-item as="document-node()" />
</xsl:mode>

<xsl:template match="*">
   <xsl:context-item as="element(foo)" />
</xsl:template>

<xsl:template name="bar">
   <xsl:context-item as="xs:string" />
</xsl:template>

The defaults for these context items are different in respect to the omitted @use attribute. Is it allowed to omit it and if it can be omitted, is the default the assumed default (resp. required, required, optional)?
Comment 2 C. M. Sperberg-McQueen 2014-02-12 09:34:06 UTC
We discussed this in Prague.

Some WG members suggested that it might be most usable not to declare defaults for the @use attributes.  Others countered that since the xsl:context-item element itself is optional, there must necessarily be a default behavior.

After discussion we agreed with the following resolution:  define the default value of xsl:mode/xsl:context-item/@use as 'required'.  For context-item within template, the default is already specified (indirectly) as 'optional'.
Comment 3 Michael Kay 2014-02-24 15:03:57 UTC
Closed as suggested.