[XSLT 2.0] Type Consistency for Overridden Definitions

I raised this initially on the XSL WG internal list at:

http://lists.w3.org/Archives/Member/w3c-xsl-wg/2004Jan/0006.html

The WG accepted the proposal with modifications, and actioned me to
raise it as a public comment to give visibility and invite comments.

The modified proposal is as follows:

We should have a rule that if a global variable, parameter,
template, or function declares its type, then it cannot be overridden in
an importing stylesheet except by an object whose type is compatible.

For example, if xmlspec.xsl declares

<xsl:param name="diff" select="false()" as="xs:boolean"/>

then it should not be possible for xsltspec.xsl (which imports
xmlspec.xsl) to declare

<xsl:variable name="diff" select="0"/>

Overriding a variable or parameter is really just another way of giving
it a value, and this ought to be a type-safe operation.

We propose to keep the rules very simple:

* if a stylesheet contains a global variable, parameter, function, or
template that declares the type of its value/result using an "as"
attribute, then any definition in an importing stylesheet that overrides
this definition must also declare a type, and this must be the same
type. 

* a function A that overrides a function B must use the same type
declarations in each of the function parameters

* a template A that overrides a template B must declare all the
parameters that B declares, with the same types; required parameters may
be made optional but optional parameters may not be made required;
additional parameters may be added but they must be optional.

Michael Kay

Received on Sunday, 25 January 2004 16:47:54 UTC