This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Using parameter with xsl:for-each


I did check the archives, the closest thing I was able to find was:

passing a parameter to select attribute of <xsl:sort>
(http://www.mulberrytech.com/xsl/xsl-list/archive/msg14124.html)

but this does not seem to apply to my situation.
Maybe somebody can point me a little bit more precisely?

-Max


----Original Message Follows----
From: David Carlisle <davidc@nag.co.uk>
To: xsl-list@mulberrytech.com
CC: mrubinst@hotmail.com
Subject: Re: Using parameter with xsl:for-each
Date: Tue, 27 Jun 2000 14:47:57 +0100 (BST)

This is a faq, you can't in standard xsl evaluate a string as an xpath
expresion. Check the archives of this list.

 > "Reference to a variable or parameter "selectpath" must evaluate to a 
node
 > list."

you have <xsl:value-of select="$selectpath"/>

but you passed it a string: "Resources/Resource"

so it is equivalent to

<xsl:value-of select="'Resources/Resource'"/>

David

-------------------------------------------------------------------
Hi,

I am trying to use a parameter in the select attribute of xsl:for-each.  
Here is my stylesheet:

<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
version="1.0">
  	<xsl:param name="selectpath" />

  	<xsl:template match="/">
		<p><xsl:value-of select="$selectpath"/></p>
  		<xsl:for-each select="$selectpath">
			<xsl:value-of select="."/>
  		</xsl:for-each>
  	</xsl:template>

</xsl:stylesheet>

Here is my xml source:
<Resources>
	<Resource URL="http://www.aspindustry.org/">
		<Keywords>
			<ASP/> <SB/>
		</Keywords>
	</Resource>
	<Resource URL="http://www.aspnews.com/" >
		<Keywords>
			<ASP/>
		</Keywords>
	</Resource>
</Resources>

When I try to invoke the stylesheet passing "Resources/Resource" as a 
parameter (using MSXML May 2000), I get the following error:

"Reference to a variable or parameter "selectpath" must evaluate to a node 
list."

But, if I remove "xsl:for-each" clause, I do see the output of 
"xsl:value-of" that shows that my parameter was passed successfully
to the stylesheet.

Any help would be appreciated.

-Max


________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]