Skip to main content
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

 

 
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
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.
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


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 >.


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:

 

 


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;"


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.


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


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.


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.


Reply