This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
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.
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.
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.
Current status: this feature is in the status quo draft.
Closing this on the grounds that we now have a design in the current draft that meets the requirements.