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"
Please elaborate.
The prefix "xsi" is the namespace prefix used by convention for the XML Schema instance namespace. XML documents can contain elements that have an xsi:type attribute. This behavior provides an explicit data type for the element. The MRM XML parser in sensitive to xsi:type attributes in the XML document.
The xsi:schemaLocation attribute locates schemas for elements and attributes that are in a specified namespace. Its value is a namespace URI followed by a relative or absolute URL where the schema for that namespace can be found. It is most commonly attached to the root element but can appear further down the tree.
XML Schema Definition or XSD is a recommendation by the World Wide Web Consortium (W3C) to describe and validate the structure and content of an XML document. It is primarily used to define the elements, attributes and data types the document can contain.
The XSD can also be used to review XML data prior to data display for proper format that is appropriate with the scheme. XSL is defined as a specified writing language that is used to follow a systematic series of action for XML coded information. The user can use the XSL to go through defined XML coded information.
xsd
and xsi
Similaritiesxsd
is xs
.)xsd
and xsi
Differencesxsd
(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
allows an empty element to be considered to be valid when the XSD might not otherwise have allowed it.
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.
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.
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.
An XML Schema (XSD) must be written using the types defined within this schema.
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
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.
For Example.
<MyElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="MySchema.xsd">
string
</MyElement>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With