On Wed, Mar 18, 2015 at 10:49 AM, mtod <m...@thetods.net> wrote:
>  INFO | Created default XPathFactory
> com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@343985bd
>  INFO | Creating new XPath expression in pool. Namespaces on XPath
> expression: [me: {system ->
> http://camel.apache.org/xml/variables/system-properties},{env ->
> http://camel.apache.org/xml/variables/environment-variables},{in ->
> http://camel.apache.org/xml/in/},{function ->
> http://camel.apache.org/xml/function/},{out ->
> http://camel.apache.org/xml/out/}]
>  INFO | Namespaces discovered in message:
> {xmlns:km=[http://xsdrepo.foundationmedicine.com/messaging/esb],
> xmlns:xsi=[http://www.w3.org/2001/XMLSchema-instance],
> xmlns:bm=[http://xsdrepo-dev.foundationmedicine.com/messaging/esbbamevent]}.

Taking a look at this:

http://camel.apache.org/maven/current/camel-core/apidocs/src-html/org/apache/camel/builder/xml/XPathBuilder.html

the order of operations appears to be

protected Object evaluateAs(Exchange exchange, QName resultQName) {
...
xpathExpression = createXPathExpression();
...
logNamespaces(exchange);
...
}

where createXPathExpression() logs:

LOG.trace("Creating new XPath expression in pool. Namespaces on XPath
expression: {}", getNamespaceContext().toString());

before calling:

xPath.setNamespaceContext(getNamespaceContext());

and that getNamespaceContext() result does not appear to contain your namespace.

whereas logNamespaces(Exchange exchange) builds one of:

answer = (NodeList) xpathExpression.evaluate(inputSource,
XPathConstants.NODESET);
answer = (NodeList) xpathExpression.evaluate(source.getNode(),
XPathConstants.NODESET);
answer = (NodeList) xpathExpression.evaluate(document, XPathConstants.NODESET);

based on the input type and then calls

logDiscoveredNamespaces(answer)

which iterates over answer and apparently *does* contain your namespace.

I would suspect this is a bug in what getNamespaceContext() is returning...


Jim

Reply via email to