The XSLT 2.0 spec is quite explicit about this:
 
"Parameters passed to the transformation by the client application are matched against stylesheet parameters (see 9.5 Global Variables and Parameters), not against the template parameters declared within the initial template. All template parameters within the initial template to be executed will take their default values." (from section 2.3).
 
XSLT 1.0 left things much more up to the implementation, and it's difficult to advise you because I don't know precisely what Xalan does.
 
However, I would expect the following to work in all cases:
 
(a) declare your template with a name and with internal template parameters; don't use it as the initial entry template for the stylesheet
 
(b) declare an initial entry template, without internal template parameters, that simply calls your named template supplying parameters copied from global stylesheet parameters
 
 <xsl:param name="p"/>
 <xsl:param name="q"/>
 
 <xsl:template match="/">
   <xsl:call-template name="named">
     <xsl:with-param name="p" select="$p"/>
     <xsl:with-param name="q" select="$q"/>
   </xsl:call-template>
 </xsl:template>
 

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay

 


From: Sivan Mozes [mailto:sivan.mozes@gmail.com]
Sent: 10 June 2009 01:07
To: saxon-help@lists.sourceforge.net
Subject: [saxon] Setting parameters on imported templates from Saxom

I have a template that can be loaded as standalone, or imported into other templates and then called using xsl:call-template. The template is declared using both the match and name attributes: <xsl:template name="main" match="/">

While using Xalan it was possible to declare the parameters inside the template, and then setParameter would pass them to the template, even though they really should be declared globally for this to work. But if they are declared globally, they are not available when the template is called after an import. Saxon enforces this. 

How can these two uses be reconciled?

Thanks,

Sivan