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.
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="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
posted
0
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.