xml - xsd :any and xsd:anyType 之间的差异/相似之处

标签 xml xsd

我正在阅读有关 XML、XML-Schema、DTD 的资料,但我并不真正理解 xsd:anyxsd:anyType 之间的区别。

有人可以向我解释一下或指出一些好的文章吗? (请不要链接到 XML-Schema 规范——我读了它,但我更困惑了)

TIA

最佳答案

This post很好地解释了它。我引用:

xsd:anyType is a type, like xsd:integer (though xsd:anyType is special in that it can act as a simple or complex type, and it places essentially no restrictions on the tree that it validates -- think of it loosely as the Schema language's analog of java.lang.Object).

A sample use would be:

<xsd:element name="e" type="xsd:anyType"/>

This would mean that elements named <e> can have any content, any attributes, etc.

xs:any is a wildcard, usable as a term in a content model. For example:

<xsd:complexType name="T">
  <xsd:sequence>
    <xsd:element ref="A"/>
    <xsd:any />
    <xsd:element ref="C"/>
  </xsd:sequence>
</xsd:complexType>

Elements of type T must have content <A/><???/><C/>, where <???> can be any named element. Now, if you look really closely there is an approximation to the definition of xsd:anyType given for reference in the Recommendation, and it uses an xsd:any wildcard as the means of saying that it allows any elements.

另请查看 XML Schema .

关于xml - xsd :any and xsd:anyType 之间的差异/相似之处,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5389076/

相关文章:

xml - 定义 XML 架构 (XSD) 时,具有 'choice' 元素的 'group' 是否有效

xml - 发布 xml 模式的标准方法

java - WSDL 发布后发生更改

xml - 如何使用 RelaxNG 检查属性是否唯一?

java - Apache Camel : Cannot locate xsd file exception

xml - 需要使用 Xpath 替换 XML 文件中的属性值

java - Android:解析 XML DOM 解析器。将子节点转换为字符串

xsd - 在 XSD 中的许多元素上重用属性

java - 将嵌套对象编码为 "flat"XML 结构

xml - SyntaxHighlighter 不格式化 xml 文本