简体   繁体   English

XSL转换给我错误的编码

[英]XSL transformation give me wrong encoding

I got a xsl-file that transform a xml-file to another one, with different xml-format. 我得到了一个xsl文件,该文件将一个xml文件转换为另一个具有不同xml格式的文件。 The xsl-file starts with: xsl文件开头为:

        ?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文件在第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. 当我在本地调试文件时,结果是utf-8,但在此应用程序使用它时却不是。

Is there anyway to force it more to set it as utf-8? 无论如何,有什么要强迫它将其设置为utf-8的? Because that is a demand. 因为那是需求。 The receiving system is some Unix-system. 接收系统是某些Unix系统。

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). 我将转换的那个格式为utf-8格式(无论如何在notepad ++中说)。

Am I missing something here, is there another way to set the result:s encoding than the syntax encoding="utf-8"? 我在这里遗漏了什么吗,有没有一种方法来设置result:s编码,而不是语法encoding =“ utf-8”?

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. 也许输出被发送到DOM树,然后由DOM序列化器而不是XSLT序列化器进行序列化-在这种情况下,样式表中请求的编码将被忽略。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM