Re: Paramter passing in Xalan

Subject: Re: Paramter passing in Xalan
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Sun, 18 Jun 2000 10:41:39 +0100

I'm not sure that I understand this totally myself, but I'll tell you what I think the problem is and prepare to be shouted down by the experts on this list.  Looking at where you're applying templates, you have:

  <xsl:apply-templates select="document($massfile-la)">
    <xsl:with-param name="iden" select="$fvid"/>

This tells the XSL processor to find the next template to be applied, and pass to it the parameter 'iden' set to the particular value that you have specified.  Crucially, the node set that you've specified the templates to be applied to is the 'root node' of the latin document.

The XSL processor goes off and tries to find a template that it can apply to the root node, and finds the default template.  There is nothing in that template that says that it is going to receive an 'iden' parameter or what to do with it.  The default template just applies templates on the children of the root node (the 'latin' element), without passing any parameter through, so the parameter is lost behind the scenes.

One way to counteract this would be to create templates that pass the parameter through from the root node, to the 'latin' element, and then to the 'text' elements.  This is probably not worthwhile, since you are only interested in the 'text' elements: instead you can specify that the 'text' elements are the ones that should be processed.  In other words, change the 'select' attribute in your 'xsl:apply-templates' to specify those nodes:

  <xsl:apply-templates select="document($massfile-la)/latin/text">
    <xsl:with-param name="iden" select="$fvid"/>

The moral of the story is that you have to make sure that your parameters will be passed through the chain of templates to get to the one that you actually use them in, or jump straight to that template if you can.

I hope that helps,


Dr Jeni Tennison
Epistemics Ltd * Strelley Hall * Nottingham * NG8 6PE
tel: 0115 906 1301 * fax: 0115 906 1304 * email: jeni.tennison@xxxxxxxxxxxxxxxx

 XSL-List info and archive:

Current Thread