I am performing an XML-XML transformation using Smooks with the help of the freemarker configuration template.
However, when my input XML has escaped characters like
<Retail>H&M</Retail>
the transformed output XML will only have
<Retail>H&M</Retail>
The escaping is removed, which makes the output XML invalid.
How can i resolve this?
This is my freemarker template
<?xml version="1.0"?>
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd">
<params>
<param name="stream.filter.type">SAX</param>
<param name="default.serialization.on">false</param>
</params>
<resource-config
selector="combinedResponse">
<resource>org.milyn.delivery.DomModelCreator</resource>
</resource-config>
<ftl:freemarker applyOnElement="combinedResponse">
<ftl:template><!--
<BODY>
<Retail>${combinedResponse.Retail}</Retail>
</BODY>
-->
</ftl:template>
</ftl:freemarker>
See Freemarker's auto-escaping, you can override it by adding the following header:
<#ftl output_format="XML">
the output format of a template can be enforced in the the ftl header
If it's not working try to add
<#ftl output_format="XML" auto_esc=true>
If escaping doesn't happen after adding the above ftl header, then <#ftl output_format="XML" auto_esc=true> might helps (and that means that FreeMarker was configured to use "disable" auto-escaping policy, which is generally not recommended).