xerces-j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sridhar veerappan <sriasa...@gmail.com>
Subject Exception in thread "main" javax.xml.transform.TransformerException: Could not find function: if
Date Mon, 17 Aug 2009 06:45:47 GMT
Hi,
I am getting parsing error in xpath transformation


String s = "if (/blah/text()!='') then blah/text() else ''";
XPathExpression expression = xpath.compile(s);

Object o = expression.evaluate(target, XPathConstants.NODESET);

I am using normal core java and xml packages to parse
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathFactory;

import org.w3c.dom.Document;
import org.w3c.dom.Node;

import org.w3c.dom.NodeList;


Exception:
Exception in thread "main" javax.xml.transform.TransformerException: Could
not find function: if
    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.error(XPathParser.java:602)

    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.FunctionCall(XPathParser.java:1449)
    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.PrimaryExpr(XPathParser.java:1388)
    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.FilterExpr(XPathParser.java:1287)

    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.PathExpr(XPathParser.java:1220)
    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.UnionExpr(XPathParser.java:1178)
    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.UnaryExpr(XPathParser.java:1084)

    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.MultiplicativeExpr(XPathParser.java:1005)
    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.AdditiveExpr(XPathParser.java:947)
    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.RelationalExpr(XPathParser.java:872)

    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.EqualityExpr(XPathParser.java:812)
    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.AndExpr(XPathParser.java:776)
    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.OrExpr(XPathParser.java:749)

    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.Expr(XPathParser.java:732)
    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.initXPath(XPathParser.java:125)
    at com.sun.org.apache.xpath.internal.XPath.<init>(XPath.java:162)

    at com.sun.org.apache.xpath.internal.XPath.<init>(XPath.java:198)
    at
com.sun.org.apache.xpath.internal.jaxp.XPathImpl.compile(XPathImpl.java:394)
    at demo.hw.client.XPathTest.xpathTest(XPathTest.java:35)

    at demo.hw.client.XPathTest.main(XPathTest.java:64)
--------------- linked to ------------------
javax.xml.xpath.XPathExpressionException
    at
com.sun.org.apache.xpath.internal.jaxp.XPathImpl.compile(XPathImpl.java:402)

    at demo.hw.client.XPathTest.xpathTest(XPathTest.java:35)
    at demo.hw.client.XPathTest.main(XPathTest.java:64)
Caused by: javax.xml.transform.TransformerException: Could not find
function: if
    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.error(XPathParser.java:602)

    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.FunctionCall(XPathParser.java:1449)
    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.PrimaryExpr(XPathParser.java:1388)
    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.FilterExpr(XPathParser.java:1287)

    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.PathExpr(XPathParser.java:1220)
    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.UnionExpr(XPathParser.java:1178)
    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.UnaryExpr(XPathParser.java:1084)

    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.MultiplicativeExpr(XPathParser.java:1005)
    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.AdditiveExpr(XPathParser.java:947)
    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.RelationalExpr(XPathParser.java:872)

    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.EqualityExpr(XPathParser.java:812)
    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.AndExpr(XPathParser.java:776)
    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.OrExpr(XPathParser.java:749)

    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.Expr(XPathParser.java:732)
    at
com.sun.org.apache.xpath.internal.compiler.XPathParser.initXPath(XPathParser.java:125)
    at com.sun.org.apache.xpath.internal.XPath.<init>(XPath.java:162)

    at com.sun.org.apache.xpath.internal.XPath.<init>(XPath.java:198)
    at
com.sun.org.apache.xpath.internal.jaxp.XPathImpl.compile(XPathImpl.java:394)
    ... 2 more


Thanks
Sri

Mime
View raw message