XSL transformation give me wrong encoding

久未见 提交于 2019-12-12 00:28:24

问题


I got a xsl-file that transform a xml-file to another one, with different xml-format. The xsl-file starts with:

        ?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxsl="urn:schemas-microsoft-com:xslt"

And then the output starts with:

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

And the rest of all elements that will be transformed, like alot of lines as:

        <xsl:element name="tns:corporateName" >
          <xsl:value-of select="@CorpOrgname"/>
        </xsl:element>

Everything looks nice, except for that the resulting xml-file has this tag in line 1:

 <?xml version="1.0" encoding="Windows-1252"?

I cannot understand where this encoding comes from. When I debug the file locally the result is utf-8, but not when this application uses it.

Is there anyway to force it more to set it as utf-8? Because that is a demand. The receiving system is some Unix-system.

I have got an example of the original file. That one I will transform, and that is in utf-8 format (during what notepad++ says anyway).

Am I missing something here, is there another way to set the result:s encoding than the syntax encoding="utf-8"?


回答1:


Look at how the transformation is being run. Perhaps the output is being sent to a DOM tree and is then serialized by the DOM serializer not the XSLT serializer - in this case the encoding requested in the stylesheet will be ignored.



来源:https://stackoverflow.com/questions/17151901/xsl-transformation-give-me-wrong-encoding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!