setHeader via xslt

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

setHeader via xslt

jpcook01
Hi,

Is it possible to set the value of a header via the result of an xslt transform eg)

.setHeader(INITIAL_DATA_HEADER, XsltBuilder.xslt(
            new File("myXslt.xslt")))

Currently this doesn't not compile as setHeader expects String, String. I tried using toString but that just gives me back XSLT[net.sf.saxon.PreparedStylesheet@775121 as per objects implementation.

I also tried outputString() but that doesn't actually return a String.

There doesn't appear to be anything like convertBodyTo(String.class) but surely this must be possible?

Thanks
Jonathan
Reply | Threaded
Open this post in threaded view
|

Re: setHeader via xslt

Claus Ibsen-2
XsltBuilder work on the exchange body only and as such it will affect
your body, and I assume this is not what you want.

You can do you own custom XSLT transformation and set it on the header
as a result to avoid affecting your body payload.



On Mon, Aug 3, 2009 at 12:45 PM, jpcook<[hidden email]> wrote:

>
> Hi,
>
> Is it possible to set the value of a header via the result of an xslt
> transform eg)
>
> .setHeader(INITIAL_DATA_HEADER, XsltBuilder.xslt(
>                        new File("myXslt.xslt")))
>
> Currently this doesn't not compile as setHeader expects String, String. I
> tried using toString but that just gives me back
> XSLT[net.sf.saxon.PreparedStylesheet@775121 as per objects implementation.
>
> I also tried outputString() but that doesn't actually return a String.
>
> There doesn't appear to be anything like convertBodyTo(String.class) but
> surely this must be possible?
>
> Thanks
> Jonathan
> --
> View this message in context: http://www.nabble.com/setHeader-via-xslt-tp24788622p24788622.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Reply | Threaded
Open this post in threaded view
|

Re: setHeader via xslt

jpcook01
Hi,

Yes i created a XsltToHeaderProcessor - If you like I can create a jira and attach a patch if you think it would be useful for other people?

Thanks

Claus Ibsen-2 wrote
XsltBuilder work on the exchange body only and as such it will affect
your body, and I assume this is not what you want.

You can do you own custom XSLT transformation and set it on the header
as a result to avoid affecting your body payload.



On Mon, Aug 3, 2009 at 12:45 PM, jpcook<jonathan.cook@erars.plus.com> wrote:
>
> Hi,
>
> Is it possible to set the value of a header via the result of an xslt
> transform eg)
>
> .setHeader(INITIAL_DATA_HEADER, XsltBuilder.xslt(
>                        new File("myXslt.xslt")))
>
> Currently this doesn't not compile as setHeader expects String, String. I
> tried using toString but that just gives me back
> XSLT[net.sf.saxon.PreparedStylesheet@775121 as per objects implementation.
>
> I also tried outputString() but that doesn't actually return a String.
>
> There doesn't appear to be anything like convertBodyTo(String.class) but
> surely this must be possible?
>
> Thanks
> Jonathan
> --
> View this message in context: http://www.nabble.com/setHeader-via-xslt-tp24788622p24788622.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Reply | Threaded
Open this post in threaded view
|

Re: setHeader via xslt

Claus Ibsen-2
On Mon, Aug 3, 2009 at 2:30 PM, jpcook<[hidden email]> wrote:
>
> Hi,
>
> Yes i created a XsltToHeaderProcessor - If you like I can create a jira and
> attach a patch if you think it would be useful for other people?
>
Great yeah that would be a nice addition.
And what is better than support for real life use cases.

We love contributions in the Camel community.
http://camel.apache.org/contributing.html





> Thanks
>
>
> Claus Ibsen-2 wrote:
>>
>> XsltBuilder work on the exchange body only and as such it will affect
>> your body, and I assume this is not what you want.
>>
>> You can do you own custom XSLT transformation and set it on the header
>> as a result to avoid affecting your body payload.
>>
>>
>>
>> On Mon, Aug 3, 2009 at 12:45 PM, jpcook<[hidden email]>
>> wrote:
>>>
>>> Hi,
>>>
>>> Is it possible to set the value of a header via the result of an xslt
>>> transform eg)
>>>
>>> .setHeader(INITIAL_DATA_HEADER, XsltBuilder.xslt(
>>>                        new File("myXslt.xslt")))
>>>
>>> Currently this doesn't not compile as setHeader expects String, String. I
>>> tried using toString but that just gives me back
>>> XSLT[net.sf.saxon.PreparedStylesheet@775121 as per objects
>>> implementation.
>>>
>>> I also tried outputString() but that doesn't actually return a String.
>>>
>>> There doesn't appear to be anything like convertBodyTo(String.class) but
>>> surely this must be possible?
>>>
>>> Thanks
>>> Jonathan
>>> --
>>> View this message in context:
>>> http://www.nabble.com/setHeader-via-xslt-tp24788622p24788622.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://www.nabble.com/setHeader-via-xslt-tp24788622p24789911.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus