You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "raulvk.soa" <ra...@gmail.com> on 2008/09/18 15:22:11 UTC

Headers in XSLT

Hi,

How can I access the headers of a message from XSLT?
Basically, I am validating a message against an XML Schema, and when the
validation fails, I want to generate a specific XML response message that
should contain:
   - the in message
   - the description of the error
   - timestamp

The in message and the timestamp are not a problem, whereas I see that the
error description is stored in the message header
"org.apache.camel.processor.DeadLetterChannel.FAILURE_HANDLED". Thus, I need
to extract the content of that header from within the XSLT.

Any clues?

Thanks.


-- 
View this message in context: http://www.nabble.com/Headers-in-XSLT-tp19552778s22882p19552778.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Headers in XSLT

Posted by James Strachan <ja...@gmail.com>.
BTW I raised a JIRA to document the XPath/XSLT/XQuery use of
parameters/methods/namespaces for accessing headers and properties etc
https://issues.apache.org/activemq/browse/CAMEL-918

2008/9/18 raulvk.soa <ra...@gmail.com>:
>
> Nevermind. By exploring the source code I found out that the XsltComponent
> actually sets all headers and properties as input parameters on the
> underlying Xslt Transformer.
>
> Just to share my findings: all you have to do is find out the name of the
> Exchange property or Message header you want to use within your XSLT and
> declare it as an <xsl:param> at the top of your XSL file. This will allow
> you to use it as any other standard variable inside the XSLT file.
>
> Just a caveat, while exploring the source code, I found out that if there
> are two properties/headers with the same name (even if one is a header and
> the other one is a property), the one that is processed second will NOT be
> inserted as a parameter on the Transformer and will be ignored.
>
> Perhaps this logic should be modified to avoid possible misinterpretations
> and unintended behaviour. A possible solution is to prefix properties with
> the string "property." and headers with "header.", before adding them to the
> parameters Hashtable.
>
> By doing this, properties and headers would be living in separate symbol
> spaces and they would not clash.
>
> What are your thoughts on this?
>
>
> raulvk.soa wrote:
>>
>> Sorry, apparently its not a header, but a Property, according to the logs.
>>
>>
>>
>> raulvk.soa wrote:
>>>
>>> Hi,
>>>
>>> How can I access the headers of a message from XSLT?
>>> Basically, I am validating a message against an XML Schema, and when the
>>> validation fails, I want to generate a specific XML response message that
>>> should contain:
>>>    - the in message
>>>    - the description of the error
>>>    - timestamp
>>>
>>> The in message and the timestamp are not a problem, whereas I see that
>>> the error description is stored in the message header
>>> "org.apache.camel.processor.DeadLetterChannel.FAILURE_HANDLED". Thus, I
>>> need to extract the content of that header from within the XSLT.
>>>
>>> Any clues?
>>>
>>> Thanks.
>>>
>>>
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Headers-in-XSLT-tp19552778s22882p19556970.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

RE: Headers in XSLT

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

Please feel free to create a ticket with your findings. 

Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: raulvk.soa [mailto:raulvk.soa@gmail.com] 
Sent: 18. september 2008 18:37
To: camel-user@activemq.apache.org
Subject: Re: Headers in XSLT


Nevermind. By exploring the source code I found out that the XsltComponent
actually sets all headers and properties as input parameters on the
underlying Xslt Transformer.

Just to share my findings: all you have to do is find out the name of the
Exchange property or Message header you want to use within your XSLT and
declare it as an <xsl:param> at the top of your XSL file. This will allow
you to use it as any other standard variable inside the XSLT file.

Just a caveat, while exploring the source code, I found out that if there
are two properties/headers with the same name (even if one is a header and
the other one is a property), the one that is processed second will NOT be
inserted as a parameter on the Transformer and will be ignored.

Perhaps this logic should be modified to avoid possible misinterpretations
and unintended behaviour. A possible solution is to prefix properties with
the string "property." and headers with "header.", before adding them to the
parameters Hashtable.

By doing this, properties and headers would be living in separate symbol
spaces and they would not clash.

What are your thoughts on this?


raulvk.soa wrote:
> 
> Sorry, apparently its not a header, but a Property, according to the logs.
> 
> 
> 
> raulvk.soa wrote:
>> 
>> Hi,
>> 
>> How can I access the headers of a message from XSLT?
>> Basically, I am validating a message against an XML Schema, and when the
>> validation fails, I want to generate a specific XML response message that
>> should contain:
>>    - the in message
>>    - the description of the error
>>    - timestamp
>> 
>> The in message and the timestamp are not a problem, whereas I see that
>> the error description is stored in the message header
>> "org.apache.camel.processor.DeadLetterChannel.FAILURE_HANDLED". Thus, I
>> need to extract the content of that header from within the XSLT.
>> 
>> Any clues?
>> 
>> Thanks.
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Headers-in-XSLT-tp19552778s22882p19556970.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Headers in XSLT

Posted by "raulvk.soa" <ra...@gmail.com>.
Nevermind. By exploring the source code I found out that the XsltComponent
actually sets all headers and properties as input parameters on the
underlying Xslt Transformer.

Just to share my findings: all you have to do is find out the name of the
Exchange property or Message header you want to use within your XSLT and
declare it as an <xsl:param> at the top of your XSL file. This will allow
you to use it as any other standard variable inside the XSLT file.

Just a caveat, while exploring the source code, I found out that if there
are two properties/headers with the same name (even if one is a header and
the other one is a property), the one that is processed second will NOT be
inserted as a parameter on the Transformer and will be ignored.

Perhaps this logic should be modified to avoid possible misinterpretations
and unintended behaviour. A possible solution is to prefix properties with
the string "property." and headers with "header.", before adding them to the
parameters Hashtable.

By doing this, properties and headers would be living in separate symbol
spaces and they would not clash.

What are your thoughts on this?


raulvk.soa wrote:
> 
> Sorry, apparently its not a header, but a Property, according to the logs.
> 
> 
> 
> raulvk.soa wrote:
>> 
>> Hi,
>> 
>> How can I access the headers of a message from XSLT?
>> Basically, I am validating a message against an XML Schema, and when the
>> validation fails, I want to generate a specific XML response message that
>> should contain:
>>    - the in message
>>    - the description of the error
>>    - timestamp
>> 
>> The in message and the timestamp are not a problem, whereas I see that
>> the error description is stored in the message header
>> "org.apache.camel.processor.DeadLetterChannel.FAILURE_HANDLED". Thus, I
>> need to extract the content of that header from within the XSLT.
>> 
>> Any clues?
>> 
>> Thanks.
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Headers-in-XSLT-tp19552778s22882p19556970.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Headers in XSLT

Posted by "raulvk.soa" <ra...@gmail.com>.
Sorry, apparently its not a header, but a Property, according to the logs.



raulvk.soa wrote:
> 
> Hi,
> 
> How can I access the headers of a message from XSLT?
> Basically, I am validating a message against an XML Schema, and when the
> validation fails, I want to generate a specific XML response message that
> should contain:
>    - the in message
>    - the description of the error
>    - timestamp
> 
> The in message and the timestamp are not a problem, whereas I see that the
> error description is stored in the message header
> "org.apache.camel.processor.DeadLetterChannel.FAILURE_HANDLED". Thus, I
> need to extract the content of that header from within the XSLT.
> 
> Any clues?
> 
> Thanks.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Headers-in-XSLT-tp19552778s22882p19552805.html
Sent from the Camel - Users mailing list archive at Nabble.com.