<xsl:param name="p" as="xs:integer"/>
The initial value of $p is an empty sequence, which is not a valid value given the type as="xs:integer". The error should be a static error.
The nearest we have to this in the spec is:
[ERR XTDE0610] If an optional parameter has no select attribute and has an empty sequence constructor, and if there is an as attribute, then the default value of the parameter is an empty sequence. If the empty sequence is not a valid instance of the required type defined in the as attribute, then the parameter is treated as a required parameter, which means that it is a dynamic error if the caller supplies no value for the parameter.
but that is a dynamic error.
The "which means..." clause also seems incorrect for a parameter to a named template; if such a parameter is required, it's a static error.
Propose changing it to:
A parameter defined using xsl:param is *implicitly required* if all the following apply:
* it has no select attribute
* it has an empty sequence constructor
* it does not specify required="yes"
* it has an .as. attribute defining the required type, and the empty sequence is not a valid instance of the required type
When an xsl:param element defines an implicitly required parameter, then:
* if its parent is an xsl:template with a .name. attribute, then it is a static error [REF:XXXXXXX] if there is an xsl:call-template instruction that does not supply a value for the parameter
* if its parent is an xsl:iterate instruction, it is a static error [XXXXXXXX]
* if its parent is an xsl:template element with a .match. attribute, it is a dynamic error if the caller supplies no value for the parameter.
I had a little difficulty disentangling the structure here. I think the decision tree is as follows, where $p is the xsl:param element:
* if ($p/@required="yes" or $p/parent::xsl:function) then the parameter is *explicitly required*
* if a parameter is *explicitly required* then no default value must be specified (static error, no code given)
* if a parameter is not *explicitly required*:
** if there is an explicit default value (a select attribute or non-empty seq-tor), then the default must conform to the required type [XTTE0600]
** if there is no explicit default, and the implicit default does not conform to the required type, then the parameter is *implicitly required*
** in general it is a dynamic error if a parameter is explicitly or implicitly required and no value is supplied by the caller ([XTDE0700] or [XTDE0610] depending on whether it is explicitly or implicitly required)
** but it is a static error (XTSE0690) if an explicitly required non-tunnel parameter is not supplied by xsl:call-template
** it is a static error if xsl:iterate/xsl:param is implicitly required (the subject of this bug)
The above rules are very dispersed around the spec; I think it's worth trying to bring them into one place (9.2).
This has been resolved as part of a larger reorganization of the section 9.2 on xsl:param, that now organizes related material into separate subsections.
The reorganized text introduces the terms "explicitly mandatory" for a parameter declared with required="yes", and "implicitly mandatory" for a parameter whose declared type does not permit an empty sequence.
As part of this reorganization a new error condition has been introduced:
[ERR XTSE3520] It is a static error if a parameter to xsl:iterate is implicitly mandatory.