neilg       2002/10/08 14:45:45

  Modified:    java/src/org/apache/xerces/impl/xs XMLSchemaValidator.java
                        XMLSchemaLoader.java
               java/src/org/apache/xerces/impl/xs/traversers
                        XSDHandler.java
  Log:
  ensure that the allow-java-encodings and continue-after-fatal-error features are 
propagated from the main configuration to the parser responsible for parsing schema 
documents.
  
  Revision  Changes    Path
  1.114     +20 -4     
xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
  
  Index: XMLSchemaValidator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java,v
  retrieving revision 1.113
  retrieving revision 1.114
  diff -u -r1.113 -r1.114
  --- XMLSchemaValidator.java   4 Oct 2002 17:42:11 -0000       1.113
  +++ XMLSchemaValidator.java   8 Oct 2002 21:45:44 -0000       1.114
  @@ -179,9 +179,13 @@
       Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_AUGMENT_PSVI;
   
       /** Feature identifier: whether to recognize java encoding names */
  -    protected static final String ALLOW_JAVA_ENCODING =
  +    protected static final String ALLOW_JAVA_ENCODINGS =
       Constants.XERCES_FEATURE_PREFIX + Constants.ALLOW_JAVA_ENCODINGS_FEATURE;
   
  +    /** Feature identifier: whether to continue parsing a schema after a fatal 
error is encountered */
  +    protected static final String CONTINUE_AFTER_FATAL_ERROR =
  +    Constants.XERCES_FEATURE_PREFIX + Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE;
  +
       // property identifiers
   
       /** Property identifier: symbol table. */
  @@ -230,6 +234,8 @@
           SCHEMA_VALIDATION,
           DYNAMIC_VALIDATION,
           SCHEMA_FULL_CHECKING,
  +        ALLOW_JAVA_ENCODINGS,
  +        CONTINUE_AFTER_FATAL_ERROR,
       };
   
       /** Feature defaults. */
  @@ -244,6 +250,8 @@
           null, //Boolean.FALSE,
           null, //Boolean.FALSE,
           null, //Boolean.FALSE,
  +        null, //Boolean.FALSE,
  +        null, //Boolean.FALSE,
       };
   
       /** Recognized properties. */
  @@ -1363,8 +1371,16 @@
           // Copy the allow-java-encoding feature to the grammar loader.
           // REVISIT: what other fetures/properties do we want to copy?
           try {
  -            boolean jencoding = componentManager.getFeature(ALLOW_JAVA_ENCODING);
  -            fSchemaLoader.setFeature(ALLOW_JAVA_ENCODING, jencoding);
  +            boolean allowJavaEncodings = 
componentManager.getFeature(ALLOW_JAVA_ENCODINGS);
  +            fSchemaLoader.setFeature(ALLOW_JAVA_ENCODINGS, allowJavaEncodings);
  +        }
  +        catch (XMLConfigurationException e){
  +        }
  +
  +        // get continue-after-fatal-error feature
  +        try {
  +            boolean fatalError = 
componentManager.getFeature(CONTINUE_AFTER_FATAL_ERROR);
  +            fSchemaLoader.setFeature(CONTINUE_AFTER_FATAL_ERROR, fatalError);
           }
           catch (XMLConfigurationException e){
           }
  
  
  
  1.10      +12 -2     
xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java
  
  Index: XMLSchemaLoader.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XMLSchemaLoader.java      4 Oct 2002 13:33:26 -0000       1.9
  +++ XMLSchemaLoader.java      8 Oct 2002 21:45:45 -0000       1.10
  @@ -114,10 +114,15 @@
       protected static final String CONTINUE_AFTER_FATAL_ERROR =
           Constants.XERCES_FEATURE_PREFIX + 
Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE;
   
  +    /** Feature identifier: allow java encodings to be recognized when parsing 
schema docs. */
  +    protected static final String ALLOW_JAVA_ENCODINGS =
  +        Constants.XERCES_FEATURE_PREFIX + Constants.ALLOW_JAVA_ENCODINGS_FEATURE;
  +
       // recognized features:
       private static final String[] RECOGNIZED_FEATURES = {
           SCHEMA_FULL_CHECKING,
           CONTINUE_AFTER_FATAL_ERROR,
  +        ALLOW_JAVA_ENCODINGS,
       };
   
       // property identifiers
  @@ -171,6 +176,9 @@
       // is Schema Full Checking enabled
       private boolean fIsCheckedFully = false;
   
  +    // is allow-java-encodings enabled?
  +    private boolean fAllowJavaEncodings = false;
  +
       private SymbolTable fSymbolTable = null;
       private XMLErrorReporter fErrorReporter = new XMLErrorReporter (); 
       private XMLEntityResolver fEntityResolver = null;
  @@ -277,6 +285,8 @@
               fIsCheckedFully = state;
           } else if(featureId.equals(CONTINUE_AFTER_FATAL_ERROR)) {
               fErrorReporter.setFeature(CONTINUE_AFTER_FATAL_ERROR, state);
  +        } else if(featureId.equals(ALLOW_JAVA_ENCODINGS)) {
  +            fAllowJavaEncodings = state;
           } else {
               throw new 
XMLConfigurationException(XMLConfigurationException.NOT_RECOGNIZED, featureId);
           }
  @@ -429,7 +439,7 @@
           }
   
           fSchemaHandler.reset(fErrorReporter, fEntityResolver,
  -                fSymbolTable, fGrammarPool);
  +                fSymbolTable, fGrammarPool, fAllowJavaEncodings);
           if(fGrammarPool == null) {
               fDeclPool.reset();
               fSchemaHandler.setDeclPool(fDeclPool);
  
  
  
  1.56      +29 -7     
xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java
  
  Index: XSDHandler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- XSDHandler.java   24 Sep 2002 13:22:58 -0000      1.55
  +++ XSDHandler.java   8 Oct 2002 21:45:45 -0000       1.56
  @@ -119,6 +119,14 @@
    */
   public class XSDHandler {
   
  +    /** Feature identifier:  allow java encodings */
  +    protected static final String ALLOW_JAVA_ENCODINGS =
  +        Constants.XERCES_FEATURE_PREFIX + Constants.ALLOW_JAVA_ENCODINGS_FEATURE;
  +
  +    /** Feature identifier:  continue after fatal error */
  +    protected static final String CONTINUE_AFTER_FATAL_ERROR =
  +        Constants.XERCES_FEATURE_PREFIX + 
Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE;
  +
       /** Property identifier: error handler. */
       protected static final String ERROR_HANDLER =
           Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_HANDLER_PROPERTY;
  @@ -152,6 +160,9 @@
   
       protected XSDeclarationPool fDeclPool = null;
   
  +    // are java encodings allowed?
  +    private boolean fAllowJavaEncodings = false;
  +
       // These tables correspond to the symbol spaces defined in the
       // spec.
       // They are keyed with a QName (that is, String("URI,localpart) and
  @@ -191,7 +202,7 @@
       // stores instance document mappings between namespaces and schema hints
       private Hashtable fLocationPairs = null;
   
  -    // convinence methods
  +    // convenience methods
       private String null2EmptyString(String ns) {
           return ns == null ? XMLSymbols.EMPTY_STRING : ns;
       }
  @@ -1469,20 +1480,22 @@
       public void reset(XMLErrorReporter errorReporter,
                         XMLEntityResolver entityResolver,
                         SymbolTable symbolTable,
  -                      XMLGrammarPool grammarPool) {
  +                      XMLGrammarPool grammarPool,
  +                      boolean allowJavaEncodings) {
   
           fErrorReporter = errorReporter;
           fEntityResolver = entityResolver;
           fSymbolTable = symbolTable;
           fGrammarPool = grammarPool;
  +        fAllowJavaEncodings = allowJavaEncodings;
   
           resetSchemaParserErrorHandler();
           
       } // reset(ErrorReporter, EntityResolver, SymbolTable, XMLGrammarPool)
   
       void resetSchemaParserErrorHandler() {
  -        try {
  -            if (fSchemaParser != null) {
  +        if (fSchemaParser != null) {
  +            try {
                   XMLErrorHandler currErrorHandler =
                                        fErrorReporter.getErrorHandler();
                   // Setting a parser property can be much more expensive
  @@ -1492,9 +1505,18 @@
                       != fSchemaParser.getProperty(ERROR_HANDLER)) {
                       fSchemaParser.setProperty(ERROR_HANDLER, currErrorHandler);
                   }
  +            } catch (Exception e) {
  +            }
  +            // make sure continue-after-fatal-error and
  +            // allow-java-encodings set correctly:
  +            try {
  +                fSchemaParser.setFeature(CONTINUE_AFTER_FATAL_ERROR, 
fErrorReporter.getFeature(CONTINUE_AFTER_FATAL_ERROR));
  +            } catch (Exception e) {
  +            }
  +            try {
  +                fSchemaParser.setFeature(ALLOW_JAVA_ENCODINGS, fAllowJavaEncodings);
  +            } catch (Exception e) {
               }
  -        }
  -        catch (Exception e) {
           }
       } // resetSchemaParserErrorHandler()
   
  
  
  

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

Reply via email to