XML 声明标签区分大小写吗?

发布于 2024-07-22 10:10:18 字数 787 浏览 4 评论 0 原文

我有一个可能非常简单、愚蠢的问题,但我在任何地方都找不到答案,我需要对此非常确定。

我有来自不同供应商的各种 XML 文件。 其中一个供应商向我提供了一个 XML 文件,其中包含日语字符。 最初,我在处理 XML 文件时遇到了问题(我正在使用 MSXML SDK)。 字符会出现错误。 我发现如果将以下内容添加到 XML 文件中,一切都会很好。

<?xml version="1.0" encoding="UTF-16"?>

所以我要求供应商将其添加到他们的文件中。 但他们用小写编码添加了它:

<?xml version="1.0" encoding="utf-16"?>

当我使用此声明加载这个新文件时,我遇到了与不存在此声明时相同的问题。

我想弄清楚(当然)是该编码属性是否区分大小写(或者是其他问题)。 他们将“utf-16”与“UTF-16”放在一起重要吗?

更新:在此处发布答案的人的建议下,我设置并执行了测试。 一个文件的 utf-16 为小写,另一个文件为大写。 除此之外,这些文件是相同的。 这并没有解决问题,也不是问题所在。 我的结论是,MSXML 不区分大小写,正如答案中发布的规范所述。

I have what is probably a really simple, studid question but I can't find an answer to it anywhere and I need to be pretty sure about this.

I have various XML files from various vendors. One of the vendors provide me an XML file with japanese characters in the file. Originally, I was having trouble processing the XML file (I'm using the MSXML SDK). The characters would come out wrong. I found that if the following was added to the XML file everything worked great.

<?xml version="1.0" encoding="UTF-16"?>

And so I asked the vendor to add this to their file. But they added it with the encoding in lower case:

<?xml version="1.0" encoding="utf-16"?>

And when I load this new file, with this declaration, I'm getting the same problem as when this declaration was not there.

What I'm trying to figure out (for sure) is if that encoding attribute is case sensitive (or is otherwise the problem). Does it matter that they put "utf-16" versus "UTF-16"?

Update: Under the advise of these who posted answers here, I setup and executed a test. One file had the lower case utf-16 and the other upper case. Other than that, the files were identical. This did not fix the problem and is not the problem. My conclusion is that MSXML is not case sensitive as the spec, posted in the answers, states.

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

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

发布评论

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

评论(2

九公里浅绿 2024-07-29 10:10:18

我想问题实际上并不是“标准是否区分大小写?” 但是“MSXML SDK 中的编码是否区分大小写?”

来自 bytes.com

XML 规范规定处理器“应该”匹配编码名称
不区分大小写。 “SHOULD”是一个技术术语,强度不如
“必须”,但我看不出处理器不这样做的任何理由。

然而,我们知道在实践中这可能并不总是正确的。 如果您可以同时尝试两者,请这样做并让我们知道结果是什么。

I suppose the question is not really "is the standrard case-sensitive?" but "is the encoding case-sensitive in MSXML SDK?"

From bytes.com:

The XML spec says that processors "SHOULD" be match encoding names
case-insensitively. "SHOULD" is a technical term, less strong than
"MUST", but I can't see any reason why a processor would not do it.

However, we know that this may not always be true in practice. If you can try both side-by-side, please do so and let us know what the result is.

无风消散 2024-07-29 10:10:18

来自 XML 规范

XML processors SHOULD match character encoding names in a case-insensitive way

所以不需要,但建议这样做不区分大小写,根据 RFC 2119

  • 应该这个词或形容词“推荐”的意思是
    可能存在正当理由
    特殊情况忽略
    特定项目,但完整
    必须理解其含义并且
    选择之前要仔细权衡
    不同的课程。
  • From the XML specs:

    XML processors SHOULD match character encoding names in a case-insensitive way
    

    So it's not needed but recommened to be case-insensitive, according to RFC 2119:

    1. SHOULD This word, or the adjective "RECOMMENDED", mean that
      there may exist valid reasons in
      particular circumstances to ignore a
      particular item, but the full
      implications must be understood and
      carefully weighed before choosing a
      different course.
    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文