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 July 11th, 2008, 10:32 AM
Authorized User
 
Join Date: Jul 2008
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default what is use of "$variable name" ?

Hi ,
    for the below code

<xsl:template match="DataSet">

  <xsl:param name="{RowSpan}"/>

  <td rowspan="Rowspan">

      <xsl:value-of select="$RowSpan"/>
      <xsl:apply-templates select="./Data"/>
  </td>

</xsl:template>


i am receiving the value of rowspan as a parameter , while displaying it using "$" sign within Tag , it is showing the proper value, if we remove the "$" sign it is not showing the value. can please any one clarify me on this? why this happens ? what is the use of "$" sign"?

Venki
__________________
Venki
 
Old July 11th, 2008, 10:50 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

This is a syntax error:

<xsl:param name="{RowSpan}"/>

You should only use curly braces when embedding an XPath expression in the literal value of an attribute.

Within an XPath expression, whenever you refer to a variable, you must prefix it with a $ sign. This is to distinguish it from an element name. select="$rowspan" gets the value of the rowspan variable, while select="rowspan" gets the value of a child <rowspan> element of the context node.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old July 11th, 2008, 11:00 AM
Authorized User
 
Join Date: Jul 2008
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you, Now i am clear with usage of "$" ,it is used when we refer the value of the variables right. Then how do i make the variable value to know HTML TD tag.
I tried the following code, but that rowspan value doesn't takes effect.

<xsl:template match="DataSet">

  <xsl:param name="RowSpan"/>

  <td rowspan="{Rowspan}">

      <xsl:value-of select="$RowSpan"/>
      <xsl:apply-templates select="./Data"/>
  </td>

</xsl:template>

Venki
 
Old July 11th, 2008, 11:08 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

It is not clear what you want to achieve.
If you want to use the parameter named RowSpan in your attribute value template for the rowspan attribute value then you need
Code:
<td rowspan="{$RowSpan}">
--
  Martin Honnen
  Microsoft MVP - XML
 
Old July 11th, 2008, 11:15 AM
Authorized User
 
Join Date: Jul 2008
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i am receiving the rowspan value as a parameter in the name "RowSpan" , I want to pass this value to the Td tag for rowspan attribute,
   i tried the code you said, the code i used is below

<xsl:template match="DataSet">

  <xsl:param name="RowSpan"/>

  <td rowspan="{$Rowspan}">

      <xsl:value-of select="$RowSpan"/>
      <xsl:apply-templates select="./Data"/>
  </td>

</xsl:template>

this shows the following error:

A reference to variable or parameter 'Rowspan' cannot be resolved. The variable or parameter may not be defined, or it may ...


Also i give the code from this DataSet template is called

<xsl:apply-templates select="$listNodes/DataSet">
                  <xsl:with-param name="RowSpan">

                  <xsl:call-template name="CalcRowSpan">
                     <xsl:with-param name="nodeList" select="$listNodes/Instance"/>
                  </xsl:call-template>

                  </xsl:with-param>
</xsl:apply-templates>

Venki
 
Old July 11th, 2008, 11:19 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Well check the spelling, 'RowSpan' is different from 'Rowspan'.

--
  Martin Honnen
  Microsoft MVP - XML
 
Old July 11th, 2008, 11:20 AM
Authorized User
 
Join Date: Jul 2008
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi ,
 I myself realized the mistake i made and corrected, that works perfectly as i need.
the mistake i made is related to Cases as shown below
<td rowspan="{$Rowspan}"> instead of <td rowspan="{$RowSpan}">

thank you all very much for their kind replies.



Venki
 
Old July 11th, 2008, 11:23 AM
Authorized User
 
Join Date: Jul 2008
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Martin Honnen
 Well check the spelling, 'RowSpan' is different from 'Rowspan'.

--
  Martin Honnen
  Microsoft MVP - XML
yes martin, just now realized . Corrected now. Thank you very much Martin for spotting my error. That works good now. :D

Venki
 
Old July 11th, 2008, 11:25 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Can't see anything obviously wrong with the code you've shown us. That usually means the error is in the code you haven't shown us. (Or sometimes it means that you were running different code from the code you thought you were running...)

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old July 11th, 2008, 11:30 AM
Authorized User
 
Join Date: Jul 2008
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by mhkay
 Can't see anything obviously wrong with the code you've shown us. That usually means the error is in the code you haven't shown us. (Or sometimes it means that you were running different code from the code you thought you were running...)

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Sorry Michale,Yaa.. I realize my mistake, i will correct myself while posting the topics in future.

Venki





Similar Threads
Thread Thread Starter Forum Replies Last Post
Object variable or With block variable not set haidee_mccaffrey Classic ASP Professional 5 March 8th, 2007 03:34 PM
ASSIGNING A JAVA SCRIPT VARIABLE TO A XSL VARIABLE SOMANATHAN10 XSLT 1 February 21st, 2007 04:26 AM
object variable or with block variable not set Aoude BOOK: Beginning VB.NET Databases 1 February 24th, 2006 05:21 PM
Object variable or With block variable not set tparrish Pro VB Databases 1 May 25th, 2005 02:08 PM
Object variable or with block variable not set spacy ASP.NET 1.x and 2.0 Application Design 0 September 21st, 2004 12:19 AM





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