W3C home > Mailing lists > Public > xmlschema-dev@w3.org > September 2002

RE: XML schema validation and namespaces

From: Dare Obasanjo <dareo@microsoft.com>
Date: Wed, 4 Sep 2002 09:21:38 -0700
Message-ID: <8BD7226E07DDFF49AF5EF4030ACE0B7E07A971E1@red-msg-06.redmond.corp.microsoft.com>
To: "Sanjay Dahiya, Noida" <sanjay@noida.hcltech.com>
Cc: <xmlschema-dev@w3.org>
Q1: 
Now XML instance document can also contain references to multiple
namespaces and schema using schemaLocation and
noNamespaceSchemaLocation ( why multiple ??) 
 
A1: 
Because an instance document may refer to elements and attributes from
multiple namespaces defined in multiple schemas. The following XML 
 
<ex1:Root xmlns:ex1="http://www.example.com/ex1/"> 
  <ex2:Child xmlns:ex2="http://www.example.com/ex2/" />
</ex1:Root>
 
can either be validated by a single schema which defines one of the
target namespaces and imports another or by multiple schemas one for
each of the namespaces involved. 
 
Q2:
 XML document ( which of course must have a root element) would have its
definition in one schema only. the child elements which in case refer to
other schemas must be refered in the schema only.

A2: 

No. If the definition of the root element is a content model with a
wildcard (e.g. xs:any with namespace=##any) then no other schemas need
to be referenced in the schema where the root element is defined.
Instead depending on if the processContents on the wildcard is skip, lax
or strict then other schemas may or may not be needed to validate the
children of the root element. 

Q3: 

now how would the validating parser locate the definition of this
element. 

A3: 

This is an implementation specific question but I know that the
Microsoft validators have a number of options. a.) the user specifies
the schemas involved programmatically by adding them to a schema cache
then validating the instance document against all the cached schemas b.)
the schemas are specified using xsi:schemaLocation in the instance
document and c.) the schemas are located via following the
schemaLocation in an xs:import in the main schema. 

Q4: 

why would someone put a namespace with an element in the instance
document and not in its schema ?

A4: 

I assume the example involving wildcards already answers this question. 

--
PITHY WORDS OF WISDOM
In any contest between power and patience, bet on patience.     

This posting is provided "AS IS" with no warranties, and confers no
rights.



 
 
  _____  

From: Sanjay Dahiya, Noida [mailto:sanjay@noida.hcltech.com] 
Sent: Wednesday, September 04, 2002 8:55 AM
To: xmlschema-dev@w3.org



Hi All

Correct me if I am wrong anywhere in the following
One can comopse an XML schema using multiple schemas and multiple
namespaces so that definitions can be reused (makes perfect sense). 

For this purpose XML schema can have references to other schemas which
might have different namespaces. This is done by 'import' / 'include'
tags in the schema definition. Q1: what are the possible ways for doing
the same.  

The instance document reffering to this schema would be validated by
loading other schemas and looking for corresponding definitions in those
schemas. (good so far)

Now XML instance document can also contain references to multiple
namespaces and schema using schemaLocation and
noNamespaceSchemaLocation ( why multiple ??) 

Q2: XML document ( which of course must have a root element) would have
its definition in one schema only. the child elements which in case
refer to other schemas must be refered in the schema only.
Second for a validating parser what would be the precise set of rules
for locating the definition of an element that is mentioned in the
instance document.

Now to make things worse each element can refer to a namepace and supply
the prefix there itself (No idea where it is going now !!)  Q3: now how
would the validating parser locate the definition of this element. and
Q4: why would someone put a namespace with an element in the instance
document and not in its schema ?

looks like some of the constructs have been designed with non-validating
parsers in mind and others for validating ones. could someone clear
things a bit here.

thanks and regards
Sanjay 
Received on Wednesday, 4 September 2002 12:22:15 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:34 GMT