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 7410 - [XSLT 2.1] Declare context item for a named template
Summary: [XSLT 2.1] Declare context item for a named template
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XSLT 3.0 (show other bugs)
Version: Working 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: 2009-08-24 11:26 UTC by Michael Kay
Modified: 2011-06-08 20:40 UTC (History)
1 user (show)

See Also:


Attachments

Description Michael Kay 2009-08-24 11:26:21 UTC
We have introduced a declaration xsl:context-item to declare the type and other properties of the context item at the level of the initial stylesheet invocation. It would be useful to reuse this construct to allow declaration of the context item supplied to a named template. At present the scope for static checking of named templates against a schema is very limited, because the type of the context item is not known and cannot be declared.
Comment 1 Michael Kay 2010-07-16 11:09:25 UTC
Accepted in principle at the Oxford F2F. Need some syntax to say whether the context item is required, optional, or prohibited. Using "?" after the item type doesn't quite capture the fact that if there's no context item, "." is an error rather than an empty sequence.
Comment 2 Michael Kay 2010-11-18 16:42:56 UTC
I propose that xsl:template should have a permitted child element xsl:context-item, to appear optionally before any xsl:param elements, with the syntax

<xsl:context-item
  use = required|optional|prohibited
  as? = ItemType />

If the template is unnamed, then use=required is the only permitted value.

If use=prohibited is specified then the as attribute must be absent.

The element declares requirements on the context item, whether the template is invoked by match or by name. The use attribute declares whether the context item is required or optional; the value prohibited indicates that the context item is set to absent on entry to the template (it does not mean that it's an error if there is a context item at the time of the call).

If there is a context item supplied by the caller, then it must match the given item type; otherwise a type error occurs.
Comment 3 Michael Kay 2011-03-24 13:45:07 UTC
Current status: this feature is in the status quo draft.
Comment 4 Michael Kay 2011-06-08 20:39:46 UTC
Closing this on the grounds that we now have a design in the current draft that meets the requirements.