You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2005/06/19 19:21:25 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/jaxp SAXParserImpl.java

mrglavas    2005/06/19 10:21:25

  Modified:    java/src/org/apache/xerces/jaxp SAXParserImpl.java
  Log:
  Phase #1 of SAXParser reset. Restore initial handlers.
  
  Revision  Changes    Path
  1.28      +33 -11    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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- SAXParserImpl.java	16 Jun 2005 17:42:10 -0000	1.27
  +++ SAXParserImpl.java	19 Jun 2005 17:21:25 -0000	1.28
  @@ -19,21 +19,21 @@
   import java.util.Enumeration;
   import java.util.Hashtable;
   
  -import javax.xml.parsers.SAXParserFactory;
   import javax.xml.validation.Schema;
   
   import org.apache.xerces.impl.Constants;
  -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.apache.xerces.util.SAXMessageFormatter;
   import org.apache.xerces.util.SecurityManager;
   import org.apache.xerces.xs.AttributePSVI;
   import org.apache.xerces.xs.ElementPSVI;
   import org.apache.xerces.xs.PSVIProvider;
  +import org.xml.sax.EntityResolver;
  +import org.xml.sax.ErrorHandler;
  +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;
   
   /**
    * This is the implementation specific class for the
  @@ -75,6 +75,12 @@
       private String schemaLanguage = null;     // null means DTD
       private final Schema grammar;
       
  +    /** Initial ErrorHandler */
  +    private final ErrorHandler fInitErrorHandler;
  +    
  +    /** Initial EntityResolver */
  +    private final EntityResolver fInitEntityResolver;
  +    
       /**
        * Create a SAX parser with the associated features
        * @param features Hashtable of SAX features, may be null
  @@ -99,7 +105,11 @@
           // validation errors with a warning telling the user to set an
           // ErrorHandler.
           if (spf.isValidating()) {
  -            xmlReader.setErrorHandler(new DefaultValidationErrorHandler());
  +            fInitErrorHandler = new DefaultValidationErrorHandler();
  +            xmlReader.setErrorHandler(fInitErrorHandler);
  +        }
  +        else {
  +            fInitErrorHandler = xmlReader.getErrorHandler();
           }
   
           xmlReader.setFeature(VALIDATION_FEATURE, spf.isValidating());
  @@ -129,6 +139,9 @@
           this.grammar = spf.getSchema();
   
           setFeatures(features);
  +        
  +        // Initial EntityResolver
  +        fInitEntityResolver = xmlReader.getEntityResolver();
       }
   
       /**
  @@ -261,8 +274,17 @@
           return grammar;
       }
       
  -    // TODO: Add in implementation.
  -    public void reset() {}
  +    public void reset() {
  +        /** Restore various handlers. **/
  +        xmlReader.setContentHandler(null);
  +        xmlReader.setDTDHandler(null);
  +        if (xmlReader.getErrorHandler() != fInitErrorHandler) {
  +            xmlReader.setErrorHandler(fInitErrorHandler);
  +        }
  +        if (xmlReader.getEntityResolver() != fInitEntityResolver) {
  +            xmlReader.setEntityResolver(fInitEntityResolver);
  +        }
  +    }
       
       /*
        * PSVIProvider methods
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org