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

示例1
/**
 * Adds an unparsed 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 publicId The public identifier of the entity.
 * @param systemId The system identifier of the entity.
 * @param notation The name of the notation.
 *
 * @see SymbolTable
 */
public void addUnparsedEntity(String name,
String publicId, String systemId,
String baseSystemId, String notation) {

    fCurrentEntity = fEntityManager.getCurrentEntity();
    if (!fEntities.containsKey(name)) {
        Entity entity = new Entity.ExternalEntity(name, new XMLResourceIdentifierImpl(publicId, systemId, baseSystemId, null), notation, fInExternalSubset);
        //                  (fCurrentEntity == null) ? fasle : fCurrentEntity.isEntityDeclInExternalSubset());
        //                  fCurrentEntity.isEntityDeclInExternalSubset());
        fEntities.put(name, entity);
    }
    else{
        if(fWarnDuplicateEntityDef){
            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
            "MSG_DUPLICATE_ENTITY_DEFINITION",
            new Object[]{ name },
            XMLErrorReporter.SEVERITY_WARNING );
        }
    }
}
 
示例2
/**
 * 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();
    }
}
 
示例3
/**
 * A notation declaration
 *
 * @param name     The name of the notation.
 * @param identifier    An object containing all location information
 *                      pertinent to this notation.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void notationDecl(String name, XMLResourceIdentifier identifier,
                         Augmentations augs) throws XNIException {

    // VC: Unique Notation Name
    if (fValidation) {
        DTDGrammar grammar = (fDTDGrammar != null ? fDTDGrammar : fGrammarBucket.getActiveGrammar());
        if (grammar.getNotationDeclIndex(name) != -1) {
            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                       "UniqueNotationName",
                                       new Object[]{name},
                                       XMLErrorReporter.SEVERITY_ERROR);
        }
    }

    // call handlers
    if(fDTDGrammar != null)
        fDTDGrammar.notationDecl(name, identifier, augs);
    if (fDTDHandler != null) {
        fDTDHandler.notationDecl(name, identifier, augs);
    }

}
 
示例4
/**
 * 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);
    }
}
 
示例5
/**
 * 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);
    }

}
 
示例6
/**
 * 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);
    }
}
 
示例7
/**
 * 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);
    }
}
 
示例8
/**
 * An element declaration.
 *
 * @param name         The name of the element.
 * @param contentModel The element content model.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void elementDecl(String name, String contentModel, Augmentations augs)
throws XNIException {

    //check VC: Unique Element Declaration
    if (fValidation) {
        if (fDTDElementDecls.contains(name)) {
            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                       "MSG_ELEMENT_ALREADY_DECLARED",
                                       new Object[]{ name},
                                       XMLErrorReporter.SEVERITY_ERROR);
        }
        else {
            fDTDElementDecls.add(name);
        }
    }

    // call handlers
    if(fDTDGrammar != null )
        fDTDGrammar.elementDecl(name, contentModel, augs);
    if (fDTDHandler != null) {
        fDTDHandler.elementDecl(name, contentModel, augs);
    }

}
 
示例9
/**
 * Read characters into a portion of an array.  This method will block
 * until some input is available, an I/O error occurs, or the end of the
 * stream is reached.
 *
 * @param      ch     Destination buffer
 * @param      offset Offset at which to start storing characters
 * @param      length Maximum number of characters to read
 *
 * @return     The number of characters read, or -1 if the end of the
 *             stream has been reached
 *
 * @exception  IOException  If an I/O error occurs
 */
public int read(char ch[], int offset, int length) throws IOException {
    if (length > fBuffer.length) {
        length = fBuffer.length;
    }
    int count = fInputStream.read(fBuffer, 0, length);
    for (int i = 0; i < count; i++) {
        int b0 = fBuffer[i];
        if (b0 < 0) {
            throw new MalformedByteSequenceException(fFormatter,
                fLocale, XMLMessageFormatter.XML_DOMAIN,
                "InvalidASCII", new Object [] {Integer.toString(b0 & 0x0FF)});
        }
        ch[offset + i] = (char)b0;
    }
    return count;
}
 
示例10
/**
 * Read characters into a portion of an array.  This method will block
 * until some input is available, an I/O error occurs, or the end of the
 * stream is reached.
 *
 * @param      ch     Destination buffer
 * @param      offset Offset at which to start storing characters
 * @param      length Maximum number of characters to read
 *
 * @return     The number of characters read, or -1 if the end of the
 *             stream has been reached
 *
 * @exception  IOException  If an I/O error occurs
 */
public int read(char ch[], int offset, int length) throws IOException {
    if (length > fBuffer.length) {
        length = fBuffer.length;
    }
    int count = fInputStream.read(fBuffer, 0, length);
    for (int i = 0; i < count; i++) {
        int b0 = fBuffer[i];
        if (b0 < 0) {
            throw new MalformedByteSequenceException(fFormatter,
                fLocale, XMLMessageFormatter.XML_DOMAIN,
                "InvalidASCII", new Object [] {Integer.toString(b0 & 0x0FF)});
        }
        ch[offset + i] = (char)b0;
    }
    return count;
}
 
示例11
/**
 * 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();
    }
}
 
示例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
/**
 * Adds an unparsed 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 publicId The public identifier of the entity.
 * @param systemId The system identifier of the entity.
 * @param notation The name of the notation.
 *
 * @see SymbolTable
 */
public void addUnparsedEntity(String name,
        String publicId, String systemId,
        String baseSystemId, String notation) {
    if (!fEntities.containsKey(name)) {
        Entity.ExternalEntity entity = new Entity.ExternalEntity(name,
                new XMLEntityDescriptionImpl(name, publicId, systemId, baseSystemId, null),
                notation, fInExternalSubset);
        fEntities.put(name, entity);
    } else{
        if(fWarnDuplicateEntityDef){
            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                    "MSG_DUPLICATE_ENTITY_DEFINITION",
                    new Object[]{ name },
                    XMLErrorReporter.SEVERITY_WARNING );
        }
    }
}
 
示例14
/**
 * 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);
    }

}
 
示例15
/**
 * Read characters into a portion of an array.  This method will block
 * until some input is available, an I/O error occurs, or the end of the
 * stream is reached.
 *
 * @param      ch     Destination buffer
 * @param      offset Offset at which to start storing characters
 * @param      length Maximum number of characters to read
 *
 * @return     The number of characters read, or -1 if the end of the
 *             stream has been reached
 *
 * @exception  IOException  If an I/O error occurs
 */
public int read(char ch[], int offset, int length) throws IOException {
    if (length > fBuffer.length) {
        length = fBuffer.length;
    }
    int count = fInputStream.read(fBuffer, 0, length);
    for (int i = 0; i < count; i++) {
        int b0 = fBuffer[i];
        if (b0 < 0) {
            throw new MalformedByteSequenceException(fFormatter,
                fLocale, XMLMessageFormatter.XML_DOMAIN,
                "InvalidASCII", new Object [] {Integer.toString(b0 & 0x0FF)});
        }
        ch[offset + i] = (char)b0;
    }
    return count;
}
 
示例16
/**
 * Adds an unparsed 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 publicId The public identifier of the entity.
 * @param systemId The system identifier of the entity.
 * @param notation The name of the notation.
 *
 * @see SymbolTable
 */
public void addUnparsedEntity(String name,
String publicId, String systemId,
String baseSystemId, String notation) {

    fCurrentEntity = fEntityManager.getCurrentEntity();
    if (!fEntities.containsKey(name)) {
        Entity entity = new Entity.ExternalEntity(name, new XMLResourceIdentifierImpl(publicId, systemId, baseSystemId, null), notation, fInExternalSubset);
        //                  (fCurrentEntity == null) ? fasle : fCurrentEntity.isEntityDeclInExternalSubset());
        //                  fCurrentEntity.isEntityDeclInExternalSubset());
        fEntities.put(name, entity);
    }
    else{
        if(fWarnDuplicateEntityDef){
            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
            "MSG_DUPLICATE_ENTITY_DEFINITION",
            new Object[]{ name },
            XMLErrorReporter.SEVERITY_WARNING );
        }
    }
}
 
示例17
/**
 * Adds an unparsed 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 publicId The public identifier of the entity.
 * @param systemId The system identifier of the entity.
 * @param notation The name of the notation.
 *
 * @see SymbolTable
 */
public void addUnparsedEntity(String name,
        String publicId, String systemId,
        String baseSystemId, String notation) {
    if (!fEntities.containsKey(name)) {
        Entity.ExternalEntity entity = new Entity.ExternalEntity(name,
                new XMLEntityDescriptionImpl(name, publicId, systemId, baseSystemId, null),
                notation, fInExternalSubset);
        fEntities.put(name, entity);
    } else{
        if(fWarnDuplicateEntityDef){
            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                    "MSG_DUPLICATE_ENTITY_DEFINITION",
                    new Object[]{ name },
                    XMLErrorReporter.SEVERITY_WARNING );
        }
    }
}
 
示例18
/**
 * 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);
    }

}
 
示例19
/**
 * Checks whether the value of the specified Limit exceeds its limit
 *
 * @param limit The Limit to be checked
 * @param entity The current entity
 * @param offset The index of the first byte
 * @param length The length of the entity scanned
 */
protected void checkLimit(Limit limit, ScannedEntity entity, int offset, int length) {
    fLimitAnalyzer.addValue(limit, entity.name, length);
    if (fSecurityManager.isOverLimit(limit, fLimitAnalyzer)) {
        fSecurityManager.debugPrint(fLimitAnalyzer);
        Object[] e = (limit == Limit.ENTITY_REPLACEMENT_LIMIT) ?
                new Object[]{fLimitAnalyzer.getValue(limit),
                    fSecurityManager.getLimit(limit), fSecurityManager.getStateLiteral(limit)} :
                new Object[]{entity.name, fLimitAnalyzer.getValue(limit),
                    fSecurityManager.getLimit(limit), fSecurityManager.getStateLiteral(limit)};
        fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, limit.key(),
                e, XMLErrorReporter.SEVERITY_FATAL_ERROR);
    }
    if (fSecurityManager.isOverLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
        fSecurityManager.debugPrint(fLimitAnalyzer);
        fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, "TotalEntitySizeLimit",
                new Object[]{fLimitAnalyzer.getTotalValue(Limit.TOTAL_ENTITY_SIZE_LIMIT),
            fSecurityManager.getLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT),
            fSecurityManager.getStateLiteral(Limit.TOTAL_ENTITY_SIZE_LIMIT)},
                XMLErrorReporter.SEVERITY_FATAL_ERROR);
    }
}
 
示例20
/**
 * 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(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();
    }
}
 
示例21
/**
 * An element declaration.
 *
 * @param name         The name of the element.
 * @param contentModel The element content model.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void elementDecl(String name, String contentModel, Augmentations augs)
throws XNIException {

    //check VC: Unique Element Declaration
    if (fValidation) {
        if (fDTDElementDecls.contains(name)) {
            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                       "MSG_ELEMENT_ALREADY_DECLARED",
                                       new Object[]{ name},
                                       XMLErrorReporter.SEVERITY_ERROR);
        }
        else {
            fDTDElementDecls.add(name);
        }
    }

    // call handlers
    if(fDTDGrammar != null )
        fDTDGrammar.elementDecl(name, contentModel, augs);
    if (fDTDHandler != null) {
        fDTDHandler.elementDecl(name, contentModel, augs);
    }

}
 
示例22
/**
 * 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);
    }

}
 
示例23
/**
 * 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);
    }

}
 
示例24
/**
 * 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);
    }
}
 
示例25
/**
 * 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);
    }
}
 
示例26
/**
 * 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 );
        }
    }

}
 
示例27
/** Throws an exception for expected byte. */
private void expectedByte(int position, int count)
    throws MalformedByteSequenceException {

    throw new MalformedByteSequenceException(fFormatter,
        fLocale,
        XMLMessageFormatter.XML_DOMAIN,
        "ExpectedByte",
        new Object[] {Integer.toString(position), Integer.toString(count)});

}
 
示例28
/**
 * Check standalone entity reference.
 * Made static to make common between the validator and loader.
 *
 * @param name
 *@param grammar    grammar to which entity belongs
 * @param tempEntityDecl    empty entity declaration to put results in
 * @param errorReporter     error reporter to send errors to
 *
 * @throws XNIException Thrown by application to signal an error.
 */
protected static void checkStandaloneEntityRef(String name, DTDGrammar grammar,
                XMLEntityDecl tempEntityDecl, XMLErrorReporter errorReporter) throws XNIException {
    // check VC: Standalone Document Declartion, entities references appear in the document.
    int entIndex = grammar.getEntityDeclIndex(name);
    if (entIndex > -1) {
        grammar.getEntityDecl(entIndex, tempEntityDecl);
        if (tempEntityDecl.inExternal) {
            errorReporter.reportError( XMLMessageFormatter.XML_DOMAIN,
                                        "MSG_REFERENCE_TO_EXTERNALLY_DECLARED_ENTITY_WHEN_STANDALONE",
                                        new Object[]{name}, XMLErrorReporter.SEVERITY_ERROR);
        }
    }
}
 
示例29
/**
 * 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);
    }
}
 
示例30
/** 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);
        }
    }
}