Hi Jamison,
you can force a specific schema to be used in validation by using
parser->setExternalSchemaLocation("namespace_uri schema_file");
alternatively, if your XML file is allowed to point to other schemas,
you should register an XMLEntityResolver handler, and inside its
resolveEntity() callback verify that the parser is trying to open the
schema for the namespace you are waiting, and return an instance of
LocalFileInputSource pointing to the schema you want to force.
Hope this helps,
Alberto
At 13.23 30/01/2007 -0500, Jamison Adcock wrote:
Hi,
I'm somewhat familiar with XML documents, XSD schemas, and Xerces,
but I must admit I am relatively new to all three. I understand that a
schema reference in an XML document is just a hint, and when parsing an
XML document you can use loadGrammar() to tell the DOMBuilder object to
use a specific XSD schema file to validate that document.
My question is this: is there a way to do some sort of preparsing of
an XML document so I can pull the "schemaLocation" from that document
prior to doing any validation? I want to do this because I need to map
the "schemaLocation" to the actual local XSD schema file I would like to
use for validation.
Also, just to make things even more fun, schemas can import other
schemas. From what I've seen, this doesn't pose any problems for
Xerces, so long as the imported schemas are all in the same directory as
the importing schema. However, is there a way to turn this feature off
in Xerces and explicitly specify all the schema files I want to use to
validate an XML document?
This seems like something Xerces would support, and perhaps I'm
missing something. I've hunted through the API documentation, but I
have not come across anything that looked like what I want. Any
pointers would be greatly appreciated,
thanks,
-Jamison
p.s.: Sorry if anyone received this email twice... I had some issues
subscribing & I wasn't sure if this email got to the list.