You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Thomas Auzinger <xs...@excite.com> on 2000/10/27 21:10:54 UTC

problem with evaluate($rtf, $exp)

I tried to use the evaluate function as presented in the latest code drop,
using a modified "nodeset" example, applying an xpath to a nodeset obtained
from a variable, one time straight from the stylesheet and once via an
expresssion stored in a variable. Maybe I'm doing something wrong, but I
think that the output of both variations should be the same. In the
following output it isn't:
Command line:

C:\XalanJ2\sandbox>java org.apache.xalan.xslt.Process -in eval.xml -xsl
eval.xslt

XML output:
-----------

<?xml version="1.0" encoding="UTF-8"?>
<out>
<these_are_the_nodes_from_the_nodeset_function>
<elem2a>
                                        ELEMENT2A
                                </elem2a>,
                </these_are_the_nodes_from_the_nodeset_function>
<these_are_the_nodes_from_the_evaluate_function/>
</out>

XSLT stylesheet eval.xslt:
--------------------------

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
                xmlns:xalan="http://xml.apache.org/xalan"
                exclude-result-prefixes="xalan">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> 
<xsl:template match="/">
  <out>
	<xsl:variable name="rtf">
	      <docelem>
		     <elem1>
				<elem1a>
					ELEMENT1A
				</elem1a>
				<elem1b>
					,ELEMENT1B
				</elem1b>
		      </elem1>
		      <elem2>
				<elem2a>
					ELEMENT2A
				</elem2a>
			</elem2>
      	</docelem>
	</xsl:variable>     

	<xsl:element name="these_are_the_nodes_from_the_nodeset_function">
		<xsl:for-each select="xalan:nodeset($rtf)//elem2a"> 
			<xsl:copy-of select="."/>,
		</xsl:for-each>
	</xsl:element>


	<xsl:variable name="exp" select="'//elem2a'"/>
	<xsl:element name="these_are_the_nodes_from_the_evaluate_function">
		<xsl:for-each select="xalan:evaluate(xalan:nodeset($rtf),$exp)"> 
			<xsl:copy-of select="."/>,
		</xsl:for-each>
	</xsl:element>

</out>
</xsl:template> 
</xsl:stylesheet>

dummy xml file eval.xml:
------------------------
<?xml version="1.0"?>
<top/>

Any help is greatly appreciated.

Thanks,

Thomas





_______________________________________________________
Say Bye to Slow Internet!
http://www.home.com/xinbox/signup.html


Re: problem with evaluate($rtf, $exp)

Posted by Gary L Peskin <ga...@firstech.com>.
Thomas Auzinger wrote:
> 
> I tried to use the evaluate function as presented in the latest code drop,
> using a modified "nodeset" example, applying an xpath to a nodeset obtained
> from a variable, one time straight from the stylesheet and once via an
> expresssion stored in a variable. Maybe I'm doing something wrong, but I
> think that the output of both variations should be the same. In the
> following output it isn't:

Thomas --

The evaluate function only takes a single argument.  This is a string
representation of an XPath that is evaluated against the current node
just as if the XPath representation (//elem2a) was coded in the select
attribute value in place of the xalan:evaluate function.

Through a bug in the new extension mechanism, this wrong number of
arguments was not detected.  I am investigating and will upload a code
correction as soon as I've identified and tested it.

Thanks,
Gary