XSLT xmlXPathCompOpEval: function new not found

I am trying to execute my xsl file and getting an error which says function new not found.

Command to execute my xsl: xsltproc GetRequestTransformation.xsl xsltTest.xml

Whenever I try to execute the above command in my Linux machine, I get the below error :

compilation error: file GetRequestTransformation.xsl line 5 element stylesheet
xsl:version: only 1.0 features are supported
xmlXPathCompOpEval: function new not found
XPath error : Unregistered function
xmlXPathCompOpEval: parameter error
runtime error: file GetRequestTransformation.xsl line 15 element variable
Failed to evaluate the expression of variable 'currentDate'.

Here is my XSLT file GetRequestTransformation.xsl :

    <?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet version='2.0'
        xmlns:java="http://xml.apache.org/xslt/java" xmlns:SimpleDateFormat="java.text.SimpleDateFormat"
        xmlns:Date="java.util.Date" exclude-result-prefixes="java SimpleDateFormat Date">
        <xsl:template match="/">
                <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:max="http://www.ibm.com/maximo">
                                    <xsl:variable name="affectedFinish" select='/tTroubleticket/alarms/tTroubleticketalarm/clearDate' />
                                    <xsl:variable name="affectedStart" select='/tTroubleticket/alarms/tTroubleticketalarm/activationDate' />
                                    <xsl:variable name="currentDate" select="SimpleDateFormat:format(SimpleDateFormat:new('yyyy-MM-dd HH:mm:ss'), Date:new() />
                                        <xsl:when test="$affectedFinish != null">
                                            <xsl:value-of select="$affectedFinish - $affectedStart" />
                                            <xsl:value-of select="$currentDate - $affectedStart" />

Mapping XML file xsltTest.xml:

                <activationDate>2015-04-01 12:42:22.0</activationDate>

Could you please try to find out the issue with my xsl file. Am I missing anything before I execute that command? How can I fix it?


The Java extension function mechanism you’re trying to use is specific to the Xalan Java XSLT processor and will not work in xsltproc (which is not written in Java). If you want to execute this stylesheet from the command line you will need to download Xalan and run its command line tool

java -cp xalan.jar:serializer.jar org.apache.xalan.xslt.Process -XSL GetRequestTransformation.xsl -IN xsltTest.xml

Leave a Reply

Your email address will not be published. Required fields are marked *