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 toxsd
isxs
.)
xsd
and xsi
Differences
- 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
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
allows an empty element to be considered to be valid when the XSD might not otherwise have allowed it. -
xsi:schemaLocation
andxsi:noNamespaceSchemaLocation
provide hints to the XML processor as to how to associate an XSD with an XML document. Usexsi:schemaLocation
when there is a namespace; usexsi:noNamespaceSchemaLocation
when there is no namespace.
-