You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Sven Bauhan <sv...@ast.dfs.de> on 2013/08/26 14:39:59 UTC

JaxbDataFormat & escaping special characters

Hi,

as JAXB does not escape special characters when marshaling, there exists 
a solution to use a special EscapingXMLStreamWriter (see 
http://blog.lesc.se/2009/03/escape-illegal-characters-with-jaxb-xml.html). 
I used this in combination with 
org.apache.commons.lang.StringEscapeUtils to replace the strings.

But I do not know how to replace the XMLStreamWriter used by 
JaxbDataFormat with my implementation. Is there a way to tell the 
JaxbDataFormat to use my EscapingXMLStreamWriter when marshaling?

The only other solution I could image is to define a Converter for the 
data field and call it via the bindings.xjb. But that is just a workaround.

Thanks, Sven


Re: JaxbDataFormat & escaping special characters

Posted by Christian Posta <ch...@gmail.com>.
Sven,
Patch+Tests are attached. Please watch the JIRA for updates and when it
gets applied. Then let me know if this fits your usecase as a valid
solution.

Thanks,
Christian


On Wed, Aug 28, 2013 at 12:04 PM, Christian Posta <christian.posta@gmail.com
> wrote:

> BTW.. i've opened a JIRA for you:
>
> https://issues.apache.org/jira/browse/CAMEL-6677
>
>
> On Wed, Aug 28, 2013 at 10:01 AM, Christian Posta <
> christian.posta@gmail.com> wrote:
>
>> post your route to recreate if it's not working.
>>
>>
>> On Tue, Aug 27, 2013 at 4:36 AM, Sven Bauhan <sv...@ast.dfs.de> wrote:
>>
>>> On 08/26/13 16:43, Christian Posta wrote:
>>>
>>>> At the moment, there is a filtering writer that camel uses by default,
>>>> and
>>>> unfortunately it's not configurable at the moment. If you open a JIRA i
>>>> will get a patch for you to make it configurable.
>>>>
>>>>  Hey thanks. I will open a ticket in Jira. But I need a solution til
>>> the end of the week. So I think I have to create an own Dataformat
>>> definition as workaround now.
>>>
>>>  Hi,
>>>>>
>>>>> as JAXB does not escape special characters when marshaling, there
>>>>> exists a
>>>>> solution to use a special EscapingXMLStreamWriter (see
>>>>> http://blog.lesc.se/2009/03/****escape-illegal-characters-**<http://blog.lesc.se/2009/03/**escape-illegal-characters-**>
>>>>> with-jaxb-xml.html<http://**blog.lesc.se/2009/03/escape-**
>>>>> illegal-characters-with-jaxb-**xml.html<http://blog.lesc.se/2009/03/escape-illegal-characters-with-jaxb-xml.html>
>>>>> >).
>>>>> I used this in combination with org.apache.commons.lang.****
>>>>> StringEscapeUtils
>>>>>
>>>>> to replace the strings.
>>>>>
>>>>> But I do not know how to replace the XMLStreamWriter used by
>>>>> JaxbDataFormat with my implementation. Is there a way to tell the
>>>>> JaxbDataFormat to use my EscapingXMLStreamWriter when marshaling?
>>>>>
>>>>> The only other solution I could image is to define a Converter for the
>>>>> data field and call it via the bindings.xjb. But that is just a
>>>>> workaround.
>>>>>
>>>>>  Hmm this does not work. The converted string is escaped then twice
>>> with the result, that the '&' is replaced again by '&amp;'
>>>
>>>
>>
>>
>> --
>> *Christian Posta*
>> http://www.christianposta.com/blog
>> twitter: @christianposta
>>
>
>
>
> --
> *Christian Posta*
> http://www.christianposta.com/blog
> twitter: @christianposta
>



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

Re: JaxbDataFormat & escaping special characters

Posted by Christian Posta <ch...@gmail.com>.
BTW.. i've opened a JIRA for you:

https://issues.apache.org/jira/browse/CAMEL-6677


On Wed, Aug 28, 2013 at 10:01 AM, Christian Posta <christian.posta@gmail.com
> wrote:

> post your route to recreate if it's not working.
>
>
> On Tue, Aug 27, 2013 at 4:36 AM, Sven Bauhan <sv...@ast.dfs.de> wrote:
>
>> On 08/26/13 16:43, Christian Posta wrote:
>>
>>> At the moment, there is a filtering writer that camel uses by default,
>>> and
>>> unfortunately it's not configurable at the moment. If you open a JIRA i
>>> will get a patch for you to make it configurable.
>>>
>>>  Hey thanks. I will open a ticket in Jira. But I need a solution til the
>> end of the week. So I think I have to create an own Dataformat definition
>> as workaround now.
>>
>>  Hi,
>>>>
>>>> as JAXB does not escape special characters when marshaling, there
>>>> exists a
>>>> solution to use a special EscapingXMLStreamWriter (see
>>>> http://blog.lesc.se/2009/03/****escape-illegal-characters-**<http://blog.lesc.se/2009/03/**escape-illegal-characters-**>
>>>> with-jaxb-xml.html<http://**blog.lesc.se/2009/03/escape-**
>>>> illegal-characters-with-jaxb-**xml.html<http://blog.lesc.se/2009/03/escape-illegal-characters-with-jaxb-xml.html>
>>>> >).
>>>> I used this in combination with org.apache.commons.lang.****
>>>> StringEscapeUtils
>>>>
>>>> to replace the strings.
>>>>
>>>> But I do not know how to replace the XMLStreamWriter used by
>>>> JaxbDataFormat with my implementation. Is there a way to tell the
>>>> JaxbDataFormat to use my EscapingXMLStreamWriter when marshaling?
>>>>
>>>> The only other solution I could image is to define a Converter for the
>>>> data field and call it via the bindings.xjb. But that is just a
>>>> workaround.
>>>>
>>>>  Hmm this does not work. The converted string is escaped then twice
>> with the result, that the '&' is replaced again by '&amp;'
>>
>>
>
>
> --
> *Christian Posta*
> http://www.christianposta.com/blog
> twitter: @christianposta
>



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

Re: JaxbDataFormat & escaping special characters

Posted by Christian Posta <ch...@gmail.com>.
post your route to recreate if it's not working.


On Tue, Aug 27, 2013 at 4:36 AM, Sven Bauhan <sv...@ast.dfs.de> wrote:

> On 08/26/13 16:43, Christian Posta wrote:
>
>> At the moment, there is a filtering writer that camel uses by default, and
>> unfortunately it's not configurable at the moment. If you open a JIRA i
>> will get a patch for you to make it configurable.
>>
>>  Hey thanks. I will open a ticket in Jira. But I need a solution til the
> end of the week. So I think I have to create an own Dataformat definition
> as workaround now.
>
>  Hi,
>>>
>>> as JAXB does not escape special characters when marshaling, there exists
>>> a
>>> solution to use a special EscapingXMLStreamWriter (see
>>> http://blog.lesc.se/2009/03/****escape-illegal-characters-**<http://blog.lesc.se/2009/03/**escape-illegal-characters-**>
>>> with-jaxb-xml.html<http://**blog.lesc.se/2009/03/escape-**
>>> illegal-characters-with-jaxb-**xml.html<http://blog.lesc.se/2009/03/escape-illegal-characters-with-jaxb-xml.html>
>>> >).
>>> I used this in combination with org.apache.commons.lang.****
>>> StringEscapeUtils
>>>
>>> to replace the strings.
>>>
>>> But I do not know how to replace the XMLStreamWriter used by
>>> JaxbDataFormat with my implementation. Is there a way to tell the
>>> JaxbDataFormat to use my EscapingXMLStreamWriter when marshaling?
>>>
>>> The only other solution I could image is to define a Converter for the
>>> data field and call it via the bindings.xjb. But that is just a
>>> workaround.
>>>
>>>  Hmm this does not work. The converted string is escaped then twice with
> the result, that the '&' is replaced again by '&amp;'
>
>


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

Re: JaxbDataFormat & escaping special characters

Posted by Sven Bauhan <sv...@ast.dfs.de>.
On 08/26/13 16:43, Christian Posta wrote:
> At the moment, there is a filtering writer that camel uses by default, and
> unfortunately it's not configurable at the moment. If you open a JIRA i
> will get a patch for you to make it configurable.
>
Hey thanks. I will open a ticket in Jira. But I need a solution til the 
end of the week. So I think I have to create an own Dataformat 
definition as workaround now.

>> Hi,
>>
>> as JAXB does not escape special characters when marshaling, there exists a
>> solution to use a special EscapingXMLStreamWriter (see
>> http://blog.lesc.se/2009/03/**escape-illegal-characters-**
>> with-jaxb-xml.html<http://blog.lesc.se/2009/03/escape-illegal-characters-with-jaxb-xml.html>).
>> I used this in combination with org.apache.commons.lang.**StringEscapeUtils
>> to replace the strings.
>>
>> But I do not know how to replace the XMLStreamWriter used by
>> JaxbDataFormat with my implementation. Is there a way to tell the
>> JaxbDataFormat to use my EscapingXMLStreamWriter when marshaling?
>>
>> The only other solution I could image is to define a Converter for the
>> data field and call it via the bindings.xjb. But that is just a workaround.
>>
Hmm this does not work. The converted string is escaped then twice with 
the result, that the '&' is replaced again by '&amp;'


Re: JaxbDataFormat & escaping special characters

Posted by Christian Posta <ch...@gmail.com>.
At the moment, there is a filtering writer that camel uses by default, and
unfortunately it's not configurable at the moment. If you open a JIRA i
will get a patch for you to make it configurable.

Cheers,
Christian


On Mon, Aug 26, 2013 at 5:39 AM, Sven Bauhan <sv...@ast.dfs.de> wrote:

> Hi,
>
> as JAXB does not escape special characters when marshaling, there exists a
> solution to use a special EscapingXMLStreamWriter (see
> http://blog.lesc.se/2009/03/**escape-illegal-characters-**
> with-jaxb-xml.html<http://blog.lesc.se/2009/03/escape-illegal-characters-with-jaxb-xml.html>).
> I used this in combination with org.apache.commons.lang.**StringEscapeUtils
> to replace the strings.
>
> But I do not know how to replace the XMLStreamWriter used by
> JaxbDataFormat with my implementation. Is there a way to tell the
> JaxbDataFormat to use my EscapingXMLStreamWriter when marshaling?
>
> The only other solution I could image is to define a Converter for the
> data field and call it via the bindings.xjb. But that is just a workaround.
>
> Thanks, Sven
>
>


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