RE: XML schema validation and namespaces

thanks, that makes it pretty clear just small doubt
 
1. Only in case of xs:any we need to specify the schema in instance
document, which is provision for extensible xml documents.
As in A1: 
if xs:any is not there in the schema, then the hierarchy root -> child must
be specified in the schema only, which itself will not be valid if schema
containing child is not imported (could be a ref or a complex type). 
so that means case 2 in A1 
"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" 
would occur in case of xs:any only. 
 
thanks again
Sanjay

-----Original Message-----
From: Dare Obasanjo [mailto:dareo@microsoft.com]
Sent: Wednesday, September 04, 2002 9:52 PM
To: Sanjay Dahiya, Noida
Cc: xmlschema-dev@w3.org
Subject: RE: XML schema validation and namespaces


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/
<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 Thursday, 5 September 2002 02:21:56 UTC