Skip to main content
Question

XMLTemplater Outputs Character Entity References


I am using an XMLTemplater to output XML. In FME 2011, the XML comes out with literal less-then, greater-than tags, that is:

 

 

   <StreetTree TreeID="2919">

 

However, in FME 2015, the XML comes out with character entity references, that is:

 

   &lt;StreetTree TreeID="2919"&gt;

 

 

The XML reader in FME 2015 does not understand the character entity references. Is there a way to tell FME to output the literal less-than / greater-than characters?

 

 

Thanks

 

 

10 replies

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • September 30, 2015
Hi,

 

 

I was not able to reproduce the same result as yours.

 

The XMLTemplater in FME 2015.1.2.1 creates a correct XML text:

 

<root><StreetTree TreeID="2919"/></root>

 

 

from this template expression:

 

<root>{fme:get-xml-attribute("element")}</root>

 

 

when "element" attribute has '<StreetTree TreeID="2919"/>'.

 

 

Check if the FME XQuery function you are using in your expression is correct.

 

 

Takashi

  • September 30, 2015
Actually the XMLTemplater is working correctly as you have confirmed. The problem is in the next transformer, which is an aggregator. The data source is street trees, and they are aggregated by neighbourhood. When they come out of the aggregator, the character entity references appear.

 

 

I have "fixed" the problem by doing a string replace on &lt; to < and &gt; to > after they come out of the aggregator. Thanks for looking into this.

mark2atsafe
Safer
Forum|alt.badge.img+43
  • Safer
  • December 30, 2015
jimo wrote:
Actually the XMLTemplater is working correctly as you have confirmed. The problem is in the next transformer, which is an aggregator. The data source is street trees, and they are aggregated by neighbourhood. When they come out of the aggregator, the character entity references appear.

 

 

I have "fixed" the problem by doing a string replace on &lt; to < and &gt; to > after they come out of the aggregator. Thanks for looking into this.

I know this is an older question, but it sounded like a bug so I thought I'd test it. Basically, I can't get the Aggregator to do what you are describing. I do see a fix in FME2016 that might have been related and solved the issue. So, if you still experience the problem in 2016, please let me (us) know. Then we can file a PR with the developers and get it properly fixed.

Regards

Mark


  • August 25, 2016

I am getting a similar problem with FME 2016, build 16608, @Mark2AtSafe. When I pass into the XMLTemplater a dynamically generated XML string like

<gmd:keyword> <gco:CharacterString>Planning</gco:CharacterString> </gmd:keyword>

<gmd:keyword> <gco:CharacterString>parcels</gco:CharacterString>

</gmd:keyword>

...it comes out of the XMLTemplater as:

<gmd:keyword> <gco:CharacterString>Planning</gco:CharacterString> </gmd:keyword>

<gmd:keyword> <gco:CharacterString>parcels</gco:CharacterString> </gmd:keyword>

I don't know if this is a bug or a feature. Again, I can do a string replace to turn the character entity references back to < and >.


  • August 25, 2016
jimo wrote:

I am getting a similar problem with FME 2016, build 16608, @Mark2AtSafe. When I pass into the XMLTemplater a dynamically generated XML string like

<gmd:keyword> <gco:CharacterString>Planning</gco:CharacterString> </gmd:keyword>

<gmd:keyword> <gco:CharacterString>parcels</gco:CharacterString>

</gmd:keyword>

...it comes out of the XMLTemplater as:

<gmd:keyword> <gco:CharacterString>Planning</gco:CharacterString> </gmd:keyword>

<gmd:keyword> <gco:CharacterString>parcels</gco:CharacterString> </gmd:keyword>

I don't know if this is a bug or a feature. Again, I can do a string replace to turn the character entity references back to < and >.

Oh, the web page does not show the character entities references that follow the line

 

...it comes out of the XMLTemplater as:

 

 


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • August 26, 2016

Hi @jimo, could you please post a minimal workspace that reproduces the symptom to clarify the issue?

# it seems that we should type the ampersand within an entity reference as its entity reference to show an entity reference string literally on this site.
  • "&amp;" -> "&"
  • "&amp;amp;" -> "&amp;"


helmoet
Forum|alt.badge.img+8
  • March 11, 2020
jimo wrote:

I am getting a similar problem with FME 2016, build 16608, @Mark2AtSafe. When I pass into the XMLTemplater a dynamically generated XML string like

<gmd:keyword> <gco:CharacterString>Planning</gco:CharacterString> </gmd:keyword>

<gmd:keyword> <gco:CharacterString>parcels</gco:CharacterString>

</gmd:keyword>

...it comes out of the XMLTemplater as:

<gmd:keyword> <gco:CharacterString>Planning</gco:CharacterString> </gmd:keyword>

<gmd:keyword> <gco:CharacterString>parcels</gco:CharacterString> </gmd:keyword>

I don't know if this is a bug or a feature. Again, I can do a string replace to turn the character entity references back to < and >.

Hi, this is a different question regarding ampersands which have a special meaning to the operating system.


helmoet
Forum|alt.badge.img+8
  • March 11, 2020

hi @mark2atsafe, we face the same trouble in FME 2019.1. See the attached example. Can you comment on it? I suspect it has something to do with not having your data in application/xml encoding.xmltemplater.fmwt


mark2atsafe
Safer
Forum|alt.badge.img+43
  • Safer
  • March 26, 2020
helmoet wrote:

hi @mark2atsafe, we face the same trouble in FME 2019.1. See the attached example. Can you comment on it? I suspect it has something to do with not having your data in application/xml encoding.xmltemplater.fmwt

Hello @helmoet

Apologies for not responding to your sooner. I think this is working as designed, because if the attribute contained those values - and wasn't XML - then it would need to have the special characters replaced.

Luckily the fix is easy. Just change from using get-attribute to get-xml-attribute. That way FME knows this is XML based and won't treat those as special characters.

I hope this helps resolve the problem.


helmoet
Forum|alt.badge.img+8
  • March 30, 2020
mark2atsafe wrote:

Hello @helmoet

Apologies for not responding to your sooner. I think this is working as designed, because if the attribute contained those values - and wasn't XML - then it would need to have the special characters replaced.

Luckily the fix is easy. Just change from using get-attribute to get-xml-attribute. That way FME knows this is XML based and won't treat those as special characters.

I hope this helps resolve the problem.

Thankx, that did the job.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings