ERROR: 'The first argument to the non-static Java function 'evaluate' is not a valid object reference.' when using TrasformFactory

RBY picture RBY · Oct 14, 2010 · Viewed 8.6k times · Source

I am trying to transform an xsl + xml to xml (for later on transforming it into a pdf using FOP library). The JDK I am using is 1.5, and there is no way I can use another (that is what the company I work in is using). I read that the xalan jar of java 1.5 is the one responsible for the error. The text that causes the error is:

"dyn:evaluate($xpath)"/>

in:

  <xsl:variable name="paramName" select="@name"/>
    <xsl:variable name="xpath"
      select="concat('/doc/data/',$paramName)" /> 
      <fo:inline>
        <xsl:value-of select="dyn:evaluate($xpath)"/>
      </fo:inline>
    </xsl:template>

is there a way arround it without changing the jar? Is there a way to write it differently? or am I using the wrong syntax?

Thanks for your help

Answer

Mads Hansen picture Mads Hansen · Oct 16, 2010

evaluate() is an EXSLT extension function. It is non-standard, but many XSLT processors, including xalan, support it.

Have you declared the dyn namespace prefix in your stylesheet, so that it correctly references the EXSLT dynamic namespace?

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:dyn="http://exslt.org/dynamic"
                extension-element-prefixes="dyn">

...

</xsl:stylesheet>