This is from release plan, made by Tinny
>Add feature http://apache.org/xml/features/nonvalidating/load-external-dtd
to >optionally ignore external DTD
For those who needs it now, the code below describes how to implement it.
Suppose we have own CParser class and member variable m_ignore,
telling the parser not to fail if DTD does not exists.
(Note. If DTD exists then it will be handled. It is not difficult to change
the code
to always ignore it )
----------------------------------------------------------------------------
--------------
#include <framework/MemBufInputSource.hpp>
#include <framework/LocalFileInputSource.hpp>
#include <framework/URLInputSource.hpp>
#include <internal/XMLScanner.hpp>
#include <util/PlatformUtils.hpp>
....
InputSource* CParser::resolveEntity (
const XMLCh* const publicId,
const XMLCh* const systemId )
{
unsigned int line, col;
XMLCh sysId[512];
XMLCh pubId[512];
// Actually there is a bug in Xerces code.
// There should be a const method getLastExtLocation
((XMLScanner&)xmlScanner).getLastExtLocation(
sysId, 512, pubId, 512, line, col );
InputSource* src = NULL;
try
{
XMLURL urlTmp(sysId, systemId );
if (urlTmp.isRelative())
{
ThrowXML
(
MalformedURLException
, XMLExcepts::URL_NoProtocolPresent
);
}
src = new URLInputSource(urlTmp);
}
catch(const MalformedURLException&)
{
// Its not a URL, so lets assume its a local file name.
src = new LocalFileInputSource( sysId, systemId );
// The file may not exist, so to prevent exception
// lets check it first
if( m_ignore )
{
FileHandle fsrc = XMLPlatformUtils::openFile(
src->getSystemId() );
if( fsrc == 0 )
{
// The file does not exist. Change it to empty buffer
src = new MemBufInputSource( NULL, 0, src->getSystemId() );
}
}
}
return src;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]