0 Replies Latest reply: Sep 25, 2008 8:04 PM by 807589 RSS

    XPath and dom4j xs:date() conversion exception

    807589
      Hey all Java folks
      I'm having a hard time deadling with XPath and date datatype using dom4J and seeking for guidance :)
      Let say I have the following XML header:
      <site:Blog xmlns:site="http://xml.netbeans.org/schema/blog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="http://xml.netbeans.org/schema/blog blog.xsd">
      and this expression :
      site:Blog//site:Entry[@date=xs:date('2007-09-07')]
      In XMLSpy I do get correct results but in my java code all I get is this exception:
      org.dom4j.XPathException: Exception occurred evaluting XPath: /site:Blog//site:Entry[@date=xs:date("2007-09-07")] Exception: No Such Function xs:date
      at org.dom4j.xpath.DefaultXPath.handleJaxenException(DefaultXPath.java:374)
      at org.dom4j.xpath.DefaultXPath.selectNodes(DefaultXPath.java:134)
      at org.dom4j.tree.AbstractNode.selectNodes(AbstractNode.java:166)
      at com.mor.blogengine.util.xpath.SearchEngine.getEntriesforDate(SearchEngine.java:142)
      at com.mor.blogengine.util.xpath.SearchEngineTest.testGetEntriesforDate(SearchEngineTest.java:120)
      Does anyone has a clue of why it works perfectly outside of JAVA but not within my code ?

      Any enlightenment is welcome! :)

      Laurent