我正在阅读有关 XML、XML-Schema、DTD 的资料,但我并不真正理解 xsd:any 和 xsd: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/