3
votes

Do the URI's in lines ( 5,6,7 ) actually have to point to anything?

When I point them at duff urls it still seems to work to validate my xml, so what is the point?

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="UploadXSD"
    targetNamespace="UploadXSD"
    elementFormDefault="qualified"
    xmlns="http://tempuri.org/UploadXSD.xsd"
    xmlns:mstns="http://tempuri.org/UploadXSD.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="Video">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Title" minOccurs="1" type="xs:string"></xs:element>
        <xs:element name="Description" minOccurs="1" type="xs:string"></xs:element>
        <xs:element name="Contributor" minOccurs="1" type="xs:string"></xs:element>
        <xs:element name="Subject" minOccurs="1" type="xs:string"></xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

</xs:schema>
2

2 Answers

5
votes

The point of using URNs as namespace is that they are unique. You could also use a GUID for example, but this way they are more readable.

Of course, using URNs gives you the possibility to point them to an actual resource, like a xsd file, but that's an added bonus and not necessary.

The "tempuri" things are just default names ("temp"+"uri"), which you should replace with a real URN to avoid namespace collisiions.

The XMLSchema namespace actually points to a website that contains information about XML-Schema.

If you use XML-Documents and Schemas regurlarly, read at least the primer, to get an idea about the possibilities of XML-Schema. More info about XML Namespaces is here.

4
votes

XML Namespace URI's (not URL's) are just opaque strings. They are intended to prevent collisions in XML structures. Just like any namespace capable other language, they don't point to anything but they define a unique name through which its content can be used.

Since it's easy to use a DNS registration and be guarenteed to be globally unique, it is a common practice to use those name in the schema's you publish. It is however not needed and a GUID would work (although it needs a scheme prefix to comply to the URI spec).

To answer your questions:

No, URI's do not need to point anything (they are IDs).

When you change a URI of a namespace, you change the namespace name, nothing else.

Hope this helps,