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 June 8th, 2008, 09:18 AM
Authorized User
 
Join Date: Jun 2008
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default Variable or parameter twice within the same temp

I am getting a error when viewing my xml document in ie 7. The error states "variable or parameter cannot be defined twice within the same template". I understand the error and know exactly where it's error out at. However, I am trying to redisplay the value or information at the bottom of the xslt to show a summary of the document. Is there a way I can redisplay the parameter or variable without getting this error?

Thanks!

 
Old June 8th, 2008, 09:28 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

You can certainly insert the value of the same variable twice or even more times with e.g.
Code:
<xsl:value-of select="$varname"/>
<xsl:value-of select="$varname"/>
The error message sounds more as if you define the same variable twice in the same template with xsl:variable or xsl:param.

--
  Martin Honnen
  Microsoft MVP - XML
 
Old June 8th, 2008, 09:34 AM
Authorized User
 
Join Date: Jun 2008
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You are correct, I did define it twice within the same template. I wanted to perform the same function again. I thought I needed to define or copy the same variable & parameter again. If I call the parameter for a second time is it done the same way as the variable.

Thanks!

 
Old June 9th, 2008, 01:19 PM
Authorized User
 
Join Date: Jun 2008
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is a sample of what I am running into.

XSLT version 2.0


The variable below is defined at the beginning of my document. I need to create a summary of the values at the bottom of the document and call the same variable again. How can I fit this into my current code? I can type it all out, but I wanted to use the variable.

Thanks!



<xsl:variable name="patientRole" select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole"/>




<tr>
<td width='50%' valign="top"><xsl:call-template name="getName">
<xsl:with-param name="name" select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:patient/n1:name"/>
</xsl:call-template>


<xsl:if test="$patientRole/n1:addr">
<xsl:call-template name="getAddress">
<xsl:with-param name="addr" select="$patientRole/n1:addr"/>
</xsl:call-template>
</xsl:if>


<xsl:if test="$patientRole/n1:telecom">
<xsl:call-template name="getTelecom">
<xsl:with-param name="telecom" select="$patientRole/n1:telecom"/>
</xsl:call-template>
</xsl:if>
</td>

 
Old June 9th, 2008, 02:29 PM
Authorized User
 
Join Date: Jun 2008
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Figured it out.

Changed variable to patientRole2 and this allowed me to use it for a second time.

Thanks!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Use Temp Table Variable in Stored Procedure rweide SQL Server ASP 2 April 15th, 2011 03:50 PM
UPDATE PARAMETER OR VARIABLE pallone XSLT 4 September 9th, 2006 05:33 PM
XSL Variable and/or Parameter Question ripple XSLT 9 September 1st, 2006 12:16 PM
How to Swap two integers without temp variable ramk_1978 C# 2 February 28th, 2006 08:03 PM
How to Store Literal Value in Variable/Parameter kwilliams XSLT 5 August 31st, 2005 08:52 AM





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