xerces-c-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jamison Adcock" <jadc...@cabcds.org>
Subject RE: Getting the "schemaLocation" from an XML document
Date Tue, 30 Jan 2007 20:28:19 GMT
Hi Alberto,
	Thanks for getting back to me so quickly.  I've figured out how
to force validation against a specific schema, but I still need to
figure out how to first look at the XML document and pull out its schema
reference (i.e., the value of "schemaLocation").  Does Xerces have this
capability somewhere?  I need to do this because the schema reference
may be wrong (either the filename or path).  Once I get the value of
schemaLocation, I can easily do a mapping and then validate the XML
against the right XSD file.
	So in short, I'm envisioning a three-step process: look at the
XML document and get the value of schemaLocation, do the mapping from
that value to the actual schema path, and finally do the validation
against that schema.

many thanks,

> -----Original Message-----
> From: Alberto Massari [mailto:amassari@datadirect.com] 
> Sent: Tuesday, January 30, 2007 2:10 PM
> To: c-users@xerces.apache.org
> Subject: Re: Getting the "schemaLocation" from an XML document
> 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.

View raw message