If you are using DOMBuilder, you can use DOMBuilder::setEntityResolver, specifying an instance of a class derived from DOMEntityResolver.
In that class, override
   virtual DOMInputSource* resolveEntity
   (
       const   XMLCh* const    publicId
       , const XMLCh* const    systemId
       , const XMLCh* const    baseURI
   ) = 0;

returning a new Wrapper4InputSource(new LocalFileInputSource("location of visor.xsd")) when sysntemId==visor.xsd

Alberto

Roberto Rigamonti wrote:
Good afternoon, I'm always working on the same visor project and I have some troubles using the entity resolver mechanism. I've tried to understand its usage searching some examples with Google, but most of them concern a SAX parser, whereas I'm using a DOM parser. Looking in the mailing-list archives I've seen some posts on this argument, but they require the derivation of the XMLEntityResolver class and things like that, so they're far too complicated for my needs. What I have to do is the following: I have a schema file in the executable's directory (e.g. /home/roby/3DVisor/sandbox/bin), let's call it "visor.xsd". Then I have some temporary XML files placed in the /tmp directory and created with the following header:

<visor xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xsi:noNamespaceSchemaLocation="visor.xsd">

I have to "dynamically replace" the "visor.xsd" attribute in the XML file to the correct path of the schema file.
Is there a _simple_ way to do that? I've seen an example on
http://www.onlamp.com/pub/a/onlamp/2005/11/10/xerces_sax.html?page=3
that looks promising (the one using a SimpleEntityResolver), but regards a SAX parser. Is there a trick to force it to work also for a DOM parser?
Thanks in advance to anyone willing to help me.
                                      Roberto Rigamonti


Reply via email to