You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by er...@locus.apache.org on 2000/08/09 06:54:58 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/framework XMLParser.java

ericye      00/08/08 21:54:58

  Modified:    java/src/org/apache/xerces/framework XMLParser.java
  Log:
  add feature load-DTDGrammar.
  
  Revision  Changes    Path
  1.20      +54 -1     xml-xerces/java/src/org/apache/xerces/framework/XMLParser.java
  
  Index: XMLParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/framework/XMLParser.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- XMLParser.java	2000/06/23 02:36:58	1.19
  +++ XMLParser.java	2000/08/09 04:54:58	1.20
  @@ -90,7 +90,7 @@
   /**
    * This is the base class of all standard parsers.
    *
  - * @version $Id: XMLParser.java,v 1.19 2000/06/23 02:36:58 andyc Exp $
  + * @version $Id: XMLParser.java,v 1.20 2000/08/09 04:54:58 ericye Exp $
    */
   public abstract class XMLParser 
       implements XMLErrorReporter, XMLDocumentHandler.DTDHandler {
  @@ -132,6 +132,7 @@
           "http://apache.org/xml/features/validation/warn-on-undeclared-elemdef",
           "http://apache.org/xml/features/allow-java-encodings",
           "http://apache.org/xml/features/continue-after-fatal-error",
  +        "http://apache.org/xml/features/load-DTDGrammar"
       };
   
       /** Properties recognized by this parser. */
  @@ -592,6 +593,44 @@
           throws SAXNotRecognizedException, SAXNotSupportedException {
           return fValidator.getDynamicValidationEnabled();
       }
  +    /**
  +     * Allows the parser to have the choice to load DTD grammar when 
  +     * validation is off.
  +     * <p>
  +     * This method is the equivalent to the feature:
  +     * <pre>
  +     * http://apache.org/xml/features/load-DTDGrammar
  +     * </pre>
  +     *
  +     * @param loadDTDGrammar True to turn on the feature; false to
  +     *                turn off the feature.
  +     *
  +     * @see #getLoadDTDGrammar
  +     * @see #setFeature
  +     */
  +    protected void setLoadDTDGrammar(boolean loadDTDGrammar) 
  +        throws SAXNotRecognizedException, SAXNotSupportedException {
  +        if (fParseInProgress) {
  +            // REVISIT: Localize message
  +            throw new SAXNotSupportedException("http://apache.org/xml/features/load-DTDGrammar: parse is in progress");
  +        }
  +        try {
  +            fValidator.setLoadDTDGrammar(loadDTDGrammar);
  +        }
  +        catch (Exception ex) {
  +            throw new SAXNotSupportedException(ex.getMessage());
  +        }
  +    }
  +
  +    /**
  +     * Returns true if load DTD grammar is turned on in the XMLValiator.
  +     *
  +     * @see #setLoadDTDGrammar
  +     */
  +    protected boolean getLoadDTDGrammar() 
  +        throws SAXNotRecognizedException, SAXNotSupportedException {
  +        return fValidator.getLoadDTDGrammar();
  +    }
   
       /**
        * Sets whether an error is emitted when an attribute is redefined
  @@ -1115,6 +1154,14 @@
                   throw new SAXNotSupportedException(featureId);
               }
               //
  +            // http://apache.org/xml/features/validation/load-DTDGrammar
  +            //
  +            if (feature.equals("load-DTDGrammar")) {
  +                setLoadDTDGrammar(state);
  +                return;
  +            }
  +
  +            //
               // http://apache.org/xml/features/validation/default-attribute-values
               //
               if (feature.equals("validation/validate-datatypes")) {
  @@ -1262,6 +1309,12 @@
               if (feature.equals("validation/validate-content-models")) {
                   // REVISIT
                   throw new SAXNotRecognizedException(featureId);
  +            }
  +            //
  +            // http://apache.org/xml/features/validation/load-DTDGrammar
  +            //
  +            if (feature.equals("load-DTDGrammar")) {
  +                return getLoadDTDGrammar();
               }
               //
               // http://apache.org/xml/features/validation/validate-datatypes