[ 
https://issues.apache.org/jira/browse/CAMEL-10653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15773435#comment-15773435
 ] 

Nikolay Voskresenskiy commented on CAMEL-10653:
-----------------------------------------------

The external variables thing is not a feature of saxon library, it is a common 
feature of XQuery 1.0 specification, and also documented at 
http://camel.apache.org/xquery.html. The same test passes in camel 2.17.4

I believe the issue was caused by upgrade to saxon 9.7.

In Camel 2.17 the following code is responsible for this functionality in 
XQueryBuilder class:
{code}
    protected void addParameters(DynamicQueryContext dynamicQueryContext, 
Map<String, Object> map, String parameterPrefix) {
        Set<Map.Entry<String, Object>> propertyEntries = map.entrySet();
        for (Map.Entry<String, Object> entry : propertyEntries) {
            dynamicQueryContext.setParameter(parameterPrefix + entry.getKey(), 
entry.getValue());
        }
    }
{code}

In camel 2.18 it is now:
{code}
    protected void addParameters(DynamicQueryContext dynamicQueryContext, 
Map<String, Object> map, String parameterPrefix) {
        Set<Map.Entry<String, Object>> propertyEntries = map.entrySet();
        for (Map.Entry<String, Object> entry : propertyEntries) {
            dynamicQueryContext.setParameter(
                StructuredQName.fromClarkName(parameterPrefix + entry.getKey()),
                new ObjectValue(entry.getValue())
            );
        }
    }
{code}
Which apparently doesn't work, it seems the value container needs to be one of 
the subtypes for net.sf.saxon.value.AtomicValue. And no, external variable 
declaration is not a deprecated feature, it is part of core xquery 
specification and supported by all popular processors including saxon.

Anyway, this is a regression compared to camel 2.17, and either needs to be 
fixed, or the documentation on camel-xquery needs to be updated accordingly


> XQuery support broken in Camel 2.18.x
> -------------------------------------
>
>                 Key: CAMEL-10653
>                 URL: https://issues.apache.org/jira/browse/CAMEL-10653
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-saxon
>    Affects Versions: 2.18.0, 2.18.1
>            Reporter: Nikolay Voskresenskiy
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.18.2, 2.19.0
>
>         Attachments: camel-xquery-test.zip
>
>
> The camel xquery support no longer works correctly as of 2.18.x
> I identified two main issues so far:
> # A java.lang.NullPointerException is thrown when exchange contains any null 
> headers or properties:
> {code}
> java.lang.NullPointerException: External object cannot wrap a Java null
>       at net.sf.saxon.value.ObjectValue.<init>(ObjectValue.java:55)
>       at 
> org.apache.camel.component.xquery.XQueryBuilder.addParameters(XQueryBuilder.java:640)
> {code}
> # An error in execution whenever a header or a property are referenced in the 
> xquery as an external variable:
> {code}
> java.lang.AssertionError: Unknown event
>       at 
> net.sf.saxon.evpull.ComplexContentProcessor.advance(ComplexContentProcessor.java:198)
> {code}
> Attached is a maven project with junit test illustrating the issues.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to