HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
The <schema> element is the root element of every XML Schema
The <schema> element is the root element of every XML Schema:
<?xml version="1.0"?>
<xs:schema>
...
...
</xs:schema>
The <schema> element may contain some attributes. A schema declaration often looks something like this:
<?xml version="1.0"?>
<xs:schema xmlns:xs="https://www.w3.org/2001/XMLSchema"
targetNamespace="/"
xmlns="/"
elementFormDefault="qualified">
...
...
</xs:schema>
The following fragment:
xmlns:xs="https://www.w3.org/2001/XMLSchema"
indicates that the elements and data types used in the schema come from the "https://www.w3.org/2001/XMLSchema" namespace. It also specifies that the elements and data types that come from the "https://www.w3.org/2001/XMLSchema" namespace should be prefixed with xs:
This fragment:
targetNamespace="/"
indicates that the elements defined by this schema (note, to, from, heading, body.) come from the "/" namespace.
This fragment:
xmlns="/"
indicates that the default namespace is "/".
This fragment:
elementFormDefault="qualified"
indicates that any elements used by the XML instance document which were declared in this schema must be namespace qualified.
This XML document has a reference to an XML Schema:
<?xml version="1.0"?>
<note xmlns="/"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="/ note.xsd">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
The following fragment:
xmlns="/"
specifies the default namespace declaration. This declaration tells the schema-validator that all the elements used in this XML document are declared in the "/" namespace.
Once you have the XML Schema Instance namespace available:
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
you can use the schemaLocation attribute. This attribute has two values, separated by a space. The first value is the namespace to use. The second value is the location of the XML schema to use for that namespace:
xsi:schemaLocation="/ note.xsd"