4

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

jasso
  • 13,736
  • 2
  • 36
  • 50
RBY
  • 101
  • 1
  • 2
  • 3

1 Answers1

2

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>
Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
  • Sorry to resuscitate this dead thread; I have the same issue. Declaring the namespace correctly does not resolve the issue FWIW. – Laird Nelson Mar 25 '15 at 17:58
  • @Laird Nelson - I just (re)verified that it works for me. Do you get an error, or just not producing the result you expect? Double check that you also have `extension-element-prefixes="dyn"` and that your XPath expression is correct. Maybe post a small example and ask as a question to get a second pair of eyes? – Mads Hansen Mar 25 '15 at 23:16
  • 2
    The issue is that the default implementation of `javax.xml.transform.TransformerFactory` produces a `Transformer` that under the covers uses the Xalan XSLTC _compiler_, not _interpreter_, and `dyn` in this case is not supported. See https://xalan.apache.org/xalan-j/extensions_xsltc.html#exslt_ext. – Laird Nelson Mar 26 '15 at 22:06