I'm using XML(xslt) - How to fix the BOM issue

Hi Guys,

I am using xslt(mapping) to create output xml file.
Issue: target system compline about added BOM character.

These outputs configurations does not fix an issue
<xsl:output method="xml" version="1.0" encoding="utf-8" omit-xml-declaration="no" indent="yes"/>
 <xsl:output method="xml" version="1.0" encoding="ASCII" omit-xml-declaration="no" indent="yes"/>

Open in new window


I'm using online validator to test output xml file
http://validator.w3.org/i18n-checker/#validate-by-upload+

results
Capture.PNG
Any advice?

Thank you!
DariusAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gertone (Geert Bormans)Information ArchitectCommented:
First let me say this: a BOM should not at all make difference on an XML file. And XML processing application that claims to validate or handle XML correctly should know how to handle the BOM. So if the BOM is causing issues with th ereceiving end, the receiving end is NOT a decent XML processor at all (I am raising this as a warning, other issues will pop up later if you have bypassed the BOM issue)

It is not the XSLT processor that ads the BOM. THat is the serialisation process and it is pretty hard to correct that from within the XSLT.
So every advice you can find if you google this issue that says that you need to change the xsl:output or the output encoding is only right in a VERY limited context

So, bottom line is "how do you serialise?"
This question can only be answered outside a limited context if we know
- what XSLT processor you use
- how you execute the XSLT
- .... anything that can help us understand the details of your transformation
0
DariusAuthor Commented:
We created an internal transformer service in C# that uses the class XslTransformer.
0
Gertone (Geert Bormans)Information ArchitectCommented:
OK, basically that ignores the xsl:output completely
If you are using a XML writer

XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
xmlWriterSettings.Encoding = new UTF8Encoding(false);

this way you set the encoding to UTF8 and will not create the BOM
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
Some of this information might be helpful, too.  I found that some common text editors will add a BOM, whether you want it or not.

See BOM is Decidedly Not Da Bomb in this article:
https://www.experts-exchange.com/articles/11880/Unicode-and-Character-Collisions.html
1
Gertone (Geert Bormans)Information ArchitectCommented:
Thanks for the article reference Ray. Have just scanned through it but it definitely deserves some in detail reading later.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.