Exemplo n.º 1
0
  private void initXML11Components() {
    if (!f11Initialized) {

      // create datatype factory
      fXML11DatatypeFactory = DTDDVFactory.getInstance(XML11_DATATYPE_VALIDATOR_FACTORY);

      // setup XML 1.1 DTD pipeline
      fXML11DTDScanner = new XML11DTDScannerImpl();
      addXML11Component(fXML11DTDScanner);
      fXML11DTDProcessor = new XML11DTDProcessor();
      addXML11Component(fXML11DTDProcessor);

      // setup XML 1.1. document pipeline - namespace aware
      fXML11NSDocScanner = new XML11NSDocumentScannerImpl();
      addXML11Component(fXML11NSDocScanner);
      fXML11NSDTDValidator = new XML11NSDTDValidator();
      addXML11Component(fXML11NSDTDValidator);

      f11Initialized = true;
    }
  }
 /** Create a datatype validator factory. */
 protected DTDDVFactory createDatatypeValidatorFactory() {
   return DTDDVFactory.getInstance();
 } // createDatatypeValidatorFactory():DatatypeValidatorFactory
Exemplo n.º 3
0
  /**
   * Constructs a parser configuration using the specified symbol table, grammar pool, and parent
   * settings.
   *
   * <p><strong>REVISIT:</strong> Grammar pool will be updated when the new validation engine is
   * implemented.
   *
   * @param symbolTable The symbol table to use.
   * @param grammarPool The grammar pool to use.
   * @param parentSettings The parent settings.
   */
  public XML11DTDConfiguration(
      SymbolTable symbolTable, XMLGrammarPool grammarPool, XMLComponentManager parentSettings) {

    super(parentSettings);

    // create a vector to hold all the components in use
    // XML 1.0 specialized components
    fComponents = new ArrayList();
    // XML 1.1 specialized components
    fXML11Components = new ArrayList();
    // Common components for XML 1.1. and XML 1.0
    fCommonComponents = new ArrayList();

    // create storage for recognized features and properties
    fRecognizedFeatures = new ArrayList();
    fRecognizedProperties = new ArrayList();

    // create table for features and properties
    fFeatures = new HashMap();
    fProperties = new HashMap();

    // add default recognized features
    final String[] recognizedFeatures = {
      CONTINUE_AFTER_FATAL_ERROR,
      LOAD_EXTERNAL_DTD, // from XMLDTDScannerImpl
      VALIDATION,
      NAMESPACES,
      EXTERNAL_GENERAL_ENTITIES,
      EXTERNAL_PARAMETER_ENTITIES,
      PARSER_SETTINGS
    };
    addRecognizedFeatures(recognizedFeatures);
    // set state for default features
    fFeatures.put(VALIDATION, Boolean.FALSE);
    fFeatures.put(NAMESPACES, Boolean.TRUE);
    fFeatures.put(EXTERNAL_GENERAL_ENTITIES, Boolean.TRUE);
    fFeatures.put(EXTERNAL_PARAMETER_ENTITIES, Boolean.TRUE);
    fFeatures.put(CONTINUE_AFTER_FATAL_ERROR, Boolean.FALSE);
    fFeatures.put(LOAD_EXTERNAL_DTD, Boolean.TRUE);
    fFeatures.put(PARSER_SETTINGS, Boolean.TRUE);

    // add default recognized properties
    final String[] recognizedProperties = {
      SYMBOL_TABLE,
      ERROR_HANDLER,
      ENTITY_RESOLVER,
      ERROR_REPORTER,
      ENTITY_MANAGER,
      DOCUMENT_SCANNER,
      DTD_SCANNER,
      DTD_PROCESSOR,
      DTD_VALIDATOR,
      DATATYPE_VALIDATOR_FACTORY,
      VALIDATION_MANAGER,
      XML_STRING,
      XMLGRAMMAR_POOL,
      JAXP_SCHEMA_SOURCE,
      JAXP_SCHEMA_LANGUAGE
    };
    addRecognizedProperties(recognizedProperties);

    if (symbolTable == null) {
      symbolTable = new SymbolTable();
    }
    fSymbolTable = symbolTable;
    fProperties.put(SYMBOL_TABLE, fSymbolTable);

    fGrammarPool = grammarPool;
    if (fGrammarPool != null) {
      fProperties.put(XMLGRAMMAR_POOL, fGrammarPool);
    }

    fEntityManager = new XMLEntityManager();
    fProperties.put(ENTITY_MANAGER, fEntityManager);
    addCommonComponent(fEntityManager);

    fErrorReporter = new XMLErrorReporter();
    fErrorReporter.setDocumentLocator(fEntityManager.getEntityScanner());
    fProperties.put(ERROR_REPORTER, fErrorReporter);
    addCommonComponent(fErrorReporter);

    fNamespaceScanner = new XMLNSDocumentScannerImpl();
    fProperties.put(DOCUMENT_SCANNER, fNamespaceScanner);
    addComponent((XMLComponent) fNamespaceScanner);

    fDTDScanner = new XMLDTDScannerImpl();
    fProperties.put(DTD_SCANNER, fDTDScanner);
    addComponent((XMLComponent) fDTDScanner);

    fDTDProcessor = new XMLDTDProcessor();
    fProperties.put(DTD_PROCESSOR, fDTDProcessor);
    addComponent((XMLComponent) fDTDProcessor);

    fDTDValidator = new XMLNSDTDValidator();
    fProperties.put(DTD_VALIDATOR, fDTDValidator);
    addComponent(fDTDValidator);

    fDatatypeValidatorFactory = DTDDVFactory.getInstance();
    fProperties.put(DATATYPE_VALIDATOR_FACTORY, fDatatypeValidatorFactory);

    fValidationManager = new ValidationManager();
    fProperties.put(VALIDATION_MANAGER, fValidationManager);

    fVersionDetector = new XMLVersionDetector();

    // add message formatters
    if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
      XMLMessageFormatter xmft = new XMLMessageFormatter();
      fErrorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);
      fErrorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);
    }

    // set locale
    try {
      setLocale(Locale.getDefault());
    } catch (XNIException e) {
      // do nothing
      // REVISIT: What is the right thing to do? -Ac
    }

    fConfigUpdated = false;
  } // <init>(SymbolTable,XMLGrammarPool)