What effect does the noNamespaceSchemaLocation attribute have on XML parsing?

A-priory:

The noNamespaceSchemaLocation attribute refers to an XML Schema document that does not have a target namespace.

How will this attribute change the result of parsing?

For example, take this XML:

<?xml version="1.0"?> <name xmlns="http://www.example.com/name" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.com/name schema/schema.xsd" title="Mr."> <first>John</first> <middle>M</middle> <last>Doe</last> </name> 

referring to this diagram:

 <?xml version="1.0"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:target="http://www.example.com/name" targetNamespace="http://www.example.com/name" elementFormDefault="qualified"> <element name="name"> <complexType> <sequence> <element name="first" type="string"/> <element name="middle" type="string"/> <element name="last" type="string"/> </sequence> <attribute name="title" type="string"/> </complexType> </element> </schema> 

I removed these namespace declarations from the schema:

 xmlns:target="http://www.example.com/name" targetNamespace="http://www.example.com/name" 

without even using the noNamespaceSchemaLocation attribute in the XML link, no error was selected. Why do we even need this attribute?

+7
source share
1 answer

The attribute does not affect the XML parser. This may affect the behavior of the XML schema processor if appropriate parameters are set; and it can also affect the behavior of a program that combines the functions of XML parsing and XML schema validation. It tells the schema processor where to look for the schema that describes the document.

But even with the schema processor, the noNamespaceSchemaLocation attribute noNamespaceSchemaLocation not affect the validation of a document like yours where all the elements are in the namespace.

+8
source

All Articles