无属性且无自闭合的 XSD [英] XSD for no attributes and no self-closing

查看:32
本文介绍了无属性且无自闭合的 XSD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想为具有尽可能多根的任何 xml 元素使用 XSD.限制是不应该有任何自结束标记并且不允许使用任何属性.允许任何级别的嵌套.例如,

I just wanna an XSD for any xml elements with as many roots as possible. The restriction is that there shouldn't be any self closing tag and no attributes allowed. Any level of nesting allowed. For example,

<a>A<b>BB</b><c></c></a><d>aa</d>

注意有多个根,没有属性,也没有自闭.

Note there are multiple roots and no attribute and no self closing.

推荐答案

(1) 如果文档格式不正确,则它不会针对任何架构进行验证.一个文档将多个根元素的格式不正确.

(1) If a document isn't well-formed, then it won't validate against any schema. A document will multiple root elements isn't well-formed.

(2) 不能使用 XSD 对 XML 施加纯粹的词法约束,例如限制属性之间的空白数量,或单引号或双引号的选择,或小数与双引号的使用- 十六进制字符引用,或在 之间的选择来表示一个空元素.接收应用程序不应该关心这些差异,如果他们使用符合标准的 XML 解析器,他们将永远不会知道这些差异.XSD 用于验证逻辑结构,这是应用程序关心的内容.

(2) You can't use XSD to impose purely lexical constraints on your XML, for example to restrict the amount of whitespace between attributes, or the choice of single-or-double quotes, or the use of decimal-versus-hexadecimal character references, or the choice between <a></a> versus <a/> to represent an empty element. Receiving applications aren't supposed to care about these differences, and if they use a conforming XML parser they will never know about the differences anyway. XSD is for validating the logical structure, the stuff that applications do care about.

这篇关于无属性且无自闭合的 XSD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆