xsd 和 xsi 有什么区别? [英] What is the difference between xsd and xsi?

查看:55
本文介绍了xsd 和 xsi 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

XML Schema DocumentXML 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"

请详细说明.

推荐答案

xsdxsi 相似之处

  • 两者都是 XML 命名空间前缀,缩写XML 命名空间.
  • 和所有命名空间前缀一样,两者都是任意命名的;其他命名空间前缀缩写同样可以很好地使用.但是,这两个前缀都是常规和所以受到推崇的.(xsd 的另一种传统替代方法是 xs.)
  • xsd and xsi Similarities

    • 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 is xs.)
      • 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 (or xs) 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 Namespace http://www.w3.org/2001/XMLSchema-instance is used in XML document instances for several special attributes defined by the XML Schema Recommendation:

      • 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?

      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:schemaLocationxsi: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屋!

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