You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Chris Wolf <cw...@gmail.com> on 2013/04/02 17:01:40 UTC

Is the result of this builder reusable? XQueryBuilder.xquery("//foo");

I want to perform an XQuery outside of DSL (in a Processor).  Something like:

 XQueryBuilder hostXQ = XQueryBuilder
    .xquery("//remote[remoteId/@value='CBOE34']/server/@value");
 String host = hostXQ.evaluateAsString(exchange);

Second question is can I parameterize the XQuery like so:

 XQueryBuilder hostXQ = XQueryBuilder
    .xquery("//remote[remoteId/@value=$accountId]/server/@value");

        hostXQ.setParameters(new HashMap<String, Object>() {{
                put("accountId", "CBOE34");}});
        String host1 = hostXQ.evaluateAsString(exchange);

        hostXQ.setParameters(new HashMap<String, Object>() {{
            put("accountId", "CBOE78");}});
        String host2 = hostXQ.evaluateAsString(exchange);


Thanks,


Chris

Re: Is the result of this builder reusable? XQueryBuilder.xquery("//foo");

Posted by Chris Wolf <cw...@gmail.com>.
Thanks Willem - that worked.

On Tue, Apr 2, 2013 at 10:33 PM, Willem jiang <wi...@gmail.com> wrote:
> I think you can use the XQueryBuilder in the Processor just like you showed.
> If you want to call the evaluateAsString multiple times, you need to make sure the message body is reread able.
> You can convert the message body into String before you process it in your processor.
>
>
> --
> Willem Jiang
>
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Web: http://www.fusesource.com | http://www.redhat.com
> Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
>           http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
> Twitter: willemjiang
> Weibo: 姜宁willem
>
>
>
>
> On Tuesday, April 2, 2013 at 11:01 PM, Chris Wolf wrote:
>
>> I want to perform an XQuery outside of DSL (in a Processor). Something like:
>>
>> XQueryBuilder hostXQ = XQueryBuilder
>> .xquery("//remote[remoteId/@value='CBOE34']/server/@value");
>> String host = hostXQ.evaluateAsString(exchange);
>>
>> Second question is can I parameterize the XQuery like so:
>>
>> XQueryBuilder hostXQ = XQueryBuilder
>> .xquery("//remote[remoteId/@value=$accountId]/server/@value");
>>
>> hostXQ.setParameters(new HashMap<String, Object>() {{
>> put("accountId", "CBOE34");}});
>> String host1 = hostXQ.evaluateAsString(exchange);
>>
>> hostXQ.setParameters(new HashMap<String, Object>() {{
>> put("accountId", "CBOE78");}});
>> String host2 = hostXQ.evaluateAsString(exchange);
>>
>>
>> Thanks,
>>
>>
>> Chris
>
>

Re: Is the result of this builder reusable? XQueryBuilder.xquery("//foo");

Posted by Willem jiang <wi...@gmail.com>.
I think you can use the XQueryBuilder in the Processor just like you showed.
If you want to call the evaluateAsString multiple times, you need to make sure the message body is reread able.  
You can convert the message body into String before you process it in your processor.


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem




On Tuesday, April 2, 2013 at 11:01 PM, Chris Wolf wrote:

> I want to perform an XQuery outside of DSL (in a Processor). Something like:
>  
> XQueryBuilder hostXQ = XQueryBuilder
> .xquery("//remote[remoteId/@value='CBOE34']/server/@value");
> String host = hostXQ.evaluateAsString(exchange);
>  
> Second question is can I parameterize the XQuery like so:
>  
> XQueryBuilder hostXQ = XQueryBuilder
> .xquery("//remote[remoteId/@value=$accountId]/server/@value");
>  
> hostXQ.setParameters(new HashMap<String, Object>() {{
> put("accountId", "CBOE34");}});
> String host1 = hostXQ.evaluateAsString(exchange);
>  
> hostXQ.setParameters(new HashMap<String, Object>() {{
> put("accountId", "CBOE78");}});
> String host2 = hostXQ.evaluateAsString(exchange);
>  
>  
> Thanks,
>  
>  
> Chris