You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by bonnahu <bo...@gmail.com> on 2013/09/19 17:25:09 UTC

Is it possible to include XPath expression in simple expression?

Hi guys,
I am wondering whether there is a way to do something like below: 

<simple>${date:now:yyyyMMdd-HHmm}-incomingOrder-${@XPath("/order/@customerId")}-.xml</simple>



--
View this message in context: http://camel.465427.n5.nabble.com/Is-it-possible-to-include-XPath-expression-in-simple-expression-tp5739830.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Is it possible to include XPath expression in simple expression?

Posted by Christian Posta <ch...@gmail.com>.
Thx for the thoughts Claus. I can hack at some embedded xpath expression in
simple and see what it looks like


On Mon, Sep 23, 2013 at 8:24 AM, Claus Ibsen <cl...@gmail.com> wrote:

> Hi
>
> I do see value in having an xpath function in the simple language, as
> people are still doing alot of messaging with xml payloads.
>
> We could try experiment with adding the xpath function that supports
>
> xpath(xpathExp)
>
> Its the result type that could be tricky as xpath returns a NodeSet by
> default.
> I guess usually you want to grab a single element and have its value
> returned as a String, like grabbing an attribute or content of a node.
> Or evaluate it as a boolean.
>
> So we may need a 2nd parameter to indicate the result type of a value of
> - boolean
> - String
>
> xpath(xpathExp, resultType)
>
> And then there is the namespace mapping. Maybe we can have 3 parameter
> for optional namespace mappings, separated by comma
>
> xpath(xpathExp, resultType, "ns2=
> http://com.foo/wine,ns3=http://com.foo/beer")
>
> But as you can see this syntax is somewhat complicated and thus not so
> easy to implement and for end users to understand.
>
> Though XML and XPath are still often used. So it could be nice with an
> xpath function in the simple language.
>
> PS: For composite expression in Java you can use ExpressionBuilder and
> PredicateBuilder to combine them. So you can do it there.
>
>
>
> On Sat, Sep 21, 2013 at 9:29 AM, Claus Ibsen <cl...@gmail.com>
> wrote:
> > Hi
> >
> > Hold your horses ... Camels.
> >
> > It can get too confusing and complex syntax if you can inline any
> > other kind of languages in the simple language. Syntax parsers and
> > whatnot cannot validate and parse the other languages syntax etc. The
> > name of the language is simple, so lets try to keep it that way.
> >
> > Also with xpath there is the namepsace problem, and as well to define
> > a result type etc.
> >
> >
> >
> >
> >
> >
> > On Fri, Sep 20, 2013 at 11:39 PM, Christian Posta
> > <ch...@gmail.com> wrote:
> >> yah i like that. can you open a jira?
> >>
> >>
> >> On Fri, Sep 20, 2013 at 9:36 AM, Dale King <da...@gmail.com> wrote:
> >>
> >>> Perhaps adding language prefixes so that things like ${xpath:...} or
> >>> ${ognl:...} and similar would work.
> >>>
> >>>
> >>> On Fri, Sep 20, 2013 at 11:17 AM, bonnahu <bo...@gmail.com> wrote:
> >>>
> >>> > Hi Christian,
> >>> > I think it would be useful if we have such  "composite" expression.
> What
> >>> do
> >>> > you think?
> >>> >
> >>> >
> >>> >
> >>> > --
> >>> > View this message in context:
> >>> >
> >>>
> http://camel.465427.n5.nabble.com/Is-it-possible-to-include-XPath-expression-in-simple-expression-tp5739830p5739882.html
> >>> > Sent from the Camel - Users mailing list archive at Nabble.com.
> >>> >
> >>>
> >>>
> >>>
> >>> --
> >>> Dale King
> >>>
> >>
> >>
> >>
> >> --
> >> *Christian Posta*
> >> http://www.christianposta.com/blog
> >> twitter: @christianposta
> >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > Red Hat, Inc.
> > Email: cibsen@redhat.com
> > Twitter: davsclaus
> > Blog: http://davsclaus.com
> > Author of Camel in Action: http://www.manning.com/ibsen
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Re: Is it possible to include XPath expression in simple expression?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I do see value in having an xpath function in the simple language, as
people are still doing alot of messaging with xml payloads.

We could try experiment with adding the xpath function that supports

xpath(xpathExp)

Its the result type that could be tricky as xpath returns a NodeSet by default.
I guess usually you want to grab a single element and have its value
returned as a String, like grabbing an attribute or content of a node.
Or evaluate it as a boolean.

So we may need a 2nd parameter to indicate the result type of a value of
- boolean
- String

xpath(xpathExp, resultType)

And then there is the namespace mapping. Maybe we can have 3 parameter
for optional namespace mappings, separated by comma

xpath(xpathExp, resultType, "ns2=http://com.foo/wine,ns3=http://com.foo/beer")

But as you can see this syntax is somewhat complicated and thus not so
easy to implement and for end users to understand.

Though XML and XPath are still often used. So it could be nice with an
xpath function in the simple language.

PS: For composite expression in Java you can use ExpressionBuilder and
PredicateBuilder to combine them. So you can do it there.



On Sat, Sep 21, 2013 at 9:29 AM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> Hold your horses ... Camels.
>
> It can get too confusing and complex syntax if you can inline any
> other kind of languages in the simple language. Syntax parsers and
> whatnot cannot validate and parse the other languages syntax etc. The
> name of the language is simple, so lets try to keep it that way.
>
> Also with xpath there is the namepsace problem, and as well to define
> a result type etc.
>
>
>
>
>
>
> On Fri, Sep 20, 2013 at 11:39 PM, Christian Posta
> <ch...@gmail.com> wrote:
>> yah i like that. can you open a jira?
>>
>>
>> On Fri, Sep 20, 2013 at 9:36 AM, Dale King <da...@gmail.com> wrote:
>>
>>> Perhaps adding language prefixes so that things like ${xpath:...} or
>>> ${ognl:...} and similar would work.
>>>
>>>
>>> On Fri, Sep 20, 2013 at 11:17 AM, bonnahu <bo...@gmail.com> wrote:
>>>
>>> > Hi Christian,
>>> > I think it would be useful if we have such  "composite" expression. What
>>> do
>>> > you think?
>>> >
>>> >
>>> >
>>> > --
>>> > View this message in context:
>>> >
>>> http://camel.465427.n5.nabble.com/Is-it-possible-to-include-XPath-expression-in-simple-expression-tp5739830p5739882.html
>>> > Sent from the Camel - Users mailing list archive at Nabble.com.
>>> >
>>>
>>>
>>>
>>> --
>>> Dale King
>>>
>>
>>
>>
>> --
>> *Christian Posta*
>> http://www.christianposta.com/blog
>> twitter: @christianposta
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Is it possible to include XPath expression in simple expression?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Hold your horses ... Camels.

It can get too confusing and complex syntax if you can inline any
other kind of languages in the simple language. Syntax parsers and
whatnot cannot validate and parse the other languages syntax etc. The
name of the language is simple, so lets try to keep it that way.

Also with xpath there is the namepsace problem, and as well to define
a result type etc.






On Fri, Sep 20, 2013 at 11:39 PM, Christian Posta
<ch...@gmail.com> wrote:
> yah i like that. can you open a jira?
>
>
> On Fri, Sep 20, 2013 at 9:36 AM, Dale King <da...@gmail.com> wrote:
>
>> Perhaps adding language prefixes so that things like ${xpath:...} or
>> ${ognl:...} and similar would work.
>>
>>
>> On Fri, Sep 20, 2013 at 11:17 AM, bonnahu <bo...@gmail.com> wrote:
>>
>> > Hi Christian,
>> > I think it would be useful if we have such  "composite" expression. What
>> do
>> > you think?
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> >
>> http://camel.465427.n5.nabble.com/Is-it-possible-to-include-XPath-expression-in-simple-expression-tp5739830p5739882.html
>> > Sent from the Camel - Users mailing list archive at Nabble.com.
>> >
>>
>>
>>
>> --
>> Dale King
>>
>
>
>
> --
> *Christian Posta*
> http://www.christianposta.com/blog
> twitter: @christianposta



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Is it possible to include XPath expression in simple expression?

Posted by Christian Posta <ch...@gmail.com>.
yah i like that. can you open a jira?


On Fri, Sep 20, 2013 at 9:36 AM, Dale King <da...@gmail.com> wrote:

> Perhaps adding language prefixes so that things like ${xpath:...} or
> ${ognl:...} and similar would work.
>
>
> On Fri, Sep 20, 2013 at 11:17 AM, bonnahu <bo...@gmail.com> wrote:
>
> > Hi Christian,
> > I think it would be useful if we have such  "composite" expression. What
> do
> > you think?
> >
> >
> >
> > --
> > View this message in context:
> >
> http://camel.465427.n5.nabble.com/Is-it-possible-to-include-XPath-expression-in-simple-expression-tp5739830p5739882.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
> >
>
>
>
> --
> Dale King
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Re: Is it possible to include XPath expression in simple expression?

Posted by Dale King <da...@gmail.com>.
Perhaps adding language prefixes so that things like ${xpath:...} or
${ognl:...} and similar would work.


On Fri, Sep 20, 2013 at 11:17 AM, bonnahu <bo...@gmail.com> wrote:

> Hi Christian,
> I think it would be useful if we have such  "composite" expression. What do
> you think?
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Is-it-possible-to-include-XPath-expression-in-simple-expression-tp5739830p5739882.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Dale King

Re: Is it possible to include XPath expression in simple expression?

Posted by bonnahu <bo...@gmail.com>.
Hi Christian,
I think it would be useful if we have such  "composite" expression. What do
you think?  



--
View this message in context: http://camel.465427.n5.nabble.com/Is-it-possible-to-include-XPath-expression-in-simple-expression-tp5739830p5739882.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Is it possible to include XPath expression in simple expression?

Posted by Christian Posta <ch...@gmail.com>.
Does it make sense to have some kind of "composite" expression?


On Thu, Sep 19, 2013 at 12:06 PM, bonnahu <bo...@gmail.com> wrote:

> yeah, that is what I am doing now.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Is-it-possible-to-include-XPath-expression-in-simple-expression-tp5739830p5739838.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Re: Is it possible to include XPath expression in simple expression?

Posted by bonnahu <bo...@gmail.com>.
yeah, that is what I am doing now.



--
View this message in context: http://camel.465427.n5.nabble.com/Is-it-possible-to-include-XPath-expression-in-simple-expression-tp5739830p5739838.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Is it possible to include XPath expression in simple expression?

Posted by Dale King <da...@gmail.com>.
The way to do it is to set a header using the xpath and then use the
header's value in the simple expression.


On Thu, Sep 19, 2013 at 12:54 PM, Robert Simmons <kr...@gmail.com> wrote:

> You can use the scripts component and use xpath by itself.
>
> Sent from my iPad
>
> > On Sep 19, 2013, at 10:25 AM, bonnahu <bo...@gmail.com> wrote:
> >
> > Hi guys,
> > I am wondering whether there is a way to do something like below:
> >
> >
> <simple>${date:now:yyyyMMdd-HHmm}-incomingOrder-${@XPath("/order/@customerId")}-.xml</simple>
> >
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/Is-it-possible-to-include-XPath-expression-in-simple-expression-tp5739830.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Dale King

Re: Is it possible to include XPath expression in simple expression?

Posted by Robert Simmons <kr...@gmail.com>.
You can use the scripts component and use xpath by itself.

Sent from my iPad

> On Sep 19, 2013, at 10:25 AM, bonnahu <bo...@gmail.com> wrote:
> 
> Hi guys,
> I am wondering whether there is a way to do something like below: 
> 
> <simple>${date:now:yyyyMMdd-HHmm}-incomingOrder-${@XPath("/order/@customerId")}-.xml</simple>
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Is-it-possible-to-include-XPath-expression-in-simple-expression-tp5739830.html
> Sent from the Camel - Users mailing list archive at Nabble.com.