- 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
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:43:50 UTC