xml xsd 和 xsi 有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41035128/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 12:12:17  来源:igfitidea点击:

What is the difference between xsd and xsi?

xmlxsdxml-namespacesxsd-validationxml-validation

提问by Piyush

What exactly is the difference between XML Schema Documentand XML Schema Instance?

XML Schema DocumentXML Schema Instance之间到底有什么区别?

  • xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  • xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  • xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  • xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

Please elaborate.

请详细说明。

采纳答案by kjhughes

xsdand xsiSimilarities

xsdxsi相似之处

  • 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 conventionaland therefore recommended. (An also-conventional alternative to xsdis xs.)
  • 两者都是XML命名空间前缀,缩写的 XML命名空间
  • 与所有命名空间前缀一样,两者都是任意命名的;其他命名空间前缀缩写同样可以使用。但是,这两个前缀都是常规的,因此建议使用。(另一种传统的替代方法xsdxs。)

xsdand xsiDifferences

xsdxsi差异

See Also

也可以看看

回答by Sprotty

http://www.w3.org/2001/XMLSchema

http://www.w3.org/2001/XMLSchema

The Simple Version : This is the namespace used within an XML Schema (XSD). An XML schema is used to describe what's valid within an XML instance document.

简单版本:这是在 XML 架构 (XSD) 中使用的命名空间。XML 模式用于描述 XML 实例文档中的有效内容。

The Less Simple Version : This is the namespace of an XML Schema that describes the structure of an XML Schema. In other words a schema that describes itself.

不太简单的版本:这是描述 XML 模式结构的 XML 模式的命名空间。换句话说,一种描述自身的模式。

An XML Schema (XSD) must be written using the types defined within this schema.

XML 模式 (XSD) 必须使用此模式中定义的类型编写。

For Example.

例如。

<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="MyElement" type="xs:string" />
</xs:schema>

http://www.w3.org/2001/XMLSchema-instance

http://www.w3.org/2001/XMLSchema-instance

This is a namespace used within XML Instance documents to provide additional data to the XML Parser that is processing it. It describes the attributes xsi:schemalocation, xsi:noSchemalocation, xsi:type and xsi:nil which the XML parser can use to assist it with validation.

这是在 XML 实例文档中使用的命名空间,用于向处理它的 XML 解析器提供附加数据。它描述了属性 xsi:schemalocation、xsi:noSchemalocation、xsi:type 和 xsi:nil,XML 解析器可以使用这些属性来帮助它进行验证。

For Example.

例如。

<MyElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
           xsi:noNamespaceSchemaLocation="MySchema.xsd">
    string
</MyElement>