0

Apologies if this is a repeat of an older question but I did attempt to find a similar question and didn't have any luck. I'm going through the tutorials at www.w3schools.com for writing XSDs and XMLs. I have a basic understanding of namespaces but my question -- why do many XSDs that I've seen contain a reference to http://www.w3.org/2001/XMLSchema?

For example:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="https://www.w3schools.com" xmlns="https://www.w3schools.com" elementFormDefault="qualified">

Why do many people include xmlns:xs="htttp://www.w3.org/2001/XMLSchema? Is it because it allows them to use predefined elements, attributes and types such as xs:string, xs:complexType, xs:simpleType, xs:attribute?

Does referencing the w3.org namespace allow you to use built-in datatypes?

Thanks in advance

2 Answers2

1

A schema document by definition must have an outermost element whose local name is "schema" and whose namespace URI is "http://www.w3.org/2001/XMLSchema". That can't be achieved unless it has a declaration of this namespace (which you misspelled "htttp...", by the way). Namespaces are used to distinguish different XML vocabularies; XSD is an XML vocabulary, and this is the namespace that distinguishes it.

The w3schools site, by the way, is not associated with W3C in any way. I find it a handy way of looking up simple reference information, but it's a hopeless way to learn new concepts. Get yourself a good book and do some bedtime reading.

Michael Kay
  • 3,599
  • 1
  • 17
  • 13
0

If an XSD file doesn't reference this namespace and use the elements from it, it's not an XML schema definition.