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 April 30th, 2008, 01:55 PM
Registered User
 
Join Date: Apr 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default How can I take variable value in for loop

Hi,

    I'm trying to take variable value in for loop but it's not working for me. My code is like this

<xsl:variable name="xTag" select="xxxx" />

<xsl:for-each select="$xTag">
 ......
 ......
</xsl:for-each>

I'm getting this error:
Reference to variable or parameter 'xTag' must evaluate to a node list.


Thanks In Advance
 
Old April 30th, 2008, 02:08 PM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Hi,

You say the error is "Reference to variable or parameter 'xTag' must evaluate to a node list" however your post does not show any input XML and your variable says to select="xxxx".

I would suggest to post some XML and the what you are trying to select in your variable.

HTH




 
Old April 30th, 2008, 02:19 PM
Registered User
 
Join Date: Apr 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

My XML is

     <rowhead title="Name" tag="rowhead/Result/five">
     <Result>
     <five>
        <row id="1" name="NA" />
        <row id="1" name="NA" />
     </five>
     </Result>
     </rowhead>

     In XSL Page i need to take the tag in for loop like this

     <xsl:variable name="xTag" select="rowhead/@tag" />

     <xsl:for-each select="$xTag">
         ......
         ......
     </xsl:for-each>

     but i'm getting error when i run the page.

     Thanks for help.
 
Old May 1st, 2008, 06:17 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You appear to be trying to evaluate the XPath contained in @tag. This is not possible in standard XSLT without using an extension such as saxon:evaluate or a scripted function in Microsoft's offerings. However the error message seems odd as the variable does contain anode-set.

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamic session variable in while loop ashuphp Beginning PHP 0 May 3rd, 2007 04:59 AM
XSL Loop and incrementing a variable 2007-03-29 XSLT 8 March 30th, 2007 10:41 AM
ASSIGNING A JAVA SCRIPT VARIABLE TO A XSL VARIABLE SOMANATHAN10 XSLT 1 February 21st, 2007 04:26 AM
To iterate the FOR loop variable garg.ashish15 Oracle 0 November 10th, 2006 09:31 AM
nested while loop doesn't loop hosefo81 PHP Databases 5 November 12th, 2003 08:46 AM





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