[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: can't get variable content after call-template

Subject: Re: can't get variable content after call-template
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Mon, 26 Jun 2006 14:55:55 +0530
xsl variable calling
Hi Georg,
 You need to use template parameters as below:

<xsl:template match="//example" mode="multi">
  <xsl:variable name="pmode">multi</xsl:variable>
  <xsl:variable name="pmode" select="'multi'" /> <!-- or like this,
as David suggested -->
  <xsl:call-template name="logfile">
     <xsl:with-param name=pmode" select="$pmode" />
  </xsl:call-template>
  <xsl:apply-templates mode="multi"/>
</xsl:template>

<xsl:template name="logfile">
  <xsl:param name="pmode" />
  <xsl:choose>
     <xsl:when test="$pmode='multi'">
        <xsl:text>mode: multi</xsl:text>
     </xsl:when>
     <xsl:otherwise>
        <xsl:text>mode: normal</xsl:text>
     </xsl:otherwise>
  </xsl:choose>
</xsl:template>

Regards,
Mukul


On 6/26/06, Georg Hohmann <georg.hohmann@xxxxxxxxx> wrote:
Hello,

I've gone through the "variable" section at
http://www.dpawson.co.uk/xsl/sect2/N8090.html#d10293e40
but couldn't find a solution ... so here i'm back on the list.

I got a stylesheet like this
...
<xsl:template match="//example" mode="multi">
  <xsl:variable name="pmode">multi</xsl:variable>
  <xsl:call-template name="logfile"/>
  <xsl:apply-templates mode="multi"/>
</xsl:template>
...
<xsl:template name="logfile">
  <xsl:choose>
     <xsl:when test="@pmode='multi'">
        <xsl:text>mode: multi</xsl:text>
     </xsl:when>
     <xsl:otherwise>
        <xsl:text>mode: normal</xsl:text>
     </xsl:otherwise>
  </xsl:choose>
</xsl:template>

I want to use this for writing a logfile which content depends on the
mode set by the "-im" option of saxon. But when i run this i get
"Variable $pmode has not been declared". It seems like the variable
declaration in the initial template is not recognized, but i don't
know why.
Any help is appreciated.

Regards,
Georg

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.