[jdom-interest] XPath : unexpected exception

Frédéric Laurent fl at opikanoba.org
Tue Dec 16 07:42:38 PST 2003


Hello

According to the W3C XPath document [*]

substring("12345", -42, 1 div 0) returns "12345"

but the following test (in jython) fails

>>> from org.jdom import *
>>> from org.jdom.xpath import *
>>> xp = XPath.newInstance("substring('12345', -42, 1 div 0)")
>>> print xp.valueOf(Document())
Traceback (innermost last):
  File "<console>", line 1, in ?
java.lang.StringIndexOutOfBoundsException: String index out of range: -43
        at java.lang.String.substring(Unknown Source)
        at org.jaxen.function.SubstringFunction.evaluate
(SubstringFunction.java:140)
        at org.jaxen.function.SubstringFunction.call(SubstringFunction.java:91)
        at org.jaxen.expr.DefaultFunctionCallExpr.evaluate
(DefaultFunctionCallExpr.java:203)
        at org.jaxen.expr.DefaultXPathExpr.asList(DefaultXPathExpr.java:107)
        at org.jaxen.BaseXPath.selectNodesForContext(BaseXPath.java:716)
        at org.jaxen.BaseXPath.selectSingleNodeForContext(BaseXPath.java:739)
        at org.jaxen.BaseXPath.stringValueOf(BaseXPath.java:281)
        at org.jaxen.BaseXPath.valueOf(BaseXPath.java:274)
        at org.jdom.xpath.JaxenXPath.valueOf(JaxenXPath.java:185)


[*] http://www.w3.org/TR/xpath#function-substring

Should I report to jaxen ?

thanks

-- 
XPath free testing software :  http://lantern.sourceforge.net
Frédéric Laurent                     http://www.opikanoba.org



More information about the jdom-interest mailing list