[ 
https://issues.apache.org/jira/browse/CAMEL-27881?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen updated CAMEL-27881:
--------------------------------
    Description: 
Found while improving the option descriptions of camel-saxon for CAMEL-23832 
(commit 
https://github.com/apache/camel/commit/85ea55b80e9f710e1c415febdbba3bc65915daea,
 pull request https://github.com/apache/camel/pull/31155).
These are separate problems of the component; the descriptions change only 
documents the current behavior.

h4. 1. staticQueryContext is always ignored
{{XQueryBuilder.init()}} always sets staticQueryContext = 
getConfiguration().newStaticQueryContext(), so a configured staticQueryContext 
is never used.
Proposed change: use the given one when set (it must come from the same Saxon 
Configuration), or deprecate the option.

h4. 2. The component moduleURIResolver overwrites the endpoint one
{{XQueryComponent.createEndpoint()}} calls 
answer.setModuleURIResolver(getModuleURIResolver()) after setProperties(), so 
an endpoint-level moduleURIResolver is replaced.
Proposed change: only set it when the endpoint has none.

h4. 3. resultsFormat=DOMSource gives a String
{{XQueryBuilder.evaluate()}} has no case for DOMSource and falls through to 
evaluateAsString; asDOMSource() has the same problem.
Proposed change: return new DOMSource(evaluateAsDOM(exchange)).

h4. 4. resultType List or Document fails
evaluate() checks resultType.isAssignableFrom(Collection.class / Node.class), 
so java.util.List and org.w3c.dom.Document throw IllegalArgumentException, 
while Object maps to List.
Proposed change: also accept List and the Node subtypes.

h4. 5. Numeric parameters are not typed
{{XQueryBuilder.getAsParameter()}} does not map Integer, Short, BigDecimal, 
Date and similar to Saxon atomic values; they become ObjectValue, so a query 
variable declared as xs:integer fails on an Integer header 
(ParameterDynamicTest shows the same for Boolean).
Proposed change: map Integer/Short/Byte to Int64Value and BigDecimal to 
BigDecimalValue.

h4. 6. The module resolver never falls back to Saxon
{{XQueryModuleURIResolver.resolve()}} returns an empty array instead of null 
when there are no location hints, so the standard Saxon resolver is not tried 
(not tested).
Proposed change: return null.


_Claude Code on behalf of davsclaus_

  was:
Found while improving the option descriptions of camel-saxon for CAMEL-23832 
(pull request https://github.com/apache/camel/pull/31155).
These are separate problems of the component; the descriptions change only 
documents the current behavior.

h4. 1. staticQueryContext is always ignored
{{XQueryBuilder.init()}} always sets staticQueryContext = 
getConfiguration().newStaticQueryContext(), so a configured staticQueryContext 
is never used.
Proposed change: use the given one when set (it must come from the same Saxon 
Configuration), or deprecate the option.

h4. 2. The component moduleURIResolver overwrites the endpoint one
{{XQueryComponent.createEndpoint()}} calls 
answer.setModuleURIResolver(getModuleURIResolver()) after setProperties(), so 
an endpoint-level moduleURIResolver is replaced.
Proposed change: only set it when the endpoint has none.

h4. 3. resultsFormat=DOMSource gives a String
{{XQueryBuilder.evaluate()}} has no case for DOMSource and falls through to 
evaluateAsString; asDOMSource() has the same problem.
Proposed change: return new DOMSource(evaluateAsDOM(exchange)).

h4. 4. resultType List or Document fails
evaluate() checks resultType.isAssignableFrom(Collection.class / Node.class), 
so java.util.List and org.w3c.dom.Document throw IllegalArgumentException, 
while Object maps to List.
Proposed change: also accept List and the Node subtypes.

h4. 5. Numeric parameters are not typed
{{XQueryBuilder.getAsParameter()}} does not map Integer, Short, BigDecimal, 
Date and similar to Saxon atomic values; they become ObjectValue, so a query 
variable declared as xs:integer fails on an Integer header 
(ParameterDynamicTest shows the same for Boolean).
Proposed change: map Integer/Short/Byte to Int64Value and BigDecimal to 
BigDecimalValue.

h4. 6. The module resolver never falls back to Saxon
{{XQueryModuleURIResolver.resolve()}} returns an empty array instead of null 
when there are no location hints, so the standard Saxon resolver is not tried 
(not tested).
Proposed change: return null.


_Claude Code on behalf of davsclaus_


> camel-saxon: xquery ignores staticQueryContext, resultsFormat=DOMSource gives 
> a String, resultType List/Document fail, numeric parameters are not typed
> -------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27881
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27881
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-saxon
>            Reporter: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.25.0
>
>
> Found while improving the option descriptions of camel-saxon for CAMEL-23832 
> (commit 
> https://github.com/apache/camel/commit/85ea55b80e9f710e1c415febdbba3bc65915daea,
>  pull request https://github.com/apache/camel/pull/31155).
> These are separate problems of the component; the descriptions change only 
> documents the current behavior.
> h4. 1. staticQueryContext is always ignored
> {{XQueryBuilder.init()}} always sets staticQueryContext = 
> getConfiguration().newStaticQueryContext(), so a configured 
> staticQueryContext is never used.
> Proposed change: use the given one when set (it must come from the same Saxon 
> Configuration), or deprecate the option.
> h4. 2. The component moduleURIResolver overwrites the endpoint one
> {{XQueryComponent.createEndpoint()}} calls 
> answer.setModuleURIResolver(getModuleURIResolver()) after setProperties(), so 
> an endpoint-level moduleURIResolver is replaced.
> Proposed change: only set it when the endpoint has none.
> h4. 3. resultsFormat=DOMSource gives a String
> {{XQueryBuilder.evaluate()}} has no case for DOMSource and falls through to 
> evaluateAsString; asDOMSource() has the same problem.
> Proposed change: return new DOMSource(evaluateAsDOM(exchange)).
> h4. 4. resultType List or Document fails
> evaluate() checks resultType.isAssignableFrom(Collection.class / Node.class), 
> so java.util.List and org.w3c.dom.Document throw IllegalArgumentException, 
> while Object maps to List.
> Proposed change: also accept List and the Node subtypes.
> h4. 5. Numeric parameters are not typed
> {{XQueryBuilder.getAsParameter()}} does not map Integer, Short, BigDecimal, 
> Date and similar to Saxon atomic values; they become ObjectValue, so a query 
> variable declared as xs:integer fails on an Integer header 
> (ParameterDynamicTest shows the same for Boolean).
> Proposed change: map Integer/Short/Byte to Int64Value and BigDecimal to 
> BigDecimalValue.
> h4. 6. The module resolver never falls back to Saxon
> {{XQueryModuleURIResolver.resolve()}} returns an empty array instead of null 
> when there are no location hints, so the standard Saxon resolver is not tried 
> (not tested).
> Proposed change: return null.
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to