Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/sax
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13512/src/org/htmlparser/sax
Modified Files:
XMLReader.java
Log Message:
Add parse(InputSource) suggested by Jamie McCrindle.
Index: XMLReader.java
===================================================================
RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/sax/XMLReader.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** XMLReader.java 12 Apr 2005 11:27:43 -0000 1.2
--- XMLReader.java 13 May 2005 10:44:15 -0000 1.3
***************
*** 28,31 ****
--- 28,33 ----
import java.io.IOException;
+ import org.htmlparser.lexer.Lexer;
+ import org.htmlparser.lexer.Page;
import org.xml.sax.ContentHandler;
***************
*** 507,513 ****
throws IOException, SAXException
{
! throw new SAXException ("parse (InputSource input) is not yet supported");
! }
/**
--- 509,552 ----
throws IOException, SAXException
{
! Locator locator;
! ParserFeedback feedback;
+ if (null != mContentHandler)
+ try
+ {
+ mParser = new Parser (
+ new Lexer (
+ new Page (
+ input.getByteStream (),
+ input.getEncoding ())));
+ locator = new Locator (mParser);
+ if (null != mErrorHandler)
+ feedback = new Feedback (mErrorHandler, locator);
+ else
+ feedback = new DefaultParserFeedback (0);
+ mParser.setFeedback (feedback);
+ mContentHandler.setDocumentLocator (locator);
+ try
+ {
+ mContentHandler.startDocument ();
+ for (NodeIterator iterator = mParser.elements ();
+ iterator.hasMoreNodes ();
+ doSAX (iterator.nextNode ()));
+ mContentHandler.endDocument ();
+ }
+ catch (SAXException se)
+ {
+ if (null != mErrorHandler)
+ mErrorHandler.fatalError (new SAXParseException (
+ "contentHandler threw me", locator, se));
+ }
+ }
+ catch (ParserException pe)
+ {
+ if (null != mErrorHandler)
+ mErrorHandler.fatalError (new SAXParseException (
+ pe.getMessage (), "", "", 0, 0));
+ }
+ }
/**
|