Raul Kripalani created CAMEL-5403:
-------------------------------------
Summary: Type converter for NodeList with size 1 to Node
Key: CAMEL-5403
URL: https://issues.apache.org/jira/browse/CAMEL-5403
Project: Camel
Issue Type: New Feature
Components: camel-core
Affects Versions: 2.8.0
Reporter: Raul Kripalani
In many cases, Xerces will return transformation results as a NodeList of size
1 even though the XPath evaluation only yields one element during runtime.
{code}
<transform>
<xpath>/child::node()[local-name() = 'ABC']</xpath>
</transform>
{code}
(that XPath is capable of matching multiple elements - but let's assume only
one is matched)
When applying an XPath choice afterwards, it is easy to come across this error:
{code}
java.lang.ClassCastException: org.apache.xml.dtm.ref.DTMNodeList cannot be cast
to org.w3c.dom.Node
at
org.apache.xpath.jaxp.XPathExpressionImpl.eval(XPathExpressionImpl.java:121)[:]
at
org.apache.xpath.jaxp.XPathExpressionImpl.eval(XPathExpressionImpl.java:99)[:]
at
org.apache.xpath.jaxp.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:184)[:]
at
org.apache.camel.builder.xml.XPathBuilder.doInEvaluateAs(XPathBuilder.java:676)[88:org.apache.camel.camel-core:2.8.0.fuse-03-06]
at
org.apache.camel.builder.xml.XPathBuilder.evaluateAs(XPathBuilder.java:640)[88:org.apache.camel.camel-core:2.8.0.fuse-03-06]
at
org.apache.camel.builder.xml.XPathBuilder.matches(XPathBuilder.java:132)[88:org.apache.camel.camel-core:2.8.0.fuse-03-06]
at
org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:65)[88:org.apache.camel.camel-core:2.8.0.fuse-03-06]
[...]
{code}
To make the out-of-the-box experience smoother, I propose adding a little type
converter that converts from NodeList => Node when the size of the former is 1.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira