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

Re: Return value from a template...

Subject: Re: Return value from a template...
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Tue, 08 Jan 2008 17:50:10 +0100
Re:  Return value from a template...
Batis DAVE 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" />

An xsl:call-template does not allow a select attribute. If you define parameters on your template with xsl:param then you can pass parameters to the called template using xsl:with-param.


		</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"/>

The variable var is defined inside of the for-each but it is that way not available outside of it.


</xsl:template>

</xsl:stylesheet>

What's wrong in it?

See comments above. I am not sure what you want to achieve, if you want your named template to concatenate the ids values then you might want to do it as follows:
<xsl:template name="getIdList">
<xsl:param name="items"/>
<xsl:for-each select="$items/ids">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">
<xsl:value-of select="$delimiter"/>
</xsl:if>
</xsl:for-each>
</xsl:template>


  <xsl:template match="/root">
    <xsl:call-template name="getIdList">
      <xsl:with-param name="items" select="bib"/>
    </xsl:call-template>
  </xsl:template>

The above is more or less guessing on how your XML input might look and what you want to achieve with your named template. If it does not help then you might want to post your XML input and tell us what you want to achieve.



--

	Martin Honnen
	http://JavaScript.FAQTs.com/

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-2013 All Rights Reserved.