[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Node-sets using

Subject: Re: [xsl] Node-sets using <xsl:with-param>
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 22 Jan 2004 14:00:16 -0500

At 2004-01-22 12:10 -0500, Mir Farooq Ali wrote:
G. Ken Holman wrote:
If you are using <xsl:with-param/> inside of <xsl:apply-templates/> (you don't say if you are using <xsl:call-template or not) make sure you don't have any built-in templates being triggered between the processing of the two templates. If so, the built-in template will not pass the node parameter, the template with the parameter declaration will get called by the built-in template with no parameters, the default value for an empty parameter declaration is string, and you will have an empty string passed for the <xsl:apply-templates/>.
This is my stylesheet

<xsl:apply-templates mode="modify" select="/TM/
<xsl:with-param name="id1" select="$id"/>
<xsl:with-param name="curnode" select="."/>
<xsl:template mode="modify" match="*">
<xsl:param name="id1"></xsl:param>
<xsl:param name="curnode"></xsl:param>
<xsl:variable name="idd" select="translate($id1,' ','_')"></xsl:variable>
<xsl:variable name="newid" select="concat($idd, position())"></xsl:variable>
<part class="{name()}" id="{$newid}">
<xsl:apply-templates mode="modify">
<xsl:with-param name="id1" select="$newid"></xsl:with-param>
<!--xsl:apply-templates mode="structure1" select="$curnode" /--> <!-----******* Error on this line here -->
Ken, could you please elaborate on what the built-in template rule is for the situation above?

If that is your entire stylesheet, then no built-in template rules are engaged between the two above fragments because the right-most step in the select is "*" (all elements wildcard) and the right-most step in the match is "*" (any element wildcard).

Which processor are you using? I'm suspecting an implementation problem.

With only the evidence you have posted, I would anticipate the data type of the curnode parameter to be "node set". I agree the default is "empty string" which would give you the error, but it seems obvious from your fragment that it would only be engaged by the given apply-templates because of your use of modes. I would think you would only get the error reported if the element being pushed at your stylesheet was pushed without an argument specified for the curnode parameter (as is true for the built-in template rule for elements).

Any template rule in your stylesheet is more important than the built-in template rules ... they *only* get used if you do not supply any template rule for the given node in the given mode. And when they are used, parameters are not preserved.

Sorry I cannot tell what is wrong from your fragment. If you post a short XML source file that triggers the error with this stylesheet fragment, then others could try the fragments with different processors.

I hope this helps.

........................... Ken

Public courses: sign up for one or both soon to reserve your seat!
Each week:  Monday-Wednesday: XSLT/XPath;  Thursday-Friday: XSL-FO
Washington, DC: 2004-03-15           San Francisco, CA: 2004-03-22
Hong Kong, China: 2004-05-17           Bremen, Germany: 2004-05-24
World-wide on-site corporate, government & user group XML training

G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc

XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list

Current Thread