mrglavas    2005/09/07 19:13:30

  Modified:    java/src/org/apache/xerces/jaxp SAXParserImpl.java
  Log:
  Fixing a bug. Xerces' SAX parser implements both the Parser and XMLReader
  interfaces. If an application uses an instance both as a SAX1 and SAX2 parser
  it was possible that a document handler or a content handler from a previous
  parse would never be cleared.
  
  Revision  Changes    Path
  1.34      +33 -1     
xml-xerces/java/src/org/apache/xerces/jaxp/SAXParserImpl.java
  
  Index: SAXParserImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/jaxp/SAXParserImpl.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- SAXParserImpl.java        21 Jun 2005 17:19:08 -0000      1.33
  +++ SAXParserImpl.java        8 Sep 2005 02:13:30 -0000       1.34
  @@ -45,12 +45,14 @@
   import org.apache.xerces.xs.PSVIProvider;
   import org.xml.sax.EntityResolver;
   import org.xml.sax.ErrorHandler;
  +import org.xml.sax.HandlerBase;
   import org.xml.sax.InputSource;
   import org.xml.sax.Parser;
   import org.xml.sax.SAXException;
   import org.xml.sax.SAXNotRecognizedException;
   import org.xml.sax.SAXNotSupportedException;
   import org.xml.sax.XMLReader;
  +import org.xml.sax.helpers.DefaultHandler;
   
   /**
    * This is the implementation specific class for the
  @@ -272,6 +274,36 @@
           return xmlReader.getProperty(name);
       }
       
  +    public void parse(InputSource is, DefaultHandler dh)
  +        throws SAXException, IOException {
  +        if (is == null) {
  +            throw new IllegalArgumentException();
  +        }
  +        if (dh != null) {
  +            xmlReader.setContentHandler(dh);
  +            xmlReader.setEntityResolver(dh);
  +            xmlReader.setErrorHandler(dh);
  +            xmlReader.setDTDHandler(dh);
  +            xmlReader.setDocumentHandler(null);
  +        }
  +        xmlReader.parse(is);
  +    }
  +    
  +    public void parse(InputSource is, HandlerBase hb)
  +        throws SAXException, IOException {
  +        if (is == null) {
  +            throw new IllegalArgumentException();
  +        }
  +        if (hb != null) {
  +            xmlReader.setDocumentHandler(hb);
  +            xmlReader.setEntityResolver(hb);
  +            xmlReader.setErrorHandler(hb);
  +            xmlReader.setDTDHandler(hb);
  +            xmlReader.setContentHandler(null);
  +        }
  +        xmlReader.parse(is);
  +    }
  +     
       public Schema getSchema() {
           return grammar;
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to