Search

XSL does not compile when and only I use xalan:evaluate.

Setting in system properties

sysProps.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.xsltc.trax.SmartTransformerFactoryImpl");

XSLT snippet

<xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:xalan="http://xml.apache.org/xalan" exclude-result-prefixes="xalan">

<xsl:template name="my_test_template">
<xsl:param name="my_test_param" />

<xsl:if test="xalan:evaluate($my_test_param)">
some statements
</xsl:if>

<xsl:if test="not(xalan:evaluate($my_test_param))">
some statements
</xsl:if>

</xsl:template>

ERROR LOG

ERROR:  'Cannot find external method 'org.apache.xalan.lib.Extensions.evaluate' (must be public).'
2015-04-14 08:19:52,509 XslTransform ERROR> Error creating 16 template, will skip compile and use interpretive mode instead
javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
    at org.apache.xalan.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:832)
    at org.apache.xalan.xsltc.trax.SmartTransformerFactoryImpl.newTemplates(SmartTransformerFactoryImpl.java:319)

You could try using exslt with the dyn-prefix instead of xalan e. g.

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

and in your templates:

<xsl:when test="dyn:evaluate(concat('/data/description/entry/text-', $lang, '/text()'))">

Hi Thank you for your support. I tried as you suggest but i am getting the below error.

ERROR: 'The first argument to the non-static Java function 'evaluate' is not a valid object reference.' FATAL ERROR: 'Could not compile stylesheet'

Error creating 16 template, will skip compile and use interpretive mode instead javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet at org.apache.xalan.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:832) at org.apache.xalan.xsltc.trax.SmartTransformerFactoryImpl.newTemplates(SmartTransformerFactoryImpl.java:319)

gokulak, if you need help using XSLT with Java then you will have to look elsewhere. This forum is for Symphony CMS, a PHP-based content management system.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details