/** Constructs a component manager suitable for Xerces' schema validator. */
  public XMLSchemaValidatorComponentManager(XSGrammarPoolContainer grammarContainer) {
    // setup components
    fEntityManager = new XMLEntityManager();
    fComponents.put(ENTITY_MANAGER, fEntityManager);

    fErrorReporter = new XMLErrorReporter();
    fComponents.put(ERROR_REPORTER, fErrorReporter);

    fNamespaceContext = new NamespaceSupport();
    fComponents.put(NAMESPACE_CONTEXT, fNamespaceContext);

    fSchemaValidator = new XMLSchemaValidator();
    fComponents.put(SCHEMA_VALIDATOR, fSchemaValidator);

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

    // setup other properties
    fComponents.put(ENTITY_RESOLVER, null);
    fComponents.put(ERROR_HANDLER, null);

    fComponents.put(SYMBOL_TABLE, new SymbolTable());

    // setup grammar pool
    fComponents.put(XMLGRAMMAR_POOL, grammarContainer.getGrammarPool());
    fUseGrammarPoolOnly = grammarContainer.isFullyComposed();

    // add schema message formatter to error reporter
    fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, new XSMessageFormatter());

    // add all recognized features and properties and apply their defaults
    addRecognizedParamsAndSetDefaults(fEntityManager, grammarContainer);
    addRecognizedParamsAndSetDefaults(fErrorReporter, grammarContainer);
    addRecognizedParamsAndSetDefaults(fSchemaValidator, grammarContainer);

    boolean secureProcessing = grammarContainer.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING);
    if (System.getSecurityManager() != null) {
      _isSecureMode = true;
      secureProcessing = true;
    }

    fInitSecurityManager = (XMLSecurityManager) grammarContainer.getProperty(SECURITY_MANAGER);
    if (fInitSecurityManager != null) {
      fInitSecurityManager.setSecureProcessing(secureProcessing);
    } else {
      fInitSecurityManager = new XMLSecurityManager(secureProcessing);
    }

    setProperty(SECURITY_MANAGER, fInitSecurityManager);

    // pass on properties set on SchemaFactory
    fSecurityPropertyMgr =
        (XMLSecurityPropertyManager)
            grammarContainer.getProperty(Constants.XML_SECURITY_PROPERTY_MANAGER);
    setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr);
  }
 void setErrorHandler(ErrorHandler errorHandler) {
   fErrorHandler = errorHandler;
   setProperty(
       ERROR_HANDLER,
       (errorHandler != null)
           ? new ErrorHandlerWrapper(errorHandler)
           : new ErrorHandlerWrapper(DraconianErrorHandler.getInstance()));
 }
  /**
   * Set the state of a feature.
   *
   * @param featureId The unique identifier (URI) of the feature.
   * @param state The requested state of the feature (true or false).
   * @exception XMLConfigurationException If the requested feature is not known.
   */
  public void setFeature(String featureId, boolean value) throws XMLConfigurationException {
    if (PARSER_SETTINGS.equals(featureId)) {
      throw new XMLConfigurationException(Status.NOT_SUPPORTED, featureId);
    } else if (value == false
        && (VALIDATION.equals(featureId) || SCHEMA_VALIDATION.equals(featureId))) {
      throw new XMLConfigurationException(Status.NOT_SUPPORTED, featureId);
    } else if (USE_GRAMMAR_POOL_ONLY.equals(featureId) && value != fUseGrammarPoolOnly) {
      throw new XMLConfigurationException(Status.NOT_SUPPORTED, featureId);
    }
    if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(featureId)) {
      if (_isSecureMode && !value) {
        throw new XMLConfigurationException(
            Status.NOT_ALLOWED, XMLConstants.FEATURE_SECURE_PROCESSING);
      }
      fInitSecurityManager.setSecureProcessing(value);
      setProperty(SECURITY_MANAGER, fInitSecurityManager);

      if (value && Constants.IS_JDK8_OR_ABOVE) {
        fSecurityPropertyMgr.setValue(
            XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD,
            XMLSecurityPropertyManager.State.FSP,
            Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
        fSecurityPropertyMgr.setValue(
            XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA,
            XMLSecurityPropertyManager.State.FSP,
            Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
        setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr);
      }

      return;
    }
    fConfigUpdated = true;
    fEntityManager.setFeature(featureId, value);
    fErrorReporter.setFeature(featureId, value);
    fSchemaValidator.setFeature(featureId, value);
    if (!fInitFeatures.containsKey(featureId)) {
      boolean current = super.getFeature(featureId);
      fInitFeatures.put(featureId, current ? Boolean.TRUE : Boolean.FALSE);
    }
    super.setFeature(featureId, value);
  }
 public void setProperty(String name, Object object)
     throws SAXNotRecognizedException, SAXNotSupportedException {
   if (name == null) {
     throw new NullPointerException();
   }
   try {
     fComponentManager.setProperty(name, object);
   } catch (XMLConfigurationException e) {
     final String identifier = e.getIdentifier();
     final String key =
         e.getType() == XMLConfigurationException.NOT_RECOGNIZED
             ? "property-not-recognized"
             : "property-not-supported";
     throw new SAXNotRecognizedException(
         SAXMessageFormatter.formatMessage(Locale.getDefault(), key, new Object[] {identifier}));
   }
 }
 void setResourceResolver(LSResourceResolver resourceResolver) {
   fResourceResolver = resourceResolver;
   setProperty(ENTITY_RESOLVER, new DOMEntityResolverWrapper(resourceResolver));
 }