OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] using schemaLocation to point multiple same namespace sche

[ Lists Home | Date Index | Thread Index ]

Dare Obasanjo writes:
>Given that xsi:schemaLocation is considered to be a hint, implementations
are 
>given a lot of leeway in how they treat its contents if at all. 

<? schema below means W3C XML Schema ?>
I realize that xsi:schemaLocation and xsi:noNamespaceSchemaLocation are
hints, and thus get ignored or treated loosely.   But pointing to multiple
schemas in the same namespace is hard even if you use the API to control a
schema processor.

The examples below are with reference to Microsoft .NET's
XmlValidatingReader, but I wonder if the issues about multiple Schema files
crossed with multiple or same namespaces are more general.

Suppose I have an XML application that wishes to direct Schema validation of
another document, and wants to bring together a collection of schemas at
different locations to provide type definitions.  

QUESTION: Is it possible for the application to direct validation by
providing a set of schema locations, or does it have to combine together the
Schemas for the same namespace into one (using xsd:include)?  Remember that
xsd:import's schemaLocation is also a hint, so we can't have just one big
file that both imports and includes.

Naively (i.e., before today) I'd have thought you define a language that
uses this
 <? xml version="1.0 ?>
 <validate xmlns="urn:mystuff" 
           schemas="http://www.example.com/schemas/money.xsd 
                    http://commerce.example.com/schemas/po.xsd 
                    http://www.example.com/schemas/checks.xsd";
           document="file://po.xml" />
to mean "validate the po.xml file with the three xsd files specified, and
figure out their namespaces."

A processor for this validation language would get the locations of all the
schemas required for processing, collect them together along with the
targetNamespaces of each, and invoke a Schema validator on the specified
document. 

ANSWER: If you allow money.xsd and checks.xsd both to specify types in the
same namespace, it's hard to implement a processor for this validation
language.  At least with the Microsoft .NET Schema validator, I can find no
way to specify a generalized collection of Schemas to be used to validate a
document.  Instead, they must be broken out into one xsd file per namespace,
with additional Schema files brought in by xsd:include into the one schema
matching the targetNamespace.  To test this, I modified the .NET
XmlValidatingReader class used in the XsdValidate.cs example in
http://www.gotdotnet.com/userarea/filedetails.aspx?FileName=XsdValidate.zip,
which uses an XmlSchemaCollection to map from namespace URI to schema file.
As expected, the XmlSchemaCollection appears to keep only one xsd file per
namespace (the last, btw, not the first).  
 
Is this an implementation convenience as well, or is it an expression of
some deeper issue about schemas and document classes and namespaces?  

Leigh.

-----Original Message-----
From: Dare Obasanjo [mailto:dareo@microsoft.com] 
Sent: Wednesday, September 04, 2002 12:43 PM
To: Wo Chang; XML
Subject: RE: [xml-dev] using schemaLocation to point multiple same namespace
schemas


 
I can't find any where in the W3C XML Schema recommendation where this
is disallowed but I can understand why a schema validator would want to
disallow that to reduce implementation complexity. Given that
xsi:schemaLocation is considered to be a hint, implementations are given
a lot of leeway in how they treat its contents if at all. 

The Microsoft W3C XML Schema implementations pick the first schema they
see and associate that with the namespace then ignores the other
specified locations. 

You can simply include lib2.xsd and lib3.xsd in lib1.xsd to get the
effect that you desire. 


-- 
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. 

 
-----Original Message-----
From: Wo Chang [mailto:wchang@nist.gov] 
Sent: Wednesday, September 04, 2002 12:23 PM
To: 'XML'

Dear All,

I'm sure this question been asked before, sorry!

Is it possible to use xsi:schemaLocation within an instance document to
import two or more same namespace schema(s)?

ex: xsi:schemaLocation="http://abc/lib lib1.xsd
                        http://abc/lib lib2.xsd
                        http://abc/lib lib3.xsd">

So that, there is no need to use any prefix when referencing any
libx.xsd elements/attributes.  The idea is, lib.xsd (can be a set of
type libraries or elements) is getting too big, therefore, it got
separated by lib1.xsd, lib2.xsd, ...

By using "include" the above works since include will bring in the
additioanal schemas into the same namespace. However, by using
schemaLocation with multiple same namespace schemas seems like
complaining about re-defining the same namespace.  I know it works by
using different namespaces.

I really want to use schemaLocation to reference multiple schemas for
the same namespace from instance document, this way I can pick and
choose which ever libx.xsd that I want to work with instead of hard
coding them using "include" from a top-level schema.

I'm very much appreciated for any hints and pointers!

Best regards,

--Wo Chang


-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>

The list archives are at http://lists.xml.org/archives/xml-dev/

To subscribe or unsubscribe from this list use the subscription
manager: <http://lists.xml.org/ob/adm.pl>




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS