Re: [xsl] Node-sets using <xsl:with-param>

Subject: Re: [xsl] Node-sets using <xsl:with-param>
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 22 Jan 2004 15:40:19 -0500
BINGO! Found it!

At 2004-01-22 14:58 -0500, Mir Farooq Ali wrote:
This is the xml source file on which I'm using the stylesheet
...

Nothing untoward in there, but using that data and adding a single debug statement pointed me to the problem.


Being a second-generation computer programmer (my father started in the trade in 1961, I started programming in 1971), I have long relied on the "printf method of debugging", so I added at the top of the modify template:

<xsl:message><xsl:value-of select="name(.)"/></xsl:message>

At 2004-01-22 12:10 -0500, Mir Farooq Ali wrote:
<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>

The problem is happening the *second* time around because of the above statement. I saw *two* element names exposed before the problem was triggered.


Add <xsl:with-param name="curnode" select="$curnode"/> (or with whatever you need for the argument) to your nested <xsl:apply-templates/> and it will work because you are passing a node for the second invocation.

The first time around, $curnode was just fine ... it was the second time around that you weren't passing a value and the defaulted empty string was being used.

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