This week's book giveaway is in the Testing forum.
We're giving away four copies of Practical Unit Testing with TestNG and Mockito and have Tomek Kaczanowski on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes error: param value not a node-set Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "error: param value not a node-set" Watch "error: param value not a node-set" New topic
Author

error: param value not a node-set

Scott Collens
Greenhorn

Joined: Jun 21, 2001
Posts: 20
Hi there,
I am new to the forum, but have been reading some posts and it look like a greta XML resource.
I have a question that I cannot seem to answer.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt" version="1.0">
<xsl utput method="html" media-type="text/html"/>
<xsl aram name="total"/>

<xsl:template match="/">
<html><body><table><xsl:apply-templates select="//TITLE"/></table></body></html>
</xsl:template>

<xsl:template match="TITLE">
<xsl:for-each select=".">
<tr><td><xsl:number/></td><td><xsl:value-of select="count ($total)"/></td></tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Using Saxon processor at the command prompt I am passing a an absolute path with a param value by typing
Saxon artists.xml artists.xsl total=/catalog/cd
and getting an error telling me that value of my parameter ($select) is not a node-set. If I add a default value to the param in the stylesheet, there is no problem, but when I try to pass one in externally , the error occurs.
What is my problem? Thanks in advance....Scott

Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
count() accept a node-set as a parameter, and when you pass something into stylesheet, it is passed as a string. There is no conversion from string to node-set so
<xsl:someElement select="$variable"...
gives an error.
Idiomatic workaround is:
<xsl:someElement select="*[name(.) = $variable]" ...
But I am not sure it will work when the path is included.
Another variant, recommended by Michael Kay, Saxon�s author, is to use evaluate() extension function which takes a string with an XPath expression and evaluates it.

Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
Scott Collens
Greenhorn

Joined: Jun 21, 2001
Posts: 20
Thanks Mapraputa, that saves me alot of time and frustration.
 
 
subject: error: param value not a node-set
 
Threads others viewed
PLEASE HELP ME!!Creating drop down list using XSL
xmlns and xsl
How to dynamically create or modify XSL
XSLT and embedded tags in text.
Using XSL to display XML
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com