src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java

Print this page




   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Copyright 2001-2005 The Apache Software Foundation.
   7  *
   8  * Licensed under the Apache License, Version 2.0 (the "License");
   9  * you may not use this file except in compliance with the License.
  10  * You may obtain a copy of the License at
  11  *
  12  *      http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 package com.sun.org.apache.xerces.internal.parsers;
  22 
  23 import java.io.File;
  24 import java.io.IOException;
  25 import java.util.ArrayList;
  26 import java.util.HashMap;
  27 import java.util.Locale;
  28 import java.util.Properties;
  29 import javax.xml.XMLConstants;
  30 
  31 import com.sun.org.apache.xerces.internal.impl.Constants;
  32 import com.sun.org.apache.xerces.internal.impl.XML11DTDScannerImpl;
  33 import com.sun.org.apache.xerces.internal.impl.XML11DocumentScannerImpl;
  34 import com.sun.org.apache.xerces.internal.impl.XML11NSDocumentScannerImpl;
  35 import com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl;
  36 import com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl;
  37 import com.sun.org.apache.xerces.internal.impl.XMLEntityHandler;
  38 import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
  39 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
  40 import com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl;
  41 import com.sun.org.apache.xerces.internal.impl.XMLVersionDetector;
  42 import com.sun.org.apache.xerces.internal.impl.dtd.XML11DTDProcessor;
  43 import com.sun.org.apache.xerces.internal.impl.dtd.XML11DTDValidator;
  44 import com.sun.org.apache.xerces.internal.impl.dtd.XML11NSDTDValidator;
  45 import com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDProcessor;
  46 import com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator;
  47 import com.sun.org.apache.xerces.internal.impl.dtd.XMLNSDTDValidator;
  48 import com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory;
  49 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
  50 import com.sun.org.apache.xerces.internal.impl.validation.ValidationManager;
  51 import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator;
  52 import com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter;
  53 import com.sun.org.apache.xerces.internal.util.FeatureState;
  54 import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings;
  55 import com.sun.org.apache.xerces.internal.util.PropertyState;
  56 import com.sun.org.apache.xerces.internal.util.Status;
  57 import com.sun.org.apache.xerces.internal.util.SymbolTable;
  58 import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
  59 import com.sun.org.apache.xerces.internal.xni.XMLDTDContentModelHandler;
  60 import com.sun.org.apache.xerces.internal.xni.XMLDTDHandler;
  61 import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
  62 import com.sun.org.apache.xerces.internal.xni.XMLLocator;
  63 import com.sun.org.apache.xerces.internal.xni.XNIException;
  64 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
  65 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponent;
  66 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
  67 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
  68 import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDScanner;
  69 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentScanner;
  70 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
  71 import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;
  72 import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
  73 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
  74 import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration;
  75 
  76 /**
  77  * This class is the configuration used to parse XML 1.0 and XML 1.1 documents.
  78  *


 261 
 262     protected static final String VALIDATION_MANAGER =
 263         Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATION_MANAGER_PROPERTY;
 264 
 265     /** Property identifier: JAXP schema language / DOM schema-type. */
 266     protected static final String JAXP_SCHEMA_LANGUAGE =
 267         Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE;
 268 
 269     /** Property identifier: JAXP schema source/ DOM schema-location. */
 270     protected static final String JAXP_SCHEMA_SOURCE =
 271         Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE;
 272 
 273     /** Property identifier: locale. */
 274     protected static final String LOCALE =
 275         Constants.XERCES_PROPERTY_PREFIX + Constants.LOCALE_PROPERTY;
 276 
 277     /** Property identifier: Schema DV Factory */
 278     protected static final String SCHEMA_DV_FACTORY =
 279         Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_DV_FACTORY_PROPERTY;
 280 
 281     /** Property identifier: access to external dtd */
 282     protected static final String ACCESS_EXTERNAL_DTD = XMLConstants.ACCESS_EXTERNAL_DTD;

 283 
 284     /** Property identifier: access to external schema */
 285     protected static final String ACCESS_EXTERNAL_SCHEMA = XMLConstants.ACCESS_EXTERNAL_SCHEMA;
 286 
 287     // debugging
 288 
 289     /** Set to true and recompile to print exception stack trace. */
 290     protected static final boolean PRINT_EXCEPTION_STACK_TRACE = false;
 291 
 292     //
 293     // Data
 294     //
 295 
 296         protected SymbolTable fSymbolTable;
 297     protected XMLInputSource fInputSource;
 298     protected ValidationManager fValidationManager;
 299         protected XMLVersionDetector fVersionDetector;
 300     protected XMLLocator fLocator;
 301         protected Locale fLocale;
 302 
 303         /** XML 1.0 Components. */
 304         protected ArrayList fComponents;
 305 


 518                 ENTITY_MANAGER,
 519                 DOCUMENT_SCANNER,
 520                 DTD_SCANNER,
 521                 DTD_PROCESSOR,
 522                 DTD_VALIDATOR,
 523                 DATATYPE_VALIDATOR_FACTORY,
 524                 VALIDATION_MANAGER,
 525                 SCHEMA_VALIDATOR,
 526                 XML_STRING,
 527                 XMLGRAMMAR_POOL,
 528                 JAXP_SCHEMA_SOURCE,
 529                 JAXP_SCHEMA_LANGUAGE,
 530                 // NOTE: These shouldn't really be here but since the XML Schema
 531                 //       validator is constructed dynamically, its recognized
 532                 //       properties might not have been set and it would cause a
 533                 //       not-recognized exception to be thrown. -Ac
 534                 SCHEMA_LOCATION,
 535                 SCHEMA_NONS_LOCATION,
 536                 LOCALE,
 537                 SCHEMA_DV_FACTORY,
 538                 ACCESS_EXTERNAL_DTD,
 539                 ACCESS_EXTERNAL_SCHEMA
 540         };
 541         addRecognizedProperties(recognizedProperties);
 542 
 543         if (symbolTable == null) {
 544                 symbolTable = new SymbolTable();
 545         }
 546         fSymbolTable = symbolTable;
 547         fProperties.put(SYMBOL_TABLE, fSymbolTable);
 548 
 549         fGrammarPool = grammarPool;
 550         if (fGrammarPool != null) {
 551             fProperties.put(XMLGRAMMAR_POOL, fGrammarPool);
 552         }
 553 
 554         fEntityManager = new XMLEntityManager();
 555                 fProperties.put(ENTITY_MANAGER, fEntityManager);
 556         addCommonComponent(fEntityManager);
 557 
 558         fErrorReporter = new XMLErrorReporter();
 559         fErrorReporter.setDocumentLocator(fEntityManager.getEntityScanner());


 567         fDTDScanner = new XMLDTDScannerImpl();
 568                 fProperties.put(DTD_SCANNER, fDTDScanner);
 569         addComponent((XMLComponent) fDTDScanner);
 570 
 571         fDTDProcessor = new XMLDTDProcessor();
 572                 fProperties.put(DTD_PROCESSOR, fDTDProcessor);
 573         addComponent((XMLComponent) fDTDProcessor);
 574 
 575         fDTDValidator = new XMLNSDTDValidator();
 576                 fProperties.put(DTD_VALIDATOR, fDTDValidator);
 577         addComponent(fDTDValidator);
 578 
 579         fDatatypeValidatorFactory = DTDDVFactory.getInstance();
 580                 fProperties.put(DATATYPE_VALIDATOR_FACTORY, fDatatypeValidatorFactory);
 581 
 582         fValidationManager = new ValidationManager();
 583                 fProperties.put(VALIDATION_MANAGER, fValidationManager);
 584 
 585         fVersionDetector = new XMLVersionDetector();
 586 
 587         //FEATURE_SECURE_PROCESSING is true, see the feature above
 588         String accessExternal =  SecuritySupport.getDefaultAccessProperty(
 589                 Constants.SP_ACCESS_EXTERNAL_DTD, Constants.EXTERNAL_ACCESS_DEFAULT);
 590         fProperties.put(ACCESS_EXTERNAL_DTD, accessExternal);
 591 
 592         accessExternal =  SecuritySupport.getDefaultAccessProperty(
 593                 Constants.SP_ACCESS_EXTERNAL_SCHEMA, Constants.EXTERNAL_ACCESS_DEFAULT);
 594         fProperties.put(ACCESS_EXTERNAL_SCHEMA, accessExternal);
 595 
 596         // add message formatters
 597         if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
 598             XMLMessageFormatter xmft = new XMLMessageFormatter();
 599             fErrorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);
 600             fErrorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);
 601         }
 602 
 603         // set locale
 604         try {
 605             setLocale(Locale.getDefault());
 606         } catch (XNIException e) {
 607             // do nothing
 608             // REVISIT: What is the right thing to do? -Ac
 609         }
 610 
 611                 fConfigUpdated = false;
 612 
 613     } // <init>(SymbolTable,XMLGrammarPool)
 614 
 615     //




   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Copyright 2001-2005 The Apache Software Foundation.
   7  *
   8  * Licensed under the Apache License, Version 2.0 (the "License");
   9  * you may not use this file except in compliance with the License.
  10  * You may obtain a copy of the License at
  11  *
  12  *      http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 package com.sun.org.apache.xerces.internal.parsers;
  22 

  23 import java.io.IOException;
  24 import java.util.ArrayList;
  25 import java.util.HashMap;
  26 import java.util.Locale;

  27 import javax.xml.XMLConstants;
  28 
  29 import com.sun.org.apache.xerces.internal.impl.Constants;
  30 import com.sun.org.apache.xerces.internal.impl.XML11DTDScannerImpl;
  31 import com.sun.org.apache.xerces.internal.impl.XML11DocumentScannerImpl;
  32 import com.sun.org.apache.xerces.internal.impl.XML11NSDocumentScannerImpl;
  33 import com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl;
  34 import com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl;
  35 import com.sun.org.apache.xerces.internal.impl.XMLEntityHandler;
  36 import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
  37 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
  38 import com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl;
  39 import com.sun.org.apache.xerces.internal.impl.XMLVersionDetector;
  40 import com.sun.org.apache.xerces.internal.impl.dtd.XML11DTDProcessor;
  41 import com.sun.org.apache.xerces.internal.impl.dtd.XML11DTDValidator;
  42 import com.sun.org.apache.xerces.internal.impl.dtd.XML11NSDTDValidator;
  43 import com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDProcessor;
  44 import com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator;
  45 import com.sun.org.apache.xerces.internal.impl.dtd.XMLNSDTDValidator;
  46 import com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory;
  47 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
  48 import com.sun.org.apache.xerces.internal.impl.validation.ValidationManager;
  49 import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator;
  50 import com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter;
  51 import com.sun.org.apache.xerces.internal.util.FeatureState;
  52 import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings;
  53 import com.sun.org.apache.xerces.internal.util.PropertyState;

  54 import com.sun.org.apache.xerces.internal.util.SymbolTable;
  55 import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
  56 import com.sun.org.apache.xerces.internal.xni.XMLDTDContentModelHandler;
  57 import com.sun.org.apache.xerces.internal.xni.XMLDTDHandler;
  58 import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
  59 import com.sun.org.apache.xerces.internal.xni.XMLLocator;
  60 import com.sun.org.apache.xerces.internal.xni.XNIException;
  61 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
  62 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponent;
  63 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
  64 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
  65 import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDScanner;
  66 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentScanner;
  67 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
  68 import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;
  69 import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
  70 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
  71 import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration;
  72 
  73 /**
  74  * This class is the configuration used to parse XML 1.0 and XML 1.1 documents.
  75  *


 258 
 259     protected static final String VALIDATION_MANAGER =
 260         Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATION_MANAGER_PROPERTY;
 261 
 262     /** Property identifier: JAXP schema language / DOM schema-type. */
 263     protected static final String JAXP_SCHEMA_LANGUAGE =
 264         Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE;
 265 
 266     /** Property identifier: JAXP schema source/ DOM schema-location. */
 267     protected static final String JAXP_SCHEMA_SOURCE =
 268         Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE;
 269 
 270     /** Property identifier: locale. */
 271     protected static final String LOCALE =
 272         Constants.XERCES_PROPERTY_PREFIX + Constants.LOCALE_PROPERTY;
 273 
 274     /** Property identifier: Schema DV Factory */
 275     protected static final String SCHEMA_DV_FACTORY =
 276         Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_DV_FACTORY_PROPERTY;
 277 
 278     /** Property identifier: Security property manager. */
 279     private static final String XML_SECURITY_PROPERTY_MANAGER =
 280             Constants.XML_SECURITY_PROPERTY_MANAGER;
 281 


 282 
 283     // debugging
 284 
 285     /** Set to true and recompile to print exception stack trace. */
 286     protected static final boolean PRINT_EXCEPTION_STACK_TRACE = false;
 287 
 288     //
 289     // Data
 290     //
 291 
 292         protected SymbolTable fSymbolTable;
 293     protected XMLInputSource fInputSource;
 294     protected ValidationManager fValidationManager;
 295         protected XMLVersionDetector fVersionDetector;
 296     protected XMLLocator fLocator;
 297         protected Locale fLocale;
 298 
 299         /** XML 1.0 Components. */
 300         protected ArrayList fComponents;
 301 


 514                 ENTITY_MANAGER,
 515                 DOCUMENT_SCANNER,
 516                 DTD_SCANNER,
 517                 DTD_PROCESSOR,
 518                 DTD_VALIDATOR,
 519                 DATATYPE_VALIDATOR_FACTORY,
 520                 VALIDATION_MANAGER,
 521                 SCHEMA_VALIDATOR,
 522                 XML_STRING,
 523                 XMLGRAMMAR_POOL,
 524                 JAXP_SCHEMA_SOURCE,
 525                 JAXP_SCHEMA_LANGUAGE,
 526                 // NOTE: These shouldn't really be here but since the XML Schema
 527                 //       validator is constructed dynamically, its recognized
 528                 //       properties might not have been set and it would cause a
 529                 //       not-recognized exception to be thrown. -Ac
 530                 SCHEMA_LOCATION,
 531                 SCHEMA_NONS_LOCATION,
 532                 LOCALE,
 533                 SCHEMA_DV_FACTORY,
 534                 XML_SECURITY_PROPERTY_MANAGER 

 535         };
 536         addRecognizedProperties(recognizedProperties);
 537 
 538         if (symbolTable == null) {
 539                 symbolTable = new SymbolTable();
 540         }
 541         fSymbolTable = symbolTable;
 542         fProperties.put(SYMBOL_TABLE, fSymbolTable);
 543 
 544         fGrammarPool = grammarPool;
 545         if (fGrammarPool != null) {
 546             fProperties.put(XMLGRAMMAR_POOL, fGrammarPool);
 547         }
 548 
 549         fEntityManager = new XMLEntityManager();
 550                 fProperties.put(ENTITY_MANAGER, fEntityManager);
 551         addCommonComponent(fEntityManager);
 552 
 553         fErrorReporter = new XMLErrorReporter();
 554         fErrorReporter.setDocumentLocator(fEntityManager.getEntityScanner());


 562         fDTDScanner = new XMLDTDScannerImpl();
 563                 fProperties.put(DTD_SCANNER, fDTDScanner);
 564         addComponent((XMLComponent) fDTDScanner);
 565 
 566         fDTDProcessor = new XMLDTDProcessor();
 567                 fProperties.put(DTD_PROCESSOR, fDTDProcessor);
 568         addComponent((XMLComponent) fDTDProcessor);
 569 
 570         fDTDValidator = new XMLNSDTDValidator();
 571                 fProperties.put(DTD_VALIDATOR, fDTDValidator);
 572         addComponent(fDTDValidator);
 573 
 574         fDatatypeValidatorFactory = DTDDVFactory.getInstance();
 575                 fProperties.put(DATATYPE_VALIDATOR_FACTORY, fDatatypeValidatorFactory);
 576 
 577         fValidationManager = new ValidationManager();
 578                 fProperties.put(VALIDATION_MANAGER, fValidationManager);
 579 
 580         fVersionDetector = new XMLVersionDetector();
 581 
 582         fProperties.put(XML_SECURITY_PROPERTY_MANAGER, new XMLSecurityPropertyManager());



 583 




 584         // add message formatters
 585         if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
 586             XMLMessageFormatter xmft = new XMLMessageFormatter();
 587             fErrorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);
 588             fErrorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);
 589         }
 590 
 591         // set locale
 592         try {
 593             setLocale(Locale.getDefault());
 594         } catch (XNIException e) {
 595             // do nothing
 596             // REVISIT: What is the right thing to do? -Ac
 597         }
 598 
 599                 fConfigUpdated = false;
 600 
 601     } // <init>(SymbolTable,XMLGrammarPool)
 602 
 603     //