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 October 19th, 2007, 04:47 AM
Authorized User
 
Join Date: Oct 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default assign XSLT variable to a wml variable

Hi,

  I have an XSLT variable and I need to assign it to WML variable or WML table attribute like this:

<xsl:template match="content/table">
 <xsl:variable name="columnCount" select="count(columns/column"/>

  <table columns="$columnCount">
    <xsl:apply-templates select="row"/>
  </table>
 </xsl:template>

Is the above possible?

or

<xsl:template match="content/table">
 <xsl:variable name="columnCount" select="count(columns/column"/>

 <setvar name="cCount" value="$columnCount"/>
  <table columns="$cCount">
    <xsl:apply-templates select="row"/>
  </table>
 </xsl:template>

In both codes, all I want to do is getting the number of columns from xml as a variable and assign to wml table columns attribute.

Could anyone suggest me, how can I do it?

Thanking you very much in advance,

Best Regards,
Aruna.G




 
Old October 19th, 2007, 04:58 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You'll be wanting to use the <xsl:attribute> tag then.

Code:
<table>
  <xsl:attribute name="columns" select="$columnCount"/>
...
An alternative is to use Attribute Value Templates.

Code:
<table columns="{$columnCount}">
Note, in both cases you don't even need the temporary variable.

Code:
<table>
  <xsl:attribute name="columns" select="count(columns/column)"/>
...

/- Sam Judson : Wrox Technical Editor -/
 
Old October 19th, 2007, 05:15 AM
Authorized User
 
Join Date: Oct 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

  Thank you very much for your help. Its working!!!!!!!!!


Regards,
Aruna.G






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to assign a new value to Classic ASP variable mcinar Javascript How-To 4 April 14th, 2008 06:02 PM
Assign Session variable from view or controller Alaphat ASP.NET 2.0 Professional 2 April 11th, 2008 09:37 AM
assign javascript variable to asp variable manjunath_c_k Classic ASP Basics 1 September 14th, 2006 07:35 AM
assign a recordset to a variable biggen55 VB How-To 1 March 26th, 2004 02:26 PM





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