xsi:schemalocation vs. xsi:nonamespaceschemalocation

 

Hi,

We are faced with big confusion that if a XML document has xsi:noNamespaceSchemaLocation, then Schema used for creation of this XML doc needs to have targetNamespace or not.

e.g. I am creating a XML doc given below called noSchemaXMLDoc.xml

<root xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation="noSchemalocate.xsd">

  <grade>a</grade> 
  </root>
 
for this is it mandatory to use noSchemalocate.xsd with no targetNamespace, given below
 
<?xml version="1.0" encoding="UTF-8" ?> 
 <file:///C:/ManavJava/noSchemalocate.xsd#> - <xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" elementFormDefault="qualified">
 <file:///C:/ManavJava/noSchemalocate.xsd#> - <xsd:element name="root">
 <file:///C:/ManavJava/noSchemalocate.xsd#> - <xsd:complexType>
 <file:///C:/ManavJava/noSchemalocate.xsd#> - <xsd:sequence>
  <xsd:element name="grade" type="abc" /> 
  </xsd:sequence>
  </xsd:complexType>
  </xsd:element>
 <file:///C:/ManavJava/noSchemalocate.xsd#> - <xsd:simpleType name="abc">
 <file:///C:/ManavJava/noSchemalocate.xsd#> - <xsd:restriction base="xsd:string">
  <xsd:enumeration value="a" /> 
  <xsd:enumeration value="b" /> 
  <xsd:enumeration value="c" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:schema>
 
or can we use schema with targetNamespace, given below
 
<?xml version="1.0" encoding="UTF-8" ?> 
 <file:///C:/ManavJava/schemanamespace.xsd#> - <xsd:schema xmlns:s1="http://www.schemaValid.com/s1ns" targetNamespace="http://www.schemaValid.com/s1ns" xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" elementFormDefault="qualified">
 <file:///C:/ManavJava/schemanamespace.xsd#> - <xsd:element name="root">
 <file:///C:/ManavJava/schemanamespace.xsd#> - <xsd:complexType>
 <file:///C:/ManavJava/schemanamespace.xsd#> - <xsd:sequence>
  <xsd:element name="grade" type="s1:abc" /> 
  </xsd:sequence>
  </xsd:complexType>
  </xsd:element>
 <file:///C:/ManavJava/schemanamespace.xsd#> - <xsd:simpleType name="abc">
 <file:///C:/ManavJava/schemanamespace.xsd#> - <xsd:restriction base="xsd:string">
  <xsd:enumeration value="a" /> 
  <xsd:enumeration value="b" /> 
  <xsd:enumeration value="c" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:schema>
 
Need your confirmation on this.
 
Regards,
Manav Singal
Programmer Analyst
Communication Software Group
 

Received on Thursday, 21 March 2002 12:03:55 UTC