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

Re: validate against multiple schemas

From: Michael Ryan Bannon <mrbannon@uwaterloo.ca>
Date: Fri, 20 Sep 2002 10:56:50 -0400
Message-ID: <004201c260b5$f3a02120$445c6181@uwaterloo.ca>
To: <noah_mendelsohn@us.ibm.com>
Cc: <xmlschema-dev@w3.org>

Hi,

Thanks for the response.  Unfortunately, this might not work.  The scenario
is the following:

1) I recieve an XML file that uses the hospital schema
2) I want to mark it up with a prototype attribute
3) I add the prototype attribute and schema definition to the XML file

The problem is, I will have no prior knowledge of the hospital schema.  The
"name" element may not (most likely will not) allow those two scenarios you
described.

So, I guess my question is, is there a way to validate against multiple
schemas without changing the schemas themselves?  Actually, the only schema
I can totally control is the prototype schema, but I doubt that helps.

Is there any way I can manipulate the parser?

thanks,

Ryan

----- Original Message -----
From: <noah_mendelsohn@us.ibm.com>
To: "Michael Ryan Bannon" <mrbannon@uwaterloo.ca>
Cc: <xmlschema-dev@w3.org>
Sent: Friday, September 20, 2002 10:41 AM
Subject: Re: validate against multiple schemas


> 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"?>
> <patientRecord
> xmlns:hosp="http://www.swen.uwaterloo.ca/~mrbannon/HOSPITAL"
>     xmlns:proto=http://www.swen.uwaterloo.ca/~mrbannon/PROTOTYPE
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>
>   <hosp:name proto:dataItem="true">
>    <hosp:surname>Bannon</hosp:surname>
>    <hosp:givenNames>Michael Ryan</hosp:givenNames>
>    <hosp:title>Mr.</hosp:title>
>   </hosp:name>
> </hosp:patientRecord>
>
>
> 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:
>
>         <import
> targetNamespace="http://www.swen.uwaterloo.ca/~mrbannon/PROTOTYPE"
>                      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:53:26 GMT

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