You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by PAC Kieffer Guillaume <Gu...@panalpina.com> on 2012/06/12 15:46:51 UTC

XML message with file reference

Hi,

I am using CAMEL 2.9 with XML DSL and blueprint, I have a design question:

I am processing (routing ;) following xml: The XML contains a reference to a specific file.

<mymessage>
	<uri>
		<protocol>file</protocol>
		<path>/mydirectory/myfile.ext</path>
		<size/>
		.......
	</uri>
</mymessage>

The path element contains the path of a file I need to read; would something like this be possible:

<from uri="direct:incoming-msg">
	<transform>
		<xpath resultType="java.io.File">/mymessage/uri/path/text()</xpath>
	 </transform>
<to uri="direct:message-file"/>

A simple solution would be to transform the body inside a bean... but I would like to know if there is a pure XML DSL equivalent for that..

Thanks for your help,

Regards,
Guillaume.

RE: XML message with file reference

Posted by PAC Kieffer Guillaume <Gu...@panalpina.com>.
Hi Claus,

Thanks for the hint!! :)

Here is the solution:
<transform>
	<xpath resultType="java.lang.String">/mymessage/uri/path/text()</xpath>
</transform>
<transform>
	<simple resultType="java.io.File">${body}</simple>
</transform>

Regards,
Guillaume.

-----Original Message-----
From: Claus Ibsen [mailto:claus.ibsen@gmail.com] 
Sent: Tuesday, June 12, 2012 15:56
To: users@camel.apache.org
Subject: Re: XML message with file reference

On Tue, Jun 12, 2012 at 3:46 PM, PAC Kieffer Guillaume <
Guillaume.Kieffer@panalpina.com> wrote:

> Hi,
>
> I am using CAMEL 2.9 with XML DSL and blueprint, I have a design question:
>
> I am processing (routing ;) following xml: The XML contains a reference to
> a specific file.
>
> <mymessage>
>        <uri>
>                <protocol>file</protocol>
>                <path>/mydirectory/myfile.ext</path>
>                <size/>
>                .......
>        </uri>
> </mymessage>
>
> The path element contains the path of a file I need to read; would
> something like this be possible:
>
> <from uri="direct:incoming-msg">
>        <transform>
>                <xpath
> resultType="java.io.File">/mymessage/uri/path/text()</xpath>
>         </transform>
> <to uri="direct:message-file"/>
>
> A simple solution would be to transform the body inside a bean... but I
> would like to know if there is a pure XML DSL equivalent for that..
>
>
Yes I think that would be possible, as there is a String -> File type
converter. But that requires that the xpath expression with the /text()
will return a String instance, and not some w3c DOM / element object.



Thanks for your help,
>
> Regards,
> Guillaume.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: XML message with file reference

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jun 12, 2012 at 3:46 PM, PAC Kieffer Guillaume <
Guillaume.Kieffer@panalpina.com> wrote:

> Hi,
>
> I am using CAMEL 2.9 with XML DSL and blueprint, I have a design question:
>
> I am processing (routing ;) following xml: The XML contains a reference to
> a specific file.
>
> <mymessage>
>        <uri>
>                <protocol>file</protocol>
>                <path>/mydirectory/myfile.ext</path>
>                <size/>
>                .......
>        </uri>
> </mymessage>
>
> The path element contains the path of a file I need to read; would
> something like this be possible:
>
> <from uri="direct:incoming-msg">
>        <transform>
>                <xpath
> resultType="java.io.File">/mymessage/uri/path/text()</xpath>
>         </transform>
> <to uri="direct:message-file"/>
>
> A simple solution would be to transform the body inside a bean... but I
> would like to know if there is a pure XML DSL equivalent for that..
>
>
Yes I think that would be possible, as there is a String -> File type
converter. But that requires that the xpath expression with the /text()
will return a String instance, and not some w3c DOM / element object.



Thanks for your help,
>
> Regards,
> Guillaume.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen