Re: Stacktrace when trying to use XPath

"Newman, John W" <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <D688C4D318A63D4290AA94A33E06F7D20275E22D0A@msxmbxnsprd14.acct.upmchs.net>
Nope, I do not have any problems with jaxen in particular.  I really don't know anything about it nor do I have plans to.  I was just reluctant to add yet another dependency to the project, especially when we are already using xalan for xpath in other places.  

But since that's what we needed to do for things to work, so be it.  It is working nicely now, what used to be a 40+ line recursive java method has been replaced by a simple xpath right in the template. =)  Lots of other places we can xpath from ftl as well.

I would like xalan to work but I don't have the time to checkout the projects and debug to see what is wrong.  On to more important things...

Thanks,
John

-----Original Message-----
From: Daniel Dekany [mailto:[email protected]] 
Sent: Thursday, September 03, 2009 2:26 PM
To: Newman, John W
Cc: FreeMarker-user
Subject: Re: [FreeMarker-user] Stacktrace when trying to use XPath

Thursday, September 3, 2009, 6:04:21 PM, Newman, John W wrote:

> Ok, I reluctantly added jaxen 1.1.1 to the classpath and also
> turned on NodeModel.useJaxenXPathSupport() and it is working nicely now.  =)
>  
> I first tried changing the xalan version to 2.7.1 but still no
> luck.  If anyone knows why this is happening and can advise so I can
> get rid of jaxen it would be great.

Out of curiosity, got any problem with Jaxen so you want get rid of
it?

> If not it's no big deal, I'm just curious as to why it won't work.
>
> Thanks,
> John
>  
> From: Newman, John W [mailto:[email protected]] 
> Sent: Thursday, September 03, 2009 10:13 AM
> To: FreeMarker-user
> Subject: [FreeMarker-user] Stacktrace when trying to use XPath
>  
> Hello,
>  
> We have instances of org.w3c.dom.Element in the data model.  I can
> use simple expressions like element.Child or element.@ID etc and all
> is working fine.  But if I try to use xpath, i.e.
> element["count(.//Child[./@flag=1])"] .. I get this stack trace everytime:
>  
> java.lang.RuntimeException: Could not resolve the node to a handle
>   at
> org.apache.xml.dtm.ref.DTMManagerDefault.getDTMHandleFromNode(DTMManagerDefault.java:556)
>   at
> org.apache.xpath.XPathContext.getDTMHandleFromNode(XPathContext.java:154)
>   at
> freemarker.ext.dom.XalanXPathSupport.executeQuery(XalanXPathSupport.java:108)
>   at freemarker.ext.dom.NodeModel.get(NodeModel.java:279) 
>   at freemarker.ext.dom.ElementModel.get(ElementModel.java:130) 
>   at
> freemarker.core.DynamicKeyName.dealWithStringKey(DynamicKeyName.java:136)
>  
> Looking around a bit I've seen one other person with this error
> message (not using freemarker), and it was due to the com.sun xalan
> being used.  You can see by the trace that we are using the real
> apache xalan, xalan-2.6.0.jar is on the classpath.  Is that the
> wrong version?  Any ideas what's happening and how I can fix this so we can use xpath?
>  
> Thanks,
> John
> ...

-- 
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.