You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Manfred Lotz <ma...@arcor.de> on 2012/05/18 18:54:14 UTC
Strange SAX2Count behaviour
Hi there,
I was playing with SAX2Count and among others I tried the following 2
test cases where I took the xml stuff from the samples as well.
1. I have a personal.xml where I changed the DTD name to something
which does not exist.
When now calling: SAX2Count -v=never personal.xml
I get
Fatal Error at file ....
Message: unable to open DTD document ...
2. I have a personal-schema.xml where I changed the schema name to
something not existing.
When now calling: SAX2Count -v=never personal-schema.xml
I get
Warning at file...
Message: unable to open primary document entity ....
Question: Why do I get a warning in case 2 but a fatal erros in case 1?
What could I do to prevent the DTD not found message to be fatal.
--
Manfred
Re: Strange SAX2Count behaviour
Posted by Manfred Lotz <ma...@arcor.de>.
On Fri, 18 May 2012 18:54:14 +0200
Manfred Lotz <ma...@arcor.de> wrote:
> Hi there,
> I was playing with SAX2Count and among others I tried the following 2
> test cases where I took the xml stuff from the samples as well.
>
> 1. I have a personal.xml where I changed the DTD name to something
> which does not exist.
>
> When now calling: SAX2Count -v=never personal.xml
> I get
>
> Fatal Error at file ....
> Message: unable to open DTD document ...
>
> 2. I have a personal-schema.xml where I changed the schema name to
> something not existing.
>
> When now calling: SAX2Count -v=never personal-schema.xml
> I get
>
> Warning at file...
> Message: unable to open primary document entity ....
>
>
> Question: Why do I get a warning in case 2 but a fatal erros in case
> 1? What could I do to prevent the DTD not found message to be fatal.
>
>
>
Well I added this in the error handler which does work:
void SAX2CountHandlers::fatalError(const SAXParseException& e) {
const XMLCh *emsg = e.getMessage();
const XMLCh *dtdmsg = XMLString::transcode("unable to open DTD
document");
// We want to make it a warning if dtd will not be found
if ( XMLString::compareString(emsg, dtdmsg) ) {
warning(e);
return;
}
fSawErrors = true;
XERCES_STD_QUALIFIER cerr << "\nFatal Error at file " <<
StrX(e.getSystemId()) << ", line " << e.getLineNumber()
<< ", char " << e.getColumnNumber()
<< "\n Message: " <<
StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl; }
However, I could imagine there is something better I could do.
--
Manfred