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

Re: validate against multiple schemas

From: <noah_mendelsohn@us.ibm.com>
Date: Fri, 20 Sep 2002 10:41:41 -0400
To: "Michael Ryan Bannon" <mrbannon@uwaterloo.ca>
Cc: xmlschema-dev@w3.org
Message-ID: <OFB5EFB293.1C7186ED-ON85256C3A.00502838@lotus.com>

Michael Ryan Bannon asks:

>> What I want to happen is for a parser to validate all the "hospial" 
>> elements agains the "hospital" schema and the "proto" attribute 
>> against the "proto" schema. 

The answer is yes absolutely, this is the intended usage although some of 
your terminology is a bit off.  The correct way to say it would be:

"What I want to happen is for a parser to validate all the "hospial" 
elements agains the "hospital" schema document and the "proto" attribute 
against the "proto"  schema document."  I explain why these terms are used 
below.  First, here's what you need to do:

Your example was:

<?xml version="1.0"?>

  <hosp:name proto:dataItem="true">
   <hosp:givenNames>Michael Ryan</hosp:givenNames>

The main question is: what' is the declaration for the hosp:name element? 
That hosp schema better do one of two things to make this work:

* It could specify <xsd:anyAttribute processContents="strict">, which 
would allow any attribute, including proto:dataItem, and would force 
validation of any attribute found (you can also use processContents="lax', 
but that's a bit trickier....no need in this example.)

* It could explicitly <import> the proto namespace, and then in the 
declaration for hosp:name list:

        <xsd:attribute ref="proto:dataItem"/>

(I've presumed all the obvious namespace declarations.)  You then have to 
make sure your schema processor is using the two schema documents you 
want.  Indeed, the terminology is that there is one "schema", which is the 
combination of information from those two documents.  Your document is 
then validated against the net schema, which is for both namespaces.  One 
way to tell your processor where to find the schema for proto is to 
include a hint in the import:

                     schemaLocation="...uri of your schema file for proto 
goes here"/>

The processor doesn't have to honor the hint, but many do. 

I hope this helps.

Noah Mendelsohn                              Voice: 1-617-693-4036
IBM Corporation                                Fax: 1-617-693-8676
One Rogers Street
Cambridge, MA 02142
Received on Friday, 20 September 2002 10:43:50 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:05 UTC