xsd 架构可以验证编码(例如 UTF-8)吗?

发布于 2024-10-06 18:01:18 字数 109 浏览 0 评论 0原文

通过使用模式,是否有任何简单/容易的方法来验证 xml 消息的编码?

假设 xml 的第一行“不”可信? 例如忽略?xml version =“1.0”encoding =“UTF-8”?

By using schema, is there any simple/easy way to validate the encoding of an xml msg?

Assuming the 1st line of xml is "not" trustworthy?
e.g. ignore ?xml version="1.0" encoding="UTF-8" ?

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

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

发布评论

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

评论(1

笛声青案梦长安 2024-10-13 18:01:18

不,除了二进制数据元素类型之外,模式不能规定编码类型,但这种编码仍将由文档本身的高级编码封装。如果您意识到模式应该描述信息而不是传输格式,那么这是有道理的。 XML 规范规定了文档传输信息,例如如何以最广义的方式表示和存储信息。模式用于验证通过 XML 存储的数据是否满足各方之间的某种语法限制。 XML 规范中定义的序言(您提到的第一行)是一个实体,其中存在(或不存在)是投诉 XML 读者需要知道文档是如何编码的。编码只是端点之间表示正确 unicode 代码点的协议,XML 规范指定如何达成此协议,而不是模式。

如果您感兴趣,这是 XML 1.1 规范的相关部分,介绍了如何达成此协议,更有趣的是,投诉读者如何“猜测”编码,因此可以将序言读取到足以猜测的程度读取实际的编码属性: http://www.w3.org/TR/xml11/ #秒猜测

No, schema can't dictate encoding type except in terms of the binary data element types, but this encoding is still going to be encapsulated by the high level encoding of the document itself. This makes sense if you realize that the schema is suppose to describe the information and not the transport format. The XML specification is what dictates that document transport information such as how information is represented and stored in the most generalized sense. Schema is for validating that the data stored via XML meets some kind of syntactical restraints between parties. The prolog (that first line you mention) as defined in the XML spec is the entity in which existence (or not) is what a complaint XML reader needs to know how the document is encoded. Encoding is simply the agreement between the endpoints to represent the correct unicode code points and XML specification specifies how this agreement is reached, not schema.

If you are interested, this is the relevant section of the XML 1.1 specification on how this agreement is reached and more interesting how a complaint reader can 'guess' at the encoding so it is good enough of a guess that the prolog can be read to read the actual encoding attribute: http://www.w3.org/TR/xml11/#sec-guessing

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