Hi ,
Probably something really simple, but I'm stuck.
This is a stylesheet for calculating a breadcrumb trail in an external XML file.
The main template calls a template named "findbreadcrumb" that goes to work on the external file.
It works great, but:
once I want to output the Result, which is the variable $breadc, it comes up empty.
When I output the result IN the actual breadcrumb routine, it's there and correct: this is at the spot
Could anybody give me a hint why that correct variable is gone after I've left the template ?
The node for which I am calculating the breadcrumb is nr. 75 which is there and not empty.
Again: I've triple checked the routine and it works fine.
I'm just losing the variable...
Cheers and thanks in advance
Matthieu Brandt
email:
[email protected]
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:variable name="varbreadc">
</xsl:variable>
<xsl:variable name="breadc">
</xsl:variable>
<xsl:variable name ="varmenuid" select="75">
</xsl:variable>
<xsl:template match="/">
<xsl:call-template name="findbreadcrumb">
<xsl:with-param name="menuid" select="$varmenuid"/>
<xsl:with-param name="breadc" select="$varbreadc"/>
</xsl:call-template>
Result: <xsl:value-of select="$breadc" />
</xsl:template>
<xsl:template name="findbreadcrumb">
<xsl:param name="menuid"/>
<xsl:param name="breadc"/>
<xsl:for-each select ="document('h:\XML\MenusWithPageCount.xml')/datarootmenu/MenusWithPageCount/Main_menu_nr[. = $menuid]">
<xsl:call-template name="bc">
<xsl:with-param name="breadc" select="parent::node()/Main_menu_name" />
<xsl:with-param name="parentnr" select ="parent::node()/Parent_menu_nr"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="bc">
<xsl:param name="breadc" />
<xsl:param name="parentnr"/>
<xsl:choose>
<xsl:when test="$parentnr > '0'">
<xsl:for-each select ="//MenusWithPageCount">
<xsl:if test ="Main_menu_nr = $parentnr" >
<xsl:call-template name="bc">
<xsl:with-param name="breadc" select= "concat (Main_menu_name,'---',$breadc)"/>
<xsl:with-param name="parentnr" select = "Parent_menu_nr"/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:when>
<xsl:when test="$parentnr = '0'">
<!-- Finished with breadcrumb routine
Variable $breadc is correctly filled-->
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>