XSLT 编码问题,结果中出现问号

发布于 2024-07-12 05:58:55 字数 231 浏览 7 评论 0原文

我正在尝试运行 XSLT 转换,但像 ëöï 这样的字符被替换为文字“?” 在输出中(我用十六进制编辑器检查过)。 源文件具有正确的字符,并且样式表具有:

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

我还缺少什么?

我正在使用 saxon 作为变压器,如果这很重要的话。

I'm trying to run an XSLT transformation, but characters like ëöï are replaced by a literal '?' in the output (I checked with an hex editor). The source file has the correct characters, and the stylesheet has:

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

What else am I missing?

I'm using saxon as the transformer, if that matters.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷乱花海 2024-07-19 05:58:55

问题很可能出在您调用变压器的方式上。 我的猜测是,如果您使用 java -jar saxon.jar ... 来调用它,它会工作得很好。

一般来说,当您使用采用 InputStream/OutputStream 的 XML 工具时,这些工具将确保编码正确。

当您混合使用 Streams 和 Writer 时,您必须确保从一种流到另一种时的编码与您告诉 XSLT 处理器生成的编码相匹配。 始终明确设置编码。 可能有默认值,但当涉及到编码时,它们往往是错误的。

The problem is most likely in the way you call the transformer. My guess is it will work fine if you call it using java -jar saxon.jar ...

In general, when you use XML tools which take InputStream/OutputStream, then the tools will make sure that the encoding is correct.

When you use a mixture of Streams and Writers, you will have to make sure that the encoding when going from one to the other matches what you told the XSLT processor to produce. Always set encodings explicitly. There may be defaults, but when it comes to encodings, they are wrong more often than not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文