Java源码示例:com.sun.org.apache.xerces.internal.impl.XMLErrorReporter

示例1
public void startDocument(XMLLocator locator, String encoding,
        NamespaceContext namespaceContext, Augmentations augs)
throws XNIException {
    fErrorReporter = (XMLErrorReporter)config.getProperty(ERROR_REPORTER);
    fGenerateSyntheticAnnotation = config.getFeature(GENERATE_SYNTHETIC_ANNOTATION);
    fHasNonSchemaAttributes.clear();
    fSawAnnotation.clear();
    schemaDOM = new SchemaDOM();
    fCurrentAnnotationElement = null;
    fAnnotationDepth = -1;
    fInnerAnnotationDepth = -1;
    fDepth = -1;
    fLocator = locator;
    fNamespaceContext = namespaceContext;
    schemaDOM.setDocumentURI(locator.getExpandedSystemId());
}
 
示例2
/**
 * A comment.
 *
 * @param text The text in the comment.
 * @param augs   Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by application to signal an error.
 */
public void comment(XMLString text, Augmentations augs) throws XNIException {
    // fixes E15.1
    if (fPerformValidation && fElementDepth >= 0 && fDTDGrammar != null) {
        fDTDGrammar.getElementDecl(fCurrentElementIndex, fTempElementDecl);
        if (fTempElementDecl.type == XMLElementDecl.TYPE_EMPTY) {
                fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                           "MSG_CONTENT_INVALID_SPECIFIED",
                                           new Object[]{ fCurrentElement.rawname,
                                                         "EMPTY",
                                                         "comment"},
                                           XMLErrorReporter.SEVERITY_ERROR);
        }
    }
    // call handlers
    if (fDocumentHandler != null) {
        fDocumentHandler.comment(text, augs);
    }

}
 
示例3
/**
 * A processing instruction. Processing instructions consist of a
 * target name and, optionally, text data. The data is only meaningful
 * to the application.
 * <p>
 * Typically, a processing instruction's data will contain a series
 * of pseudo-attributes. These pseudo-attributes follow the form of
 * element attributes but are <strong>not</strong> parsed or presented
 * to the application as anything other than text. The application is
 * responsible for parsing the data.
 *
 * @param target The target.
 * @param data   The data or null if none specified.
 * @param augs   Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void processingInstruction(String target, XMLString data, Augmentations augs)
throws XNIException {

    // fixes E15.1
    if (fPerformValidation && fElementDepth >= 0 && fDTDGrammar != null) {
        fDTDGrammar.getElementDecl(fCurrentElementIndex, fTempElementDecl);
        if (fTempElementDecl.type == XMLElementDecl.TYPE_EMPTY) {
                fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                           "MSG_CONTENT_INVALID_SPECIFIED",
                                           new Object[]{ fCurrentElement.rawname,
                                                         "EMPTY",
                                                         "processing instruction"},
                                           XMLErrorReporter.SEVERITY_ERROR);
        }
    }
    // call handlers
    if (fDocumentHandler != null) {
        fDocumentHandler.processingInstruction(target, data, augs);
    }
}
 
示例4
/**
 * This method is called either from XMLGrammarLoader.loadGrammar or from XMLSchemaValidator.
 * Note: in either case, the EntityManager (or EntityResolvers) are not going to be invoked
 * to resolve the location of the schema in XSDDescription
 * @param desc
 * @param source
 * @param locationPairs
 * @return An XML Schema grammar
 * @throws IOException
 * @throws XNIException
 */
SchemaGrammar loadSchema(XSDDescription desc,
        XMLInputSource source,
        Map locationPairs) throws IOException, XNIException {

    // this should only be done once per invocation of this object;
    // unless application alters JAXPSource in the mean time.
    if(!fJAXPProcessed) {
        processJAXPSchemaSource(locationPairs);
    }

    if (desc.isExternal()) {
        String accessError = SecuritySupport.checkAccess(desc.getExpandedSystemId(), faccessExternalSchema, Constants.ACCESS_EXTERNAL_ALL);
        if (accessError != null) {
            throw new XNIException(fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
                    "schema_reference.access",
                    new Object[] { SecuritySupport.sanitizePath(desc.getExpandedSystemId()), accessError }, XMLErrorReporter.SEVERITY_ERROR));
        }
    }
    SchemaGrammar grammar = fSchemaHandler.parseSchema(source, desc, locationPairs);

    return grammar;
}
 
示例5
/**
 * Sets the value of a property. This method is called by the component
 * manager any time after reset when a property changes value.
 * <p>
 * <strong>Note:</strong> Components should silently ignore properties
 * that do not affect the operation of the component.
 *
 * @param propertyId The property identifier.
 * @param value      The value of the property.
 *
 * @throws SAXNotRecognizedException The component should not throw
 *                                   this exception.
 * @throws SAXNotSupportedException The component should not throw
 *                                  this exception.
 */
public void setProperty(String propertyId, Object value)
    throws XMLConfigurationException {

    // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
            final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();

        if (suffixLength == Constants.SECURITY_MANAGER_PROPERTY.length() &&
            propertyId.endsWith(Constants.SECURITY_MANAGER_PROPERTY)) {
            fSecurityManager = (XMLSecurityManager)value;
            maxNodeLimit = (fSecurityManager != null) ?
                    fSecurityManager.getLimit(XMLSecurityManager.Limit.MAX_OCCUR_NODE_LIMIT) * MULTIPLICITY : 0 ;
            return;
        }
        if (suffixLength == Constants.ERROR_REPORTER_PROPERTY.length() &&
            propertyId.endsWith(Constants.ERROR_REPORTER_PROPERTY)) {
            fErrorReporter = (XMLErrorReporter)value;
            return;
        }
    }

}
 
示例6
/**
 * A comment.
 *
 * @param text The text in the comment.
 * @param augs   Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by application to signal an error.
 */
public void comment(XMLString text, Augmentations augs) throws XNIException {
    // fixes E15.1
    if (fPerformValidation && fElementDepth >= 0 && fDTDGrammar != null) {
        fDTDGrammar.getElementDecl(fCurrentElementIndex, fTempElementDecl);
        if (fTempElementDecl.type == XMLElementDecl.TYPE_EMPTY) {
                fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                           "MSG_CONTENT_INVALID_SPECIFIED",
                                           new Object[]{ fCurrentElement.rawname,
                                                         "EMPTY",
                                                         "comment"},
                                           XMLErrorReporter.SEVERITY_ERROR);
        }
    }
    // call handlers
    if (fDocumentHandler != null) {
        fDocumentHandler.comment(text, augs);
    }

}
 
示例7
/**
 * This method is called either from XMLGrammarLoader.loadGrammar or from XMLSchemaValidator.
 * Note: in either case, the EntityManager (or EntityResolvers) are not going to be invoked
 * to resolve the location of the schema in XSDDescription
 * @param desc
 * @param source
 * @param locationPairs
 * @return An XML Schema grammar
 * @throws IOException
 * @throws XNIException
 */
SchemaGrammar loadSchema(XSDDescription desc, XMLInputSource source,
        Map<String, LocationArray> locationPairs) throws IOException, XNIException {

    // this should only be done once per invocation of this object;
    // unless application alters JAXPSource in the mean time.
    if(!fJAXPProcessed) {
        processJAXPSchemaSource(locationPairs);
    }

    if (desc.isExternal()) {
        String accessError = SecuritySupport.checkAccess(desc.getExpandedSystemId(), faccessExternalSchema, Constants.ACCESS_EXTERNAL_ALL);
        if (accessError != null) {
            throw new XNIException(fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
                    "schema_reference.access",
                    new Object[] { SecuritySupport.sanitizePath(desc.getExpandedSystemId()), accessError }, XMLErrorReporter.SEVERITY_ERROR));
        }
    }
    SchemaGrammar grammar = fSchemaHandler.parseSchema(source, desc, locationPairs);

    return grammar;
}
 
示例8
/**
 * This method is called either from XMLGrammarLoader.loadGrammar or from XMLSchemaValidator.
 * Note: in either case, the EntityManager (or EntityResolvers) are not going to be invoked
 * to resolve the location of the schema in XSDDescription
 * @param desc
 * @param source
 * @param locationPairs
 * @return An XML Schema grammar
 * @throws IOException
 * @throws XNIException
 */
SchemaGrammar loadSchema(XSDDescription desc, XMLInputSource source,
        Map<String, LocationArray> locationPairs) throws IOException, XNIException {

    // this should only be done once per invocation of this object;
    // unless application alters JAXPSource in the mean time.
    if(!fJAXPProcessed) {
        processJAXPSchemaSource(locationPairs);
    }

    if (desc.isExternal()) {
        String accessError = SecuritySupport.checkAccess(desc.getExpandedSystemId(), faccessExternalSchema, Constants.ACCESS_EXTERNAL_ALL);
        if (accessError != null) {
            throw new XNIException(fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
                    "schema_reference.access",
                    new Object[] { SecuritySupport.sanitizePath(desc.getExpandedSystemId()), accessError }, XMLErrorReporter.SEVERITY_ERROR));
        }
    }
    SchemaGrammar grammar = fSchemaHandler.parseSchema(source, desc, locationPairs);

    return grammar;
}
 
示例9
/**
 * A comment.
 *
 * @param text The text in the comment.
 * @param augs   Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by application to signal an error.
 */
public void comment(XMLString text, Augmentations augs) throws XNIException {
    // fixes E15.1
    if (fPerformValidation && fElementDepth >= 0 && fDTDGrammar != null) {
        fDTDGrammar.getElementDecl(fCurrentElementIndex, fTempElementDecl);
        if (fTempElementDecl.type == XMLElementDecl.TYPE_EMPTY) {
                fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                           "MSG_CONTENT_INVALID_SPECIFIED",
                                           new Object[]{ fCurrentElement.rawname,
                                                         "EMPTY",
                                                         "comment"},
                                           XMLErrorReporter.SEVERITY_ERROR);
        }
    }
    // call handlers
    if (fDocumentHandler != null) {
        fDocumentHandler.comment(text, augs);
    }

}
 
示例10
/**
 * A processing instruction. Processing instructions consist of a
 * target name and, optionally, text data. The data is only meaningful
 * to the application.
 * <p>
 * Typically, a processing instruction's data will contain a series
 * of pseudo-attributes. These pseudo-attributes follow the form of
 * element attributes but are <strong>not</strong> parsed or presented
 * to the application as anything other than text. The application is
 * responsible for parsing the data.
 *
 * @param target The target.
 * @param data   The data or null if none specified.
 * @param augs   Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void processingInstruction(String target, XMLString data, Augmentations augs)
throws XNIException {

    // fixes E15.1
    if (fPerformValidation && fElementDepth >= 0 && fDTDGrammar != null) {
        fDTDGrammar.getElementDecl(fCurrentElementIndex, fTempElementDecl);
        if (fTempElementDecl.type == XMLElementDecl.TYPE_EMPTY) {
                fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                           "MSG_CONTENT_INVALID_SPECIFIED",
                                           new Object[]{ fCurrentElement.rawname,
                                                         "EMPTY",
                                                         "processing instruction"},
                                           XMLErrorReporter.SEVERITY_ERROR);
        }
    }
    // call handlers
    if (fDocumentHandler != null) {
        fDocumentHandler.processingInstruction(target, data, augs);
    }
}
 
示例11
/**
 * This method notifies the start of a general entity.
 * <p>
 * <strong>Note:</strong> This method is not called for entity references
 * appearing as part of attribute values.
 *
 * @param name     The name of the general entity.
 * @param identifier The resource identifier.
 * @param encoding The auto-detected IANA encoding name of the entity
 *                 stream. This value will be null in those situations
 *                 where the entity encoding is not auto-detected (e.g.
 *                 internal entities or a document entity that is
 *                 parsed from a java.io.Reader).
 * @param augs     Additional information that may include infoset augmentations
 *
 * @exception XNIException Thrown by handler to signal an error.
 */
public void startGeneralEntity(String name,
                               XMLResourceIdentifier identifier,
                               String encoding,
                               Augmentations augs) throws XNIException {
    if (fPerformValidation && fElementDepth >= 0 && fDTDGrammar != null) {
        fDTDGrammar.getElementDecl(fCurrentElementIndex, fTempElementDecl);
        // fixes E15.1
        if (fTempElementDecl.type == XMLElementDecl.TYPE_EMPTY) {
            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                       "MSG_CONTENT_INVALID_SPECIFIED",
                                       new Object[]{ fCurrentElement.rawname,
                                                     "EMPTY", "ENTITY"},
                                       XMLErrorReporter.SEVERITY_ERROR);
        }
        if (fGrammarBucket.getStandalone()) {
            XMLDTDLoader.checkStandaloneEntityRef(name, fDTDGrammar, fEntityDecl, fErrorReporter);
        }
    }
    if (fDocumentHandler != null) {
        fDocumentHandler.startGeneralEntity(name, identifier, encoding, augs);
    }
}
 
示例12
/**
 * A referenced element in a mixed or children content model.
 *
 * @param elementName The name of the referenced element.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void element(String elementName, Augmentations augs) throws XNIException {

    // check VC: No duplicate Types, in a single mixed-content declaration
    if (fMixed && fValidation) {
        if (fMixedElementTypes.contains(elementName)) {
            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                       "DuplicateTypeInMixedContent",
                                       new Object[]{fDTDElementDeclName, elementName},
                                       XMLErrorReporter.SEVERITY_ERROR);
        }
        else {
            fMixedElementTypes.add(elementName);
        }
    }

    // call handlers
    if(fDTDGrammar != null)
        fDTDGrammar.element(elementName, augs);
    if (fDTDContentModelHandler != null) {
        fDTDContentModelHandler.element(elementName, augs);
    }

}
 
示例13
/**
 * A referenced element in a mixed or children content model.
 *
 * @param elementName The name of the referenced element.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void element(String elementName, Augmentations augs) throws XNIException {

    // check VC: No duplicate Types, in a single mixed-content declaration
    if (fMixed && fValidation) {
        if (fMixedElementTypes.contains(elementName)) {
            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                       "DuplicateTypeInMixedContent",
                                       new Object[]{fDTDElementDeclName, elementName},
                                       XMLErrorReporter.SEVERITY_ERROR);
        }
        else {
            fMixedElementTypes.add(elementName);
        }
    }

    // call handlers
    if(fDTDGrammar != null)
        fDTDGrammar.element(elementName, augs);
    if (fDTDContentModelHandler != null) {
        fDTDContentModelHandler.element(elementName, augs);
    }

}
 
示例14
/**
 * start a parameter entity dealing with the textdecl if there is any
 *
 * @param name The name of the parameter entity to start (without the '%')
 * @param literal Whether this is happening within a literal
 */
protected void startPE(String name, boolean literal)
throws IOException, XNIException {
    int depth = fPEDepth;
    String pName = "%"+name;
    if (fValidation && !fEntityStore.isDeclaredEntity(pName)) {
        fErrorReporter.reportError( XMLMessageFormatter.XML_DOMAIN,"EntityNotDeclared",
        new Object[]{name}, XMLErrorReporter.SEVERITY_ERROR);
    }
    fEntityManager.startEntity(false, fSymbolTable.addSymbol(pName),
    literal);
    // if we actually got a new entity and it's external
    // parse text decl if there is any
    if (depth != fPEDepth && fEntityScanner.isExternal()) {
        scanTextDecl();
    }
}
 
示例15
/**
 * A processing instruction. Processing instructions consist of a
 * target name and, optionally, text data. The data is only meaningful
 * to the application.
 * <p>
 * Typically, a processing instruction's data will contain a series
 * of pseudo-attributes. These pseudo-attributes follow the form of
 * element attributes but are <strong>not</strong> parsed or presented
 * to the application as anything other than text. The application is
 * responsible for parsing the data.
 *
 * @param target The target.
 * @param data   The data or null if none specified.
 * @param augs   Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void processingInstruction(String target, XMLString data, Augmentations augs)
throws XNIException {

    // fixes E15.1
    if (fPerformValidation && fElementDepth >= 0 && fDTDGrammar != null) {
        fDTDGrammar.getElementDecl(fCurrentElementIndex, fTempElementDecl);
        if (fTempElementDecl.type == XMLElementDecl.TYPE_EMPTY) {
                fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                           "MSG_CONTENT_INVALID_SPECIFIED",
                                           new Object[]{ fCurrentElement.rawname,
                                                         "EMPTY",
                                                         "processing instruction"},
                                           XMLErrorReporter.SEVERITY_ERROR);
        }
    }
    // call handlers
    if (fDocumentHandler != null) {
        fDocumentHandler.processingInstruction(target, data, augs);
    }
}
 
示例16
/**
 * Sets the value of a property. This method is called by the component
 * manager any time after reset when a property changes value.
 * <p>
 * <strong>Note:</strong> Components should silently ignore properties
 * that do not affect the operation of the component.
 *
 * @param propertyId The property identifier.
 * @param value      The value of the property.
 *
 * @throws SAXNotRecognizedException The component should not throw
 *                                   this exception.
 * @throws SAXNotSupportedException The component should not throw
 *                                  this exception.
 */
public void setProperty(String propertyId, Object value)
    throws XMLConfigurationException {

    // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
            final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();

        if (suffixLength == Constants.SECURITY_MANAGER_PROPERTY.length() &&
            propertyId.endsWith(Constants.SECURITY_MANAGER_PROPERTY)) {
            fSecurityManager = (XMLSecurityManager)value;
            maxNodeLimit = (fSecurityManager != null) ?
                    fSecurityManager.getLimit(XMLSecurityManager.Limit.MAX_OCCUR_NODE_LIMIT) * MULTIPLICITY : 0 ;
            return;
        }
        if (suffixLength == Constants.ERROR_REPORTER_PROPERTY.length() &&
            propertyId.endsWith(Constants.ERROR_REPORTER_PROPERTY)) {
            fErrorReporter = (XMLErrorReporter)value;
            return;
        }
    }

}
 
示例17
static void reportSchemaError(XMLErrorReporter errorReporter,
        SimpleLocator loc,
        String key, Object[] args) {
    if (loc != null) {
        errorReporter.reportError(loc, XSMessageFormatter.SCHEMA_DOMAIN,
                key, args, XMLErrorReporter.SEVERITY_ERROR);
    }
    else {
        errorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
                key, args, XMLErrorReporter.SEVERITY_ERROR);
    }
}
 
示例18
/**
 * Adds an internal entity declaration.
 * <p>
 * <strong>Note:</strong> This method ignores subsequent entity
 * declarations.
 * <p>
 * <strong>Note:</strong> The name should be a unique symbol. The
 * SymbolTable can be used for this purpose.
 *
 * @param name The name of the entity.
 * @param text The text of the entity.
 *
 * @see SymbolTable
 */
public void addInternalEntity(String name, String text) {
  if (!fEntities.containsKey(name)) {
        Entity entity = new Entity.InternalEntity(name, text, fInExternalSubset);
        fEntities.put(name, entity);
    }
    else{
        if(fWarnDuplicateEntityDef){
            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
            "MSG_DUPLICATE_ENTITY_DEFINITION",
            new Object[]{ name },
            XMLErrorReporter.SEVERITY_WARNING );
        }
    }
}
 
示例19
static void reportSchemaError(XMLErrorReporter errorReporter,
        SimpleLocator loc,
        String key, Object[] args) {
    if (loc != null) {
        errorReporter.reportError(loc, XSMessageFormatter.SCHEMA_DOMAIN,
                key, args, XMLErrorReporter.SEVERITY_ERROR);
    }
    else {
        errorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
                key, args, XMLErrorReporter.SEVERITY_ERROR);
    }
}
 
示例20
/**
 * Constructs a preparser using the specified symbol table.
 *
 * @param symbolTable The symbol table to use.
 */
public XMLGrammarPreparser (SymbolTable symbolTable) {
    fSymbolTable = symbolTable;

    fLoaders = new HashMap<>();
    fErrorReporter = new XMLErrorReporter();
    setLocale(Locale.getDefault());
    fEntityResolver = new XMLEntityManager();
    // those are all the basic properties...
}
 
示例21
public DOMValidatorHelper(XMLSchemaValidatorComponentManager componentManager) {
    fComponentManager = componentManager;
    fErrorReporter = (XMLErrorReporter) fComponentManager.getProperty(ERROR_REPORTER);
    fNamespaceContext = (NamespaceSupport) fComponentManager.getProperty(NAMESPACE_CONTEXT);
    fSchemaValidator = (XMLSchemaValidator) fComponentManager.getProperty(SCHEMA_VALIDATOR);
    fSymbolTable = (SymbolTable) fComponentManager.getProperty(SYMBOL_TABLE);
    fValidationManager = (ValidationManager) fComponentManager.getProperty(VALIDATION_MANAGER);
}
 
示例22
public XPointerHandler(SymbolTable symbolTable,
        XMLErrorHandler errorHandler, XMLErrorReporter errorReporter) {
    super();

    fXPointerParts = new Vector();
    fSymbolTable = symbolTable;
    fErrorHandler = errorHandler;
    fXPointerErrorReporter = errorReporter;
    //fErrorReporter = errorReporter; // The XInclude ErrorReporter
}
 
示例23
/**
 * Sets the value of a property. This method is called by the component
 * manager any time after reset when a property changes value.
 * <p>
 * <strong>Note:</strong> Components should silently ignore properties
 * that do not affect the operation of the component.
 *
 * @param propertyId The property identifier.
 * @param value      The value of the property.
 *
 * @throws SAXNotRecognizedException The component should not throw
 *                                   this exception.
 * @throws SAXNotSupportedException The component should not throw
 *                                  this exception.
 */
public void setProperty(String propertyId, Object value)
        throws XMLConfigurationException {
    if (propertyId.equals(SYMBOL_TABLE)) {
        fSymbolTable = (SymbolTable)value;
        fDTDScanner.setProperty(propertyId, value);
        fEntityManager.setProperty(propertyId, value);
    }
    else if(propertyId.equals(ERROR_REPORTER)) {
        fErrorReporter = (XMLErrorReporter)value;
        // Add XML message formatter if there isn't one.
        if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
            XMLMessageFormatter xmft = new XMLMessageFormatter();
            fErrorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);
            fErrorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);
        }
        fDTDScanner.setProperty(propertyId, value);
        fEntityManager.setProperty(propertyId, value);
    }
    else if (propertyId.equals(ERROR_HANDLER)) {
        fErrorReporter.setProperty(propertyId, value);
    }
    else if (propertyId.equals(ENTITY_RESOLVER)) {
        fEntityResolver = (XMLEntityResolver)value;
        fEntityManager.setProperty(propertyId, value);
    }
    else if (propertyId.equals(LOCALE)) {
        setLocale((Locale) value);
    }
    else if(propertyId.equals(GRAMMAR_POOL)) {
        fGrammarPool = (XMLGrammarPool)value;
    }
    else {
        throw new XMLConfigurationException(Status.NOT_RECOGNIZED, propertyId);
    }
}
 
示例24
/**
 *
 *
 * @param componentManager The component manager.
 *
 * @throws SAXException Throws exception if required features and
 *                      properties cannot be found.
 */
public void reset(XMLComponentManager componentManager)
throws XMLConfigurationException {

            fParserSettings = componentManager.getFeature(PARSER_SETTINGS, true);

            if (!fParserSettings) {
                    // parser settings have not been changed
                    init();
                    return;
            }


    // Xerces properties
    fSymbolTable = (SymbolTable)componentManager.getProperty(SYMBOL_TABLE);
    fErrorReporter = (XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER);
    fEntityManager = (XMLEntityManager)componentManager.getProperty(ENTITY_MANAGER);
    fSecurityManager = (XMLSecurityManager)componentManager.getProperty(SECURITY_MANAGER);

    //this step is extra because we have separated the storage of entity
    fEntityStore = fEntityManager.getEntityStore() ;

    // sax features
    fValidation = componentManager.getFeature(VALIDATION, false);
    fNamespaces = componentManager.getFeature(NAMESPACES, true);
    fNotifyCharRefs = componentManager.getFeature(NOTIFY_CHAR_REFS, false);

    init();
}
 
示例25
/** Constructor for he use of non-XMLComponentManagers. */
public XMLDTDScannerImpl(SymbolTable symbolTable,
        XMLErrorReporter errorReporter, XMLEntityManager entityManager) {
    fSymbolTable = symbolTable;
    fErrorReporter = errorReporter;
    fEntityManager = entityManager;
    entityManager.setProperty(SYMBOL_TABLE, fSymbolTable);
}
 
示例26
/**
 * Sets the value of a property. This method is called by the component
 * manager any time after reset when a property changes value.
 * <p>
 * <strong>Note:</strong> Components should silently ignore properties
 * that do not affect the operation of the component.
 *
 * @param propertyId The property identifier.
 * @param value      The value of the property.
 *
 * @throws SAXNotRecognizedException The component should not throw
 *                                   this exception.
 * @throws SAXNotSupportedException The component should not throw
 *                                  this exception.
 */
public void setProperty(String propertyId, Object value)
        throws XMLConfigurationException {
    if (propertyId.equals(SYMBOL_TABLE)) {
        fSymbolTable = (SymbolTable)value;
        fDTDScanner.setProperty(propertyId, value);
        fEntityManager.setProperty(propertyId, value);
    }
    else if(propertyId.equals(ERROR_REPORTER)) {
        fErrorReporter = (XMLErrorReporter)value;
        // Add XML message formatter if there isn't one.
        if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
            XMLMessageFormatter xmft = new XMLMessageFormatter();
            fErrorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);
            fErrorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);
        }
        fDTDScanner.setProperty(propertyId, value);
        fEntityManager.setProperty(propertyId, value);
    }
    else if (propertyId.equals(ERROR_HANDLER)) {
        fErrorReporter.setProperty(propertyId, value);
    }
    else if (propertyId.equals(ENTITY_RESOLVER)) {
        fEntityResolver = (XMLEntityResolver)value;
        fEntityManager.setProperty(propertyId, value);
    }
    else if (propertyId.equals(LOCALE)) {
        setLocale((Locale) value);
    }
    else if(propertyId.equals(GRAMMAR_POOL)) {
        fGrammarPool = (XMLGrammarPool)value;
    }
    else {
        throw new XMLConfigurationException(Status.NOT_RECOGNIZED, propertyId);
    }
}
 
示例27
/**
 * Sets the value of a property during parsing.
 *
 * @param propertyId
 * @param value
 */
public void setProperty(String propertyId, Object value)
throws XMLConfigurationException {

    // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
        String property =
                propertyId.substring(Constants.XERCES_PROPERTY_PREFIX.length());
        if (property.equals(Constants.SYMBOL_TABLE_PROPERTY)) {
            fSymbolTable = (SymbolTable)value;
        } else if (property.equals(Constants.ERROR_REPORTER_PROPERTY)) {
            fErrorReporter = (XMLErrorReporter)value;
        } else if (property.equals(Constants.ENTITY_MANAGER_PROPERTY)) {
            fEntityManager = (XMLEntityManager)value;
        }
    }

    if (propertyId.equals(SECURITY_MANAGER)) {
        fSecurityManager = (XMLSecurityManager)value;
    }
            /*else if(propertyId.equals(Constants.STAX_PROPERTIES)){
        fStaxProperties = (HashMap)value;
        //TODO::discuss with neeraj what are his thoughts on passing properties.
        //For now use this
    }*/

}
 
示例28
private void setErrorReporter(XMLErrorReporter reporter) {
    fErrorReporter = reporter;
    if (fErrorReporter != null) {
        fErrorReporter.putMessageFormatter(
            XIncludeMessageFormatter.XINCLUDE_DOMAIN, fXIncludeMessageFormatter);
        // this ensures the proper location is displayed in error messages
        if (fDocLocation != null) {
            fErrorReporter.setDocumentLocator(fDocLocation);
        }
    }
}
 
示例29
/**
 * Sets the value of a property during parsing.
 *
 * @param propertyId
 * @param value
 */
public void setProperty(String propertyId, Object value)
throws XMLConfigurationException {

    // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
        String property =
                propertyId.substring(Constants.XERCES_PROPERTY_PREFIX.length());
        if (property.equals(Constants.SYMBOL_TABLE_PROPERTY)) {
            fSymbolTable = (SymbolTable)value;
        } else if (property.equals(Constants.ERROR_REPORTER_PROPERTY)) {
            fErrorReporter = (XMLErrorReporter)value;
        } else if (property.equals(Constants.ENTITY_MANAGER_PROPERTY)) {
            fEntityManager = (XMLEntityManager)value;
        }
    }

    if (propertyId.equals(SECURITY_MANAGER)) {
        fSecurityManager = (XMLSecurityManager)value;
    }
            /*else if(propertyId.equals(Constants.STAX_PROPERTIES)){
        fStaxProperties = (HashMap)value;
        //TODO::discuss with neeraj what are his thoughts on passing properties.
        //For now use this
    }*/

}
 
示例30
/**
 * Reports XPointer Warnings
 *
 */
private void reportWarning(String key, Object[] arguments)
        throws XNIException {
    fXPointerErrorReporter.reportError(
            XPointerMessageFormatter.XPOINTER_DOMAIN, key, arguments,
            XMLErrorReporter.SEVERITY_WARNING);
}