Skip to main content
Solved

BOM (Byte Order Mark) written by AttributeFileWriter on FME server


Hello,

I have a workspace that creates XML content in an attribute and finally uses an AttributeFileWriter to write it to an XML file. This all works fine in FME Desktop 2018.1 (on my Windows 10 machine) and mostly fine in FME server 2018.1.0.3 on "win64". The difference is that the result file written by FME server has a BOM (Byte Order Mark) set and the result file written by FME Desktop does not.

We found this only recently when the receiver of the result file (generated by FME server) complained that their software couldn't read it, and we nailed it down to the BOM being set.

I know that there is a setting in the "ordinary" Text File Writer which allows to select whether I want the BOM or not. The AttributeFileWriter does not have this option and seems to handle this differently on FME desktop and server.

From the logs of the server run of my workspace I saw that it seems that the server uses a text file writer "underneath" the AttibuteFileWriter:

Text File Writer: Opening the file '\\\\server\\and\\path\\to\\my\\result.xml\\'

 

Text File Writer: Line Termination: Windows

 

Text File Writer: Write the final line termination character: yes

 

Text File Writer: Character Encoding: 'utf-8'

 

Text File Writer: Write UTF-8 Byte Order Mark: yes

 

 

My question: how can I prevent the server from setting the BOM, or configure the workspace to write the result file without it?

Thank you in advance

NK

 

Best answer by david_r

The Text File writer only writes one single attribute, not the whole feature. Just be sure that the resulting attribute from the XMLTemplater is called "text_line_data", which is what the writer expects:

View original
Did this help you find an answer to your question?

7 replies

takashi
Influencer
  • June 23, 2020

Is there any reason for that you don't use the Text File writer?


  • Author
  • June 23, 2020

I create the complete result XML content in an attribute, using an XMLTemplater and an XMLFormatter. There is basically only one feature left at the end, which contains all the XML in the attribute. Then I use the AttributeFileWriter to write that attribute into a file.


david_r
Celebrity
  • June 23, 2020

As @takashi mentions, my recommendation would be to use the Text File writer, e.g. with a FeatureWriter.


  • Author
  • June 23, 2020
david_r wrote:

As @takashi mentions, my recommendation would be to use the Text File writer, e.g. with a FeatureWriter.

I'm sorry, I can't think of a way how to do this. How can I get my content, which is in an attribute, to the file? There is only one feature left at the end. I don't want to write this feature to a file, but only the content of one of its attributes.

Maybe putting my desired result into an attribute is not a good idea in the first place, but then, this is how the XMLTemplater works.

david_r
Celebrity
  • Best Answer
  • June 23, 2020

The Text File writer only writes one single attribute, not the whole feature. Just be sure that the resulting attribute from the XMLTemplater is called "text_line_data", which is what the writer expects:


takashi
Influencer
  • June 23, 2020
david_r wrote:

The Text File writer only writes one single attribute, not the whole feature. Just be sure that the resulting attribute from the XMLTemplater is called "text_line_data", which is what the writer expects:

Yes, you can write any attribute value into a text file with the Text File writer. Just rename the attribute to "text_line_data", as @david_r suggested.

You can also write the resulting XML document with the XMLFormatter directly.

Select "XML File" as the XML Output Type parameter and set the destination file path to the "XML Output File" parameter in the XMLFormatter. Not sure if the XMLFormatter writes BOM, but I think it's worth to try.


  • Author
  • June 24, 2020
david_r wrote:

The Text File writer only writes one single attribute, not the whole feature. Just be sure that the resulting attribute from the XMLTemplater is called "text_line_data", which is what the writer expects:

I did not know that a text file writer works this way. This solution works perfectly. Thank you very much!


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