xsd:any 和 xsd:anyType 之间的差异/相似之处 [英] Difference/similarities between xsd:any and xsd:anyType

查看:68
本文介绍了xsd:any 和 xsd:anyType 之间的差异/相似之处的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读有关 XML、XML-Schema、DTD 的文章,但我不太明白 xsd:anyxsd:anyType 之间的区别.

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

TIA

解决方案

这篇文章很好地解释了它.我引用:

<块引用>

xsd:anyType 是一种类型,比如xsd:integer (虽然 xsd:anyType 是特别之处在于它可以作为一个简单的或复杂类型,它放置基本上没有限制它验证的树 - 想想它松散地作为 Schema 语言的java.lang.Object 的模拟).

示例用途是:

<块引用>

这意味着命名的元素 可以有任何内容,任何属性等

xs:any 是通配符,可用作术语在内容模型中.例如:

<xsd:序列><xsd:element ref="A"/><xsd:any/><xsd:element ref="C"/></xsd:sequence></xsd:complexType>

<块引用>

类型 T 的元素必须有内容<A/><???/><C/>,其中 可以是任何命名元素.现在,如果你看真的很接近有一个近似于定义xsd:anyType 中给出供参考推荐,它使用 xsd:any通配符作为表达方式它允许任何元素.

另请查看 XML 架构.

I am reading about XML, XML-Schema, DTD and I don't really understand the difference between xsd:any and xsd:anyType.

Can someone explain this to me or point to some good article? (please don't link to the XML-Schema specifications - I read that and I'm more confused)

TIA

解决方案

This post explains it nicely. I quote:

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.

Also take a look at the XML Schema.

这篇关于xsd:any 和 xsd:anyType 之间的差异/相似之处的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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