Hi Guillaume, The JAXP 1.3 Validation API is better suited for what you want to do. If you use a Schema [1] (created by the SchemaFactory [2]) for validation any xsi: schema location hints in your document will be ignored.
Thanks. [1] http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/parsers/SAXParserFactory.html#setSchema(javax.xml.validation.Schema) [2] http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/validation/SchemaFactory.html Michael Glavassevich XML Parser Development IBM Toronto Lab E-mail: [EMAIL PROTECTED] E-mail: [EMAIL PROTECTED] Guillaume Laurent <[EMAIL PROTECTED]> wrote on 03/03/2008 08:54:10 AM: > Hi all, > > I'm currently scratching my head over the following problem. I have a > validating parser for which the reference schema is specified through code > ( setAttribute(JAXP_SCHEMA_SOURCE, schema); ). The reference schema has a > target namespace. The parser works fine, but surprisingly completelyfails to > detect an file which has both a different namespace and a reference to its > own schema. > > To sum up, given the following schema : > > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > targetNamespace="official/namespace" > ... > > and the following code : > > setAttribute(JAXP_SCHEMA_SOURCE, "path/to/official/schema") > > Then a document like this : > > <foo xmlns="different/namespace" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="different/namespace path/to/different/schema.xsd"> > > will be seen as valid by the parser. > > Is there a way to get the parser to reject the document, without resorting to > manuall checking the document's namespace ? > > Thanks, > > -- > Guillaume Laurent > OASIS, Inria Sophia-Antipolis > http://www-sop.inria.fr/oasis/ > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]