Hi, I originally posted this question a couple of days ago but did not get a resolution. I am very close to getting my xerces 2.3.0 application working but am having trouble getting my local entity resolver to work correctly when parsing an xml file that points to a SYSTEM DTD that is accessed via http. Since I don't have an internet connection when running the app, I have made an entity resolver that should point to a local copy of the dtd. The resolver is getting called OK and trying to point to the local dtd but the parser engine is still failing. One thing I also notice is that if I manually edit the XML to point to a local DTD, the parsing still fails if I have my entity resolver hooked up. That leads me to believe that my resolver is the problem spot. Any help in debugging this issue would be greatly appreciated. The specifics of my app are below.
Thanks in advance, --Hieu XML Format: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE Catalog SYSTEM "http://www.mydomain.com/Catalog.dtd"> <foo> <foo1> <foofield1 TableFieldID="id1" Value="value1" /> <foofield2 TableFieldID="id2" Value="value2" /> <foofield3 TableFieldID="id3" Value="value3" /> </foo1> </foo> Entity Resolver: class LocalDTDResolver : public DOMEntityResolver { public: // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- LocalDTDResolver() {}; ~LocalDTDResolver() {}; DOMInputSource * resolveEntity (const XMLCh *const publicId, const XMLCh *const systemId, const XMLCh *const baseURI); }; DOMInputSource * LocalDTDResolver::resolveEntity (const XMLCh *const publicId, const XMLCh *const systemId, const XMLCh *const baseURI) { char tempString[1024]; XMLCh localDTDFile[1024]; XMLCh externalDTDFile[1024]; XMLString::transcode("c:\\temp\\Catalog.dtd", localDTDFile, sizeof(localDTDFile)-1); XMLString::transcode("http://www.mydomain.com/Catalog.dtd", externalDTDFile, sizeof(externalDTDFile)-1); try { if ( XMLString::compareIString(systemId, externalDTDFile)==0 ) { AppendToLogFile("Found external DTD and resolving to local DTD"); // Return local copy of the dtd file return new Wrapper4InputSource( new LocalFileInputSource(localDTDFile)); } else { AppendToLogFile("No external DTD so returning NULL"); } } catch (...) { AppendToLogFile("resolveEntity() failed and caught error"); } // If no match, returning null makes process continue normally return NULL; } Parser: XercesDOMParser * gParser; LocalDTDResolver * gEntityResolver; gParser = new XercesDOMParser; gEntityResolver = new LocalDTDResolver(); XercesDOMParser::ValSchemes valScheme = XercesDOMParser::Val_Auto; bool doNamespaces = false; bool doSchema = false; bool doSchemaFullChecking = false; gParser->setValidationScheme(valScheme); gParser->setDoNamespaces(doNamespaces); gParser->setDoSchema(doSchema); gParser->setValidationSchemaFullChecking(doSchemaFullChecking); // set the entity resolver gParser->setEntityResolver((EntityResolver * const)gEntityResolver); // Parse the XML file, catching any XML exceptions that might propogate try { // Parse the XML file gParser->parse(xmlFilePath); } catch(...) { AppendToLogFile("Parser failed - entity resolver did not work"); return 0; } Need a new email address that people can remember Check out the new EudoraMail at http://www.eudoramail.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
