[jdom-interest] Is BuilderErrorHandler redundant ?
Koller, Shmuel
Shmuel_Koller at bmc.com
Sun May 11 17:57:23 PDT 2003
Parsing piece of code:
////////////////////////
private void init(String xmlMessage, boolean validate) throws Exception
{
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
factory.setValidating(validate);
try
{
DocumentBuilder builder = factory.newDocumentBuilder();
builder.setErrorHandler(new SAXErrorHandler());
xmlDocument = builder.parse(new
java.io.ByteArrayInputStream(xmlMessage.getBytes(), 0,
xmlMessage.length()));
}
catch(SAXException sxe)
{
/////////////////////////////////
I inherited above code (except for setErrorHandler) - was told it is SAX
traversal using Xerces underneath JDOM API.
Handler class:
package ...... same as above
import org.jdom.input.BuilderErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import for logging
public class SAXErrorHandler extends BuilderErrorHandler {
public void warning(SAXParseException spe) throws SAXException {
Logger.error(this.getClass(),"Warning in " + spe.getSystemId() +
" at line " + spe.getLineNumber() +
" column= " + spe.getColumnNumber());
}
public void error(SAXParseException spe) throws SAXException {
Logger.error(this.getClass(),"Error in " + spe.getSystemId() +
" at line " + spe.getLineNumber() +
" column= " + spe.getColumnNumber());
throw(spe);
}
public void fatalError(SAXParseException spe) throws SAXException {
Logger.error(this.getClass(),"FatalError in " +
spe.getSystemId() +
" at line " + spe.getLineNumber() +
" column= " + spe.getColumnNumber());
throw(spe);
}
}
///////////////////////////////////////////////////
Thanks, Shmuel Koller
-----Original Message-----
From: Jason Hunter [mailto:jhunter at servlets.com]
Sent: Mon, May 12, 2003 3:35 AM
To: Koller, Shmuel
Cc: jdom-interest at jdom.org
Subject: Re: [jdom-interest] Is BuilderErrorHandler redundant ?
Without sending in your code, it's going to be very hard for anyone to
figure out what's wrong.
-jh-
"Koller, Shmuel" wrote:
>
> Uses of Class
> org.jdom.input.BuilderErrorHandler
>
> No usage of org.jdom.input.BuilderErrorHandler
>
////////////////////////////////////////////////////////////////////////////
>
////////////////////////////////////////////////////////////////////////////
> /////////
> Can it be that this class (in jdom-b9) is redundant ?
>
> I cannot drive it, and keep getting messages below even that I do
> setErrorHandler to an instance of a class that extends BuilderErrorHandler
> before the Parsing.
>
> How do I implement the semantics of SAX ErrorHandler with JDOM, if
possible
> at all.
>
> Thanks in advance, Shmuel Koller, BMC
>
> 2003-05-12 02:41:23,375 ERROR [HttpProcessor[8080][2]] STDERR - Warning:
> validation was turned on but an org.xml.sax.ErrorHandler was not
> 2003-05-12 02:41:23,378 ERROR [HttpProcessor[8080][2]] STDERR - set, which
> is probably not what is desired. Parser will use a default
> 2003-05-12 02:41:23,381 ERROR [HttpProcessor[8080][2]] STDERR -
ErrorHandler
> to print the first 10 errors. Please call
> 2003-05-12 02:41:23,383 ERROR [HttpProcessor[8080][2]] STDERR - the
> 'setErrorHandler' method to fix this.
>
> _______________________________________________
> To control your jdom-interest membership:
>
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
More information about the jdom-interest
mailing list