Yes you are correct. If you get the validation to function properly then the IgnoreWhitespace functionality will kick in. Your DTD problem is probably that the parser can't find the file. Take a look at the EntityResolver functionality, it will solve that problem for you.
Heck I'll throw in my implementation of an EntityResolver for you to use. Hook the sucker into the parser (setEntityResolver) and do a call to addEntity for each DTD you want to add to the parser OR do calls to addDirToPath to create a search path for the resolver to search. You'll figure it out. We use it ourselves and this is one piece of code I do not have to look at anymore. Although it contains classes that I will not give to you (cXMLString is to large), but it is an easy modification to make it work. Regards Erik Rydgren Mandarinen systems AB Sweden // // **************************************************************************** ***************** // cXML4CEntityResolver // **************************************************************************** ***************** // class cXML4CEntityResolver : public EntityResolver { CRITICAL_SECTION sMutex; struct sdEntity { sdEntity* psNext; cXMLString publicId; cXMLString systemId; cXMLString document; }; sdEntity* m_psHead; char* m_pzPath; public: cXML4CEntityResolver(); ~cXML4CEntityResolver(); void addEntity(const char* publicId, const char* systemId, const char* xmldocument); void addDirToPath(const char* pzDir); InputSource* resolveEntity(const XMLCh* const publicId, const XMLCh* const systemId); }; // // **************************************************************************** ***************** // cXML4CEntityResolver // **************************************************************************** ***************** // cXML4CEntityResolver::cXML4CEntityResolver() { InitializeCriticalSection(&sMutex); m_psHead = null; m_pzPath = null; } cXML4CEntityResolver::~cXML4CEntityResolver() { DeleteCriticalSection(&sMutex); while (m_psHead) { sdEntity* psLoop = m_psHead; m_psHead = m_psHead->psNext; delete psLoop; } delete m_pzPath; } void cXML4CEntityResolver::addEntity(const char* publicId, const char* systemId, const char* xmldocument) { EnterCriticalSection(&sMutex); sdEntity* psNewEntity = new sdEntity; psNewEntity->publicId = publicId; psNewEntity->systemId = systemId; psNewEntity->document = xmldocument; psNewEntity->psNext = m_psHead; m_psHead = psNewEntity; LeaveCriticalSection(&sMutex); } void cXML4CEntityResolver::addDirToPath(const char* pzDir) { EnterCriticalSection(&sMutex); if (!m_pzPath) { m_pzPath = new char[strlen(pzDir)+2]; strcpy(m_pzPath, pzDir); } else { bool bFound = false; { // Search to see if the dir already is in the path char* pzLoop = m_pzPath; while (!bFound && pzLoop) { // Fetch next dir from path char* pzEnd = strchr(pzLoop, ';'); if (pzEnd) *pzEnd = '\0'; // Compare the strings disregarding last char if it is a '\' int nDirLen = strlen(pzDir); int nLoopLen = strlen(pzLoop); if (pzDir[nDirLen-1] == '\\') nDirLen--; if (pzLoop[nLoopLen-1] == '\\') nLoopLen--; if (nDirLen == nLoopLen && strnicmp(pzLoop, pzDir, nDirLen) == 0) bFound = true; if (pzEnd) *pzEnd = ';'; if (pzEnd) pzLoop = pzEnd+1; else pzLoop = null; } } if (!bFound) { // Add the dir if not found char* pzTmp = new char[strlen(m_pzPath)+1+strlen(pzDir)+2]; strcpy(pzTmp, m_pzPath); strcat(pzTmp, ";"); strcat(pzTmp, pzDir); delete m_pzPath; m_pzPath = pzTmp; } } // Add traling \ to directory if (m_pzPath[strlen(m_pzPath)-1] != '\\') strcat(m_pzPath, "\\"); LeaveCriticalSection(&sMutex); } InputSource* cXML4CEntityResolver::resolveEntity ( const XMLCh* const publicId, const XMLCh* const systemId ) { InputSource* result = null; try { EnterCriticalSection(&sMutex); { // Loop through list searching for entity sdEntity* psLoop = m_psHead; bool bFound = false; while (!bFound && psLoop) { if (psLoop->publicId == cXMLString(publicId) && psLoop->systemId == cXMLString(systemId)) bFound = true; else psLoop = psLoop->psNext; } if (bFound) { result = new MemBufInputSource((const XMLByte*)(const char*) psLoop->document, psLoop->document.getLength(), "xmldocument", false); } } if (!result) { // Not found, search in path char* pzLoop = m_pzPath; while (!result && pzLoop) { // Fetch next dir from path char* pzEnd = strchr(pzLoop, ';'); if (pzEnd) *pzEnd = '\0'; cXMLString oPath(pzLoop); if (pzEnd) *pzEnd = ';'; LocalFileInputSource* fileinput = null; try { fileinput = new LocalFileInputSource(cXMLString(oPath), systemId); ifstream in; in.open(cXMLString(fileinput->getSystemId())); if (in.is_open()) result = fileinput; else delete fileinput; } catch (...) { delete fileinput; result = null; } if (pzEnd) pzLoop = pzEnd+1; else pzLoop = null; } } LeaveCriticalSection(&sMutex); } catch (cException&) { LeaveCriticalSection(&sMutex); throw; } catch (...) { LeaveCriticalSection(&sMutex); throw } return result; } -----Original Message----- From: Leitner, Sarah M. [Contractor] [mailto:[EMAIL PROTECTED]] Sent: den 14 januari 2003 21:08 To: '[EMAIL PROTECTED]' Subject: whitespace problem- help! To all, I have a DTD in my official code. What I sent was just a small piece of code to present the problem. But I am kind of lost on using the DTD. My first problem is that Xerces parses the code fine - as long as I delete the top-level line that says where the DTD is located. I also have to delete all comment lines. Is it to be assumed that the setIncludeIgnorableWhitespace option would work as in my previous example if the DTD was being parsed? I've also tried to loadGrammar, but haven't got that to work either. Sarah --------------------------------------------------------------------- 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]