You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by ol...@ubs.com on 2012/11/21 15:27:27 UTC

Using CXF with Saxon 9.4

Hi guys,

Just joined this mailing list and I have a question:

We are using CXF WebServices in our project web module running on
Tomcat.
Now we have Saxon 6.5.5 library in our project dependecies, but we are
going to use Saxon 9.4 to get benefit of using XSLT2.0. 
The problem is that it seams CXF framework doesn't work with Saxon 9.4
library (error soap response with a message inside it saying can't cast
Arraylist to a nodelist), 
because:
Saxon has taken to XSLT 2.0 and XPath 2.0 implementation. In 9.4 the
library goes on to override the default namespace for Xpath to a Saxon
implementation, this wasn't done in 6.x version. The issue is mainly
centered around the implementation of "xpath.evaluate(expression,
inputSource, XPathConstants.NODESET);".
If the InputSource passed is a org.xml.sax.InputSource then an ArrayList
(of TinyElementImpl) is returned back. If the InputSource is a Document,
only then it returns a NodeList which most of the callers expect.
Michael Kay (person who wrote Saxon) says in his blog post the reason
behind this change.
It seams CXF expects a NodeList return type that's why XML -->Java
-->XML marshalling is impacted.

Does anyone know some workaround to make CXF work with Saxon 9.4, 
except hacking classpath to inject lets say Xalan library to be picked
up before Saxon library to satisfy CXF framework?  

Thank you,
Oleg

RE: Using CXF with Saxon 9.4

Posted by Andrei Shakirin <as...@talend.com>.
Could you provide stack trace from the service?
Perhaps it is possible to fix CXF in a way to support both evaluate() versions. Patch is welcome.
Actually I see only workaround with endorsed/classpath hack for Xalan.

Cheers,
Andrei.

From: oleg.tsal-tsalko@ubs.com [mailto:oleg.tsal-tsalko@ubs.com]
Sent: Mittwoch, 21. November 2012 15:27
To: users@cxf.apache.org
Subject: Using CXF with Saxon 9.4


Hi guys,

Just joined this mailing list and I have a question:

We are using CXF WebServices in our project web module running on Tomcat.
Now we have Saxon 6.5.5 library in our project dependecies, but we are going to use Saxon 9.4 to get benefit of using XSLT2.0.

The problem is that it seams CXF framework doesn't work with Saxon 9.4 library (error soap response with a message inside it saying can't cast Arraylist to a nodelist),

because:
Saxon has taken to XSLT 2.0 and XPath 2.0 implementation. In 9.4 the library goes on to override the default namespace for Xpath to a Saxon implementation, this wasn't done in 6.x version. The issue is mainly centered around the implementation of "xpath.evaluate(expression, inputSource, XPathConstants.NODESET);".

If the InputSource passed is a org.xml.sax.InputSource then an ArrayList (of TinyElementImpl) is returned back. If the InputSource is a Document, only then it returns a NodeList which most of the callers expect. Michael Kay (person who wrote Saxon) says in his blog post the reason behind this change.

It seams CXF expects a NodeList return type that's why XML -->Java -->XML marshalling is impacted.

Does anyone know some workaround to make CXF work with Saxon 9.4,
except hacking classpath to inject lets say Xalan library to be picked up before Saxon library to satisfy CXF framework?

Thank you,
Oleg

Re: Using CXF with Saxon 9.4

Posted by Daniel Kulp <dk...@apache.org>.
On Nov 21, 2012, at 9:27 AM, oleg.tsal-tsalko@ubs.com wrote:
> 
> We are using CXF WebServices in our project web module running on Tomcat. 
> Now we have Saxon 6.5.5 library in our project dependecies, but we are going to use Saxon 9.4 to get benefit of using XSLT2.0.
> 
> The problem is that it seams CXF framework doesn’t work with Saxon 9.4 library (error soap response with a message inside it saying can't cast Arraylist to a nodelist),
> 
> because: 
> Saxon has taken to XSLT 2.0 and XPath 2.0 implementation. In 9.4 the library goes on to override the default namespace for Xpath to a Saxon implementation, this wasn't done in 6.x version. The issue is mainly centered around the implementation of "xpath.evaluate(expression, inputSource, XPathConstants.NODESET);".
> 
> If the InputSource passed is a org.xml.sax.InputSource then an ArrayList (of TinyElementImpl) is returned back. If the InputSource is a Document, only then it returns a NodeList which most of the callers expect. Michael Kay (person who wrote Saxon) says in his blog post the reason behind this change.

Well, I would consider this behavior completely wrong.   The javadoc for XPathConstants.NODESET specifically says this is mapped to NodeList.    Thus, he's violating the specs and the contract for that return type.  If he created his own QName "SaxonConstants.ARRAYLIST" or something, I'd be 100% for that, but violating a spec is just a bad idea to me.


> It seams CXF expects a NodeList return type that’s why XML -->Java -->XML marshalling is impacted.

Well, the spec says it should be a NodeList, so why shouldn't we expect it?

> Does anyone know some workaround to make CXF work with Saxon 9.4, 
> except hacking classpath to inject lets say Xalan library to be picked up before Saxon library to satisfy CXF framework? 

If you can provide some stack traces and such in the areas that don't work, we might be able to provide some workarounds or hacks or something.   Wrappering an ArrayList with something that implements NodeList is relatively simple.


-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com