xsd 和 xsi 有什么区别? [英] What is the difference between xsd and xsi?
问题描述
XML Schema Document 和 XML Schema Instance 到底有什么区别?
What exactly is the difference between XML Schema Document and XML Schema Instance ?
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
请详细说明.
推荐答案
xsd
和 xsi
相似之处
- 两者都是 XML 命名空间前缀,缩写XML 命名空间.
- 和所有命名空间前缀一样,两者都是任意命名的;其他命名空间前缀缩写同样可以很好地使用.但是,这两个前缀都是常规和所以受到推崇的.(
xsd
的另一种传统替代方法是xs
.) - Both are XML namespace prefixes, abbreviations for an XML namespace.
- Both are, as are all namespace prefixes, arbitrarily named; other namespace prefix abbreviations
could equally well be used. However, both prefixes are conventional and therefore
recommended. (An also-conventional alternative to
xsd
isxs
.) xsd
(或xs
)前缀指的是 架构命名空间(http://www.w3.org/2001/XMLSchema
) 在 XML 模式 (XSD) 中用于 W3C XML 模式推荐本身.(这是可能的,因为 XML Schema 本身就是 XML.)xsi
前缀指的是 架构实例命名空间http://www.w3.org/2001/XMLSchema-instance
是用于 XML 文档实例中定义的几个特殊属性根据 XML 架构建议:- The
xsd
(orxs
) prefix referring to the Schema Namespace (http://www.w3.org/2001/XMLSchema
) is used in XML Schemas (XSDs) for the elements, attributes, and types of the W3C XML Schema Recommendation itself. (This is possible because XML Schema is itself XML.) The
xsi
prefix referring to the The Schema Instance Namespacehttp://www.w3.org/2001/XMLSchema-instance
is used in XML document instances for several special attributes defined by the XML Schema Recommendation:xsi:type
允许 XML 实例直接关联元素类型信息,而不是通过 XSD.请参阅如何在 XSD 中使用 xsi:type 限制 XML 元素的值?xsi:type
allows an XML instance to associate element type information directly rather than through an XSD. See How to restrict the value of an XML element using xsi:type in XSD?
xsd
and xsi
Similarities
xsi:nil
允许在 XSD 可能不允许的情况下将空元素视为有效.
xsi:nil
allows an empty element to be considered to be valid when the XSD might not otherwise have allowed it.
xsi:schemaLocation
和 xsi:noNamespaceSchemaLocation
向 XML 处理器提供有关如何将 XSD 与 XML 文档相关联的提示.有命名空间时使用xsi:schemaLocation
;没有命名空间时使用 xsi:noNamespaceSchemaLocation
.
xsi:schemaLocation
and xsi:noNamespaceSchemaLocation
provide hints to the XML processor as to how to associate an XSD with an XML document. Use xsi:schemaLocation
when there is a namespace; use xsi:noNamespaceSchemaLocation
when there is no namespace.
这篇关于xsd 和 xsi 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!