You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by MichaelAtSAG <me...@gmail.com> on 2011/12/07 18:50:43 UTC
Equivalent expressions?
I want to obtain the string value of an XML element in the message. Are these
two Spring XML expressions functionality equivalent?
--Camel--
(1)
<setHeader headerName="SevtType1">
<xpath resultType="java.lang.String">/evt:Event/evt:Header/evt:Type</xpath>
</setHeader>
(2)
<setHeader headerName="SevtType2">
<xpath >/evt:Event/evt:Header/evt:Type/text()</xpath>
</setHeader>
--Velocity--
Event1 = '${headers.SevtType1}'.
Event2 = '${headers.SevtType2}'.
I receive different results when I reference them in velocity
--Velocity output--
(1) SevtType1 is Correct :
Event1 =
'{http://namespaces.softwareag.com/EDA/WebM/Sample/InventoryMgmt/1.0}PartInventoryShortage'
(2) SevtType2 is Incorrect:
Event2 =
'com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList@55e03a61'
--XML--
---<?xml version="1.0" encoding="UTF-8"?>
<evt:Event xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:evt="http://namespaces.softwareag.com/EDA/Event">
<evt:Header>
<evt:Type>{http://namespaces.softwareag.com/EDA/WebM/Sample/InventoryMgmt/1.0}PartInventoryShortage</evt:Type>
</evt:Header>
</evt:Event>
My root issue is that I want to obtain the local name of
'PartInventoryShortage', yet the functions do not appear to be working in
XPATH.
--
View this message in context: http://camel.465427.n5.nabble.com/Equivalent-expressions-tp5056482p5056482.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Equivalent expressions?
Posted by Claus Ibsen <cl...@gmail.com>.
When using <xpath> you are under the mercy what the XPathExpression
engine in the JDK returns as result.
And often it prefers to return a NODE type as the result.
That is why there is a resultType attribute you can configure as
String to tell Camel to convert the result to a String.
Which is often what you want to work with.
On Wed, Dec 7, 2011 at 6:50 PM, MichaelAtSAG <me...@gmail.com> wrote:
> I want to obtain the string value of an XML element in the message. Are these
> two Spring XML expressions functionality equivalent?
>
> --Camel--
> (1)
> <setHeader headerName="SevtType1">
> <xpath resultType="java.lang.String">/evt:Event/evt:Header/evt:Type</xpath>
> </setHeader>
>
> (2)
> <setHeader headerName="SevtType2">
> <xpath >/evt:Event/evt:Header/evt:Type/text()</xpath>
> </setHeader>
>
> --Velocity--
>
> Event1 = '${headers.SevtType1}'.
> Event2 = '${headers.SevtType2}'.
>
> I receive different results when I reference them in velocity
>
> --Velocity output--
> (1) SevtType1 is Correct :
> Event1 =
> '{http://namespaces.softwareag.com/EDA/WebM/Sample/InventoryMgmt/1.0}PartInventoryShortage'
>
> (2) SevtType2 is Incorrect:
> Event2 =
> 'com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList@55e03a61'
>
>
> --XML--
> ---<?xml version="1.0" encoding="UTF-8"?>
> <evt:Event xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:evt="http://namespaces.softwareag.com/EDA/Event">
> <evt:Header>
>
> <evt:Type>{http://namespaces.softwareag.com/EDA/WebM/Sample/InventoryMgmt/1.0}PartInventoryShortage</evt:Type>
> </evt:Header>
> </evt:Event>
>
>
> My root issue is that I want to obtain the local name of
> 'PartInventoryShortage', yet the functions do not appear to be working in
> XPATH.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Equivalent-expressions-tp5056482p5056482.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/