Re: [xsl] Return value from a template...

Subject: Re: [xsl] Return value from a template...
From: "Eric Bréchemier" <eric.brechemier@xxxxxxxxx>
Date: Tue, 8 Jan 2008 17:53:43 +0100
  Hi Batis,

You cannot use call-template with select="/root/bib"

"Unlike xsl:apply-templates, xsl:call-template does not change the
current node or the current node list." [1]

You should give a try to using apply-templates instead.

Besides, "variable" in XSLT cannot be changed after first initialization, so
<xsl:variable name="var"  select="concat($var,ids, $delimiter)"/> is
bound to fail.

[1] XSL Transformation (XSLT) version 1.0, '6 Named Templates
http://www.w3.org/TR/xslt#named-templates

Cheers,

Eric Brichemier

On Jan 8, 2008 4:58 PM, Batis DAVE <batis.04@xxxxxxxxx> wrote:
> I want to return a variable value from a template based on this example:
> http://biglist.com/lists/xsl-list/archives/200205/msg01614.html
> but it's not working...
> Here's my code:
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
> <xsl:output indent="yes" method="html" omit-xml-declaration="no"
> encoding="ISO-8859-1" />
> <xsl:param name="delimiter" select="','"/>
>
>         <xsl:template match="/root">
>
>                 <xsl:variable name="idList">
>                         <xsl:call-template select="/root/bib"
name="getIdList" />
>                 </xsl:variable>
>
>                 <xsl:value-of select="$idList"/>
>
>         </xsl:template>
>
>
>         <xsl:template match="/root/bib" name="getIdList">
>                 <xsl:for-each select="/root/bib">
>                         <xsl:variable name="var"  select="concat($var,ids,
$delimiter)"/>
>                 </xsl:for-each>
>                 <xsl:value-of select="$var"/>
>         </xsl:template>
>
> </xsl:stylesheet>
>
> What's wrong in it?

Current Thread