com.sun.org.apache.xerces.internal.impl.XMLErrorReporter Java Examples

The following examples show how to use com.sun.org.apache.xerces.internal.impl.XMLErrorReporter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XMLDTDValidator.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * 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);
    }

}
 
Example #2
Source File: XMLDTDProcessor.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }

}
 
Example #3
Source File: XMLDTDScannerImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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();
    }
}
 
Example #4
Source File: SchemaDOMParser.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
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());
}
 
Example #5
Source File: XMLDTDValidator.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example #6
Source File: XMLDTDValidator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }

}
 
Example #7
Source File: XMLDTDValidator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example #8
Source File: XMLSchemaLoader.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #9
Source File: CMNodeFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
        }
    }

}
 
Example #10
Source File: CMNodeFactory.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
        }
    }

}
 
Example #11
Source File: XMLDTDValidator.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example #12
Source File: XMLSchemaLoader.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #13
Source File: XMLDTDValidator.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example #14
Source File: XMLSchemaLoader.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #15
Source File: XMLDTDValidator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }

}
 
Example #16
Source File: XMLDTDProcessor.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
    }

}
 
Example #17
Source File: XMLSchemaLoader.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the state of a property.
 *
 * @param propertyId The property identifier.
 * @param state     The state of the property.
 *
 * @throws XMLConfigurationException Thrown when a property is not
 *                  recognized or cannot be set.
 */
public void setProperty(String propertyId,
        Object state) throws XMLConfigurationException {
    fSettingsChanged = true;
    fLoaderConfig.setProperty(propertyId, state);
    if (propertyId.equals(JAXP_SCHEMA_SOURCE)) {
        fJAXPSource = state;
        fJAXPProcessed = false;
    }
    else if (propertyId.equals(XMLGRAMMAR_POOL)) {
        fGrammarPool = (XMLGrammarPool)state;
    }
    else if (propertyId.equals(SCHEMA_LOCATION)) {
        fExternalSchemas = (String)state;
    }
    else if (propertyId.equals(SCHEMA_NONS_LOCATION)) {
        fExternalNoNSSchema = (String) state;
    }
    else if (propertyId.equals(LOCALE)) {
        setLocale((Locale) state);
    }
    else if (propertyId.equals(ENTITY_RESOLVER)) {
        fEntityManager.setProperty(ENTITY_RESOLVER, state);
    }
    else if (propertyId.equals(ERROR_REPORTER)) {
        fErrorReporter = (XMLErrorReporter)state;
        if (fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) {
            fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, new XSMessageFormatter());
        }
    }
    else if (propertyId.equals(XML_SECURITY_PROPERTY_MANAGER)) {
        XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)state;
        faccessExternalSchema = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA);
    }
}
 
Example #18
Source File: XSConstraints.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #19
Source File: XPointerElementHandler.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
protected void reportFatalError(String key, Object[] args) {
    if (fErrorReporter != null) {
        fErrorReporter.reportError(
        fDocLocation,
        XIncludeMessageFormatter.XINCLUDE_DOMAIN,
        key,
        args,
        XMLErrorReporter.SEVERITY_FATAL_ERROR);
    }
    // we won't worry about when error reporter is null, since there should always be
    // at least the default error reporter
}
 
Example #20
Source File: SchemaDOMParser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Character content.
 *
 * @param text   The content.
 * @param augs   Additional information that may include infoset augmentations
 *
 * @exception XNIException
 *                   Thrown by handler to signal an error.
 */
public void characters(XMLString text, Augmentations augs) throws XNIException {
    // when it's not within xs:appinfo or xs:documentation
    if (fInnerAnnotationDepth == -1 ) {
        for (int i=text.offset; i<text.offset+text.length; i++) {
            // and there is a non-whitespace character
            if (!XMLChar.isSpace(text.ch[i])) {
                // the string we saw: starting from the first non-whitespace character.
                String txt = new String(text.ch, i, text.length+text.offset-i);
                // report an error
                fErrorReporter.reportError(fLocator,
                        XSMessageFormatter.SCHEMA_DOMAIN,
                        "s4s-elt-character",
                        new Object[]{txt},
                        XMLErrorReporter.SEVERITY_ERROR);
                break;
            }
        }
        // don't call super.characters() when it's not within one of the 2
        // annotation elements: the traversers ignore them anyway. We can
        // save time/memory creating the text nodes.
    }
    // when it's within either of the 2 elements, characters are allowed
    // and we need to store them.
    else {
        schemaDOM.characters(text);
    }

}
 
Example #21
Source File: XMLDTDValidator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/** Root element specified. */
private final void rootElementSpecified(QName rootElement) throws XNIException {
    if (fPerformValidation) {
        String root1 = fRootElement.rawname;
        String root2 = rootElement.rawname;
        if (root1 == null || !root1.equals(root2)) {
            fErrorReporter.reportError( XMLMessageFormatter.XML_DOMAIN,
                                        "RootElementTypeMustMatchDoctypedecl",
                                        new Object[]{root1, root2},
                                        XMLErrorReporter.SEVERITY_ERROR);
        }
    }
}
 
Example #22
Source File: XIncludeHandler.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example #23
Source File: SchemaDOMParser.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Character content.
 *
 * @param text   The content.
 * @param augs   Additional information that may include infoset augmentations
 *
 * @exception XNIException
 *                   Thrown by handler to signal an error.
 */
public void characters(XMLString text, Augmentations augs) throws XNIException {
    // when it's not within xs:appinfo or xs:documentation
    if (fInnerAnnotationDepth == -1 ) {
        for (int i=text.offset; i<text.offset+text.length; i++) {
            // and there is a non-whitespace character
            if (!XMLChar.isSpace(text.ch[i])) {
                // the string we saw: starting from the first non-whitespace character.
                String txt = new String(text.ch, i, text.length+text.offset-i);
                // report an error
                fErrorReporter.reportError(fLocator,
                        XSMessageFormatter.SCHEMA_DOMAIN,
                        "s4s-elt-character",
                        new Object[]{txt},
                        XMLErrorReporter.SEVERITY_ERROR);
                break;
            }
        }
        // don't call super.characters() when it's not within one of the 2
        // annotation elements: the traversers ignore them anyway. We can
        // save time/memory creating the text nodes.
    }
    // when it's within either of the 2 elements, characters are allowed
    // and we need to store them.
    else {
        schemaDOM.characters(text);
    }

}
 
Example #24
Source File: XMLScanner.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
    }*/

}
 
Example #25
Source File: XMLDTDLoader.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example #26
Source File: CMNodeFactory.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public void reset(XMLComponentManager componentManager){
    fErrorReporter = (XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER);
    try {
        fSecurityManager = (XMLSecurityManager)componentManager.getProperty(SECURITY_MANAGER);
        //we are setting the limit of number of nodes to 3times the maxOccur value..
        if(fSecurityManager != null){
            maxNodeLimit = fSecurityManager.getLimit(XMLSecurityManager.Limit.MAX_OCCUR_NODE_LIMIT) * MULTIPLICITY ;
        }
    }
    catch (XMLConfigurationException e) {
        fSecurityManager = null;
    }

}
 
Example #27
Source File: XMLDTDLoader.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example #28
Source File: XMLDTDScannerImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/** 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);
}
 
Example #29
Source File: XMLScanner.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * 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
    }*/

}
 
Example #30
Source File: XMLDTDLoader.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
    }
}