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

Re: Return value from a template 2...

Subject: Re: Return value from a template 2...
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 23 Jan 2008 09:21:14 GMT
Re:  Return value from a template 2...
> I want to return a value from a template(getIdList)

templates never return values (in the sense of a function
return). Anything they generate is always added to the current output
(whetehr that is the stylesheet result, or a variable).

You haven't said what ypur input looks like, or what output ypiu want or
what transform you are trying to do, so I can make some comments on the
code you posted but can't really suggest any code that you need,
although I make a blind guess at the end.


       <xsl:template match="/root">
               <xsl:variable name="idList">
                       <xsl:call-template select="/root/vid" name="getIdList" />
               </xsl:variable>
               <xsl:value-of select="$idList"/>
       </xsl:template>

This is a syntax error you can not have a select attribute on
call-template so you should get no output. If you delete that then
it generates a variable  idList with a document node with child nodes
anything generated by getIdList, it then discards any nodes in that
variable and outputs the string value of $idList.

               <xsl:for-each select=".">

doing a for-each over a single node is a no-op, so it is like not having
the for-each except that variable definitions have skope the current
element so it restricts the scope of $idList"

select="concat($var,

there is no variable $var in scope at this point (you haven't defined
var yet) What processor are you using, again this should have given you
a syntax error and no output.

               </xsl:for-each>
if the definition of $var had been syntactivcally correct, it would have
gone out of scope at this point.

               <xsl:value-of select="$var"/>
so this is a reference to an undefined variable.


I suspect that what you want is
 
<xsl:template match="/root">
 <xsl:for-each select="vid">
 <xsl:value-of select="."/>
 <xsl:if test="position()!=last()">,</xsl:if>
</xsl:for-each>
</xsl:template>

or, in xslt2

<xsl:template match="/root">
<xsl:value-of select="vid" separator=","/>
</xsl:template>


With no variables at all


David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

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.