Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 28th, 2005, 01:34 PM
Authorized User
 
Join Date: Dec 2003
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default xsl template concat problem

Hi,
I have a template which the values needs to be concatenated with comma and assign it to a variable. I have a code like this.

  <xsl:variable name="ordernames">
     <xsl:call-template name="test">
  </xsl:variable>
   <table><tr><td><xsl:value-of select="$ordernames"/>

  <xsl:template name="test">
    <xsl:value-of select="order_name">
    <xsl:text>,</xsl:text>
  </xsl:template>
How I can do this? Please help.

 
Old January 28th, 2005, 02:04 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

Use Concat function.

 
Old January 28th, 2005, 02:12 PM
Authorized User
 
Join Date: Dec 2003
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for you help.
Could you please give me an example.Because I received an error when I use a varibale like this.
<xsl:variable name="ordernames">
   <xsl:call-template name="test">
</xsl:template>
Thanks..

 
Old January 30th, 2005, 02:00 PM
Authorized User
 
Join Date: Jul 2004
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

xml:
<foo>
  <bar>one</bar>
  <bar>two></bar>
  <bar>three></bar>
</foo>

xsl:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:template match="/">
      <xsl:variable name="fooValues">
         <xsl:apply-templates select="foo/bar" />
      </xsl:variable>
      <xsl:value-of select="$fooValues" />
   </xsl:template>

   <xsl:template match="bar">
      <xsl:value-of select="text()" />
      <xsl:if test="position()!=last()">,</xsl:if>
   </xsl:template>
</xsl:stylesheet>

Bryan

 
Old January 31st, 2005, 02:58 PM
Authorized User
 
Join Date: Dec 2003
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
Thanks for your solution.This code is working for 'http://www.w3.org/1999/XSL/Transform' namespace.But I have a xsl file with 'http://www.w3.org/TR/WD-xsl'. It wouldn't allow me create a variable. Also what I am trying to do is to display the variable value 'onmouseover' of the <td>.But it's not working.
Could you please help.

Here is the code:
<tr>
<td><xsl:attribute name="onmouseover"><xsl:value-of select="$fooValues" />
</td>
</tr>

 
Old January 31st, 2005, 03:43 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

WD-xsl is dead, it's been obsolete for five years. The sooner you move off it, the less money you will be throwing down the drain.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl:template problem mickhughes XSLT 1 August 16th, 2007 08:40 AM
XSL: template reuse ramesh.kumarm XSLT 16 December 1st, 2006 06:27 AM
xsl:call-template name="$variable" problem chemi XSLT 1 October 6th, 2005 07:28 AM
xsl:template match 'overlapping' ? Kabe XSLT 1 February 25th, 2005 06:03 AM
help with xsl template match enT XSLT 9 September 24th, 2003 06:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.