xsl-list
[Top] [All Lists]

RE: xsl to format an ugly xml file to a neat xml file

2004-09-21 02:51:54

no, all I needed was a stylesheet to do this job, not an 
application! although jarno's link helped me in a way, 
mysteriously enough the transformation always converted <?xml 
version="1.0" encoding="utf-8"?> to <?xml version="1.0" 
encoding="utf-16"?> which my application did not like at all. 
I tried to investigate a little (changing encoding types here 
and there), but then decided the feature was not important 
enough, because I had no clue and there were other things 
more important at the time. anyway, if this error is somewhat 
common and an easy fix is at hand, I'd be glad to hear about it...

It's because you are using MSXML - if you don't specify an output
encoding MSXML will default to UTF-16.  The encoding specified in your
xml source applies to your xml source, not to  the xml produced by the
transformation, so the processing isn't changing the xml declation it is
creating a new one.  If you want your output to be encoded in UTF-8 and
you are using MSXML you will need to be explicit:

<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
                         ^^^^^^^^^^^^^^^^
cheers 
andrew