posted on Thursday, September 23, 2004 12:11 PM
by
jdixon
Don't forget the <xsl:output encoding=""/> when creating text files!
I've written many XSLTs that create formatted text files. I don't do this very often, and there are usually many months between each occurrence. So, I often find that the first three characters in the resulting file are the characters 0xEF, 0xBB, and 0xBF. (These apparently indicate that UTF8 encoding is being used.) Because these characters do not show up in normal text editors, I don't always notice that they are there. When I look at the file with a hex editor, however, BINGO!. There they are.
As you can imagine, this causes problems for some of my clients that do not expect these characters.
To solve the problem, I place <xsl:output indent="no" method="text" encoding="ISO-8859-1"/> in the XSLT. This removes the encoding characters from the resulting text file. Now my clients are happy, and so am I.
Note that this works in my situation, but that you may need a different encoding. Just don't forget the <xsl:output encoding=""/>!