Java 类org.w3c.dom.DOMError 实例源码

项目:OpenJSharp    文件:DOMNormalizer.java   
/**
 * Reports a DOM error to the user handler.
 *
 * If the error is fatal, the processing will be always aborted.
 */
public static final void reportDOMError(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
                    String message, short severity, String type ) {
    if( errorHandler!=null ) {
        error.reset();
        error.fMessage = message;
        error.fSeverity = severity;
        error.fLocator = locator;
        error.fType = type;
        error.fRelatedData = locator.fRelatedNode;

        if(!errorHandler.handleError(error))
            throw abort;
    }
    if( severity==DOMError.SEVERITY_FATAL_ERROR )
        throw abort;
}
项目:OpenJSharp    文件:DOMErrorHandlerWrapper.java   
/**
 * Reports a warning. Warnings are non-fatal and can be safely ignored
 * by most applications.
 *
 * @param domain    The domain of the warning. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this warning.
 * @param key       The warning key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */

public void warning(String domain, String key,
                    XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_WARNING;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode = fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
项目:OpenJSharp    文件:DOMErrorHandlerWrapper.java   
/**
 * Reports an error. Errors are non-fatal and usually signify that the
 * document is invalid with respect to its grammar(s).
 *
 * @param domain    The domain of the error. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this error.
 * @param key       The error key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */
public void error(String domain, String key,
                  XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_ERROR;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode= fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
项目:openjdk-jdk10    文件:DOMNormalizer.java   
/**
 * Reports a DOM error to the user handler.
 *
 * If the error is fatal, the processing will be always aborted.
 */
public static final void reportDOMError(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
                    String message, short severity, String type ) {
    if( errorHandler!=null ) {
        error.reset();
        error.fMessage = message;
        error.fSeverity = severity;
        error.fLocator = locator;
        error.fType = type;
        error.fRelatedData = locator.fRelatedNode;

        if(!errorHandler.handleError(error))
            throw new AbortException();
    }
    if( severity==DOMError.SEVERITY_FATAL_ERROR )
        throw new AbortException();
}
项目:openjdk-jdk10    文件:DOMErrorHandlerWrapper.java   
/**
 * Reports a warning. Warnings are non-fatal and can be safely ignored
 * by most applications.
 *
 * @param domain    The domain of the warning. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this warning.
 * @param key       The warning key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */

public void warning(String domain, String key,
                    XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_WARNING;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode = fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
项目:openjdk-jdk10    文件:DOMErrorHandlerWrapper.java   
/**
 * Reports an error. Errors are non-fatal and usually signify that the
 * document is invalid with respect to its grammar(s).
 *
 * @param domain    The domain of the error. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this error.
 * @param key       The error key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */
public void error(String domain, String key,
                  XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_ERROR;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode= fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
项目:openjdk-jdk10    文件:DOM3TreeWalker.java   
/**
 * Checks if an CDATASection node is well-formed, by checking it's data
 * for well-formedness.  Note that the presence of a CDATA termination mark
 * in the contents of a CDATASection is handled by the parameter
 * spli-cdata-sections
 *
 * @param data The contents of the comment node
 */
protected void isCDATASectionWellFormed(CDATASection node) {
    // Does the data valid XML character data
    Character invalidChar = isWFXMLChar(node.getData());
    //if (!isWFXMLChar(node.getData(), invalidChar)) {
    if (invalidChar != null) {
        String msg =
            Utils.messages.createMessage(
                MsgKey.ER_WF_INVALID_CHARACTER_IN_CDATA,
                new Object[] { Integer.toHexString(Character.getNumericValue(invalidChar.charValue())) });

        if (fErrorHandler != null) {
            fErrorHandler.handleError(
                new DOMErrorImpl(
                    DOMError.SEVERITY_FATAL_ERROR,
                    msg,
                    MsgKey.ER_WF_INVALID_CHARACTER,
                    null,
                    null,
                    null));
        }
    }
}
项目:openjdk-jdk10    文件:DOM3TreeWalker.java   
/**
 * Checks if an Text node is well-formed, by checking if it contains invalid
 * XML characters.
 *
 * @param data The contents of the comment node
 */
protected void isTextWellFormed(Text node) {
    // Does the data valid XML character data
    Character invalidChar = isWFXMLChar(node.getData());
    if (invalidChar != null) {
        String msg =
            Utils.messages.createMessage(
                MsgKey.ER_WF_INVALID_CHARACTER_IN_TEXT,
                new Object[] { Integer.toHexString(Character.getNumericValue(invalidChar.charValue())) });

        if (fErrorHandler != null) {
            fErrorHandler.handleError(
                new DOMErrorImpl(
                    DOMError.SEVERITY_FATAL_ERROR,
                    msg,
                    MsgKey.ER_WF_INVALID_CHARACTER,
                    null,
                    null,
                    null));
        }
    }
}
项目:openjdk-jdk10    文件:DOMErrorHandlerImpl.java   
/**
 * Implementation of DOMErrorHandler.handleError that
 * adds copy of error to list for later retrieval.
 *
 */
public boolean handleError(DOMError error) {
    boolean fail = true;
    String severity = null;
    if (error.getSeverity() == DOMError.SEVERITY_WARNING) {
        fail = false;
        severity = "[Warning]";
    } else if (error.getSeverity() == DOMError.SEVERITY_ERROR) {
        severity = "[Error]";
    } else if (error.getSeverity() == DOMError.SEVERITY_FATAL_ERROR) {
        severity = "[Fatal Error]";
    }

    System.err.println(severity + ": " + error.getMessage() + "\t");
    System.err.println("Type : " + error.getType() + "\t" + "Related Data: "
            + error.getRelatedData() + "\t" + "Related Exception: "
            + error.getRelatedException() );

    return fail;
}
项目:openjdk9    文件:DOMNormalizer.java   
/**
 * Reports a DOM error to the user handler.
 *
 * If the error is fatal, the processing will be always aborted.
 */
public static final void reportDOMError(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
                    String message, short severity, String type ) {
    if( errorHandler!=null ) {
        error.reset();
        error.fMessage = message;
        error.fSeverity = severity;
        error.fLocator = locator;
        error.fType = type;
        error.fRelatedData = locator.fRelatedNode;

        if(!errorHandler.handleError(error))
            throw abort;
    }
    if( severity==DOMError.SEVERITY_FATAL_ERROR )
        throw abort;
}
项目:openjdk9    文件:DOMErrorHandlerWrapper.java   
/**
 * Reports a warning. Warnings are non-fatal and can be safely ignored
 * by most applications.
 *
 * @param domain    The domain of the warning. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this warning.
 * @param key       The warning key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */

public void warning(String domain, String key,
                    XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_WARNING;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode = fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
项目:openjdk9    文件:DOMErrorHandlerWrapper.java   
/**
 * Reports an error. Errors are non-fatal and usually signify that the
 * document is invalid with respect to its grammar(s).
 *
 * @param domain    The domain of the error. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this error.
 * @param key       The error key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */
public void error(String domain, String key,
                  XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_ERROR;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode= fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
项目:openjdk9    文件:DOM3TreeWalker.java   
/**
 * Checks if an CDATASection node is well-formed, by checking it's data
 * for well-formedness.  Note that the presence of a CDATA termination mark
 * in the contents of a CDATASection is handled by the parameter
 * spli-cdata-sections
 *
 * @param data The contents of the comment node
 */
protected void isCDATASectionWellFormed(CDATASection node) {
    // Does the data valid XML character data
    Character invalidChar = isWFXMLChar(node.getData());
    //if (!isWFXMLChar(node.getData(), invalidChar)) {
    if (invalidChar != null) {
        String msg =
            Utils.messages.createMessage(
                MsgKey.ER_WF_INVALID_CHARACTER_IN_CDATA,
                new Object[] { Integer.toHexString(Character.getNumericValue(invalidChar.charValue())) });

        if (fErrorHandler != null) {
            fErrorHandler.handleError(
                new DOMErrorImpl(
                    DOMError.SEVERITY_FATAL_ERROR,
                    msg,
                    MsgKey.ER_WF_INVALID_CHARACTER,
                    null,
                    null,
                    null));
        }
    }
}
项目:openjdk9    文件:DOM3TreeWalker.java   
/**
 * Checks if an Text node is well-formed, by checking if it contains invalid
 * XML characters.
 *
 * @param data The contents of the comment node
 */
protected void isTextWellFormed(Text node) {
    // Does the data valid XML character data
    Character invalidChar = isWFXMLChar(node.getData());
    if (invalidChar != null) {
        String msg =
            Utils.messages.createMessage(
                MsgKey.ER_WF_INVALID_CHARACTER_IN_TEXT,
                new Object[] { Integer.toHexString(Character.getNumericValue(invalidChar.charValue())) });

        if (fErrorHandler != null) {
            fErrorHandler.handleError(
                new DOMErrorImpl(
                    DOMError.SEVERITY_FATAL_ERROR,
                    msg,
                    MsgKey.ER_WF_INVALID_CHARACTER,
                    null,
                    null,
                    null));
        }
    }
}
项目:openjdk9    文件:DOMErrorHandlerImpl.java   
/**
 * Implementation of DOMErrorHandler.handleError that
 * adds copy of error to list for later retrieval.
 *
 */
public boolean handleError(DOMError error) {
    boolean fail = true;
    String severity = null;
    if (error.getSeverity() == DOMError.SEVERITY_WARNING) {
        fail = false;
        severity = "[Warning]";
    } else if (error.getSeverity() == DOMError.SEVERITY_ERROR) {
        severity = "[Error]";
    } else if (error.getSeverity() == DOMError.SEVERITY_FATAL_ERROR) {
        severity = "[Fatal Error]";
    }

    System.err.println(severity + ": " + error.getMessage() + "\t");
    System.err.println("Type : " + error.getType() + "\t" + "Related Data: "
            + error.getRelatedData() + "\t" + "Related Exception: "
            + error.getRelatedException() );

    return fail;
}
项目:Push2Display    文件:AbstractDocument.java   
/**
 * Creates a DOMError object with the given parameters.
 */
protected DOMError createDOMError(String type,
                                  short severity,
                                  String key,
                                  Object[] args,
                                  Node related,
                                  Exception e) {
    try {
        return new DocumentError(type,
                                 severity,
                                 getCurrentDocument().formatMessage(key, args),
                                 related,
                                 e);
    } catch (Exception ex) {
        return new DocumentError(type,
                                 severity,
                                 key,
                                 related,
                                 e);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:DOMNormalizer.java   
/**
 * Reports a DOM error to the user handler.
 *
 * If the error is fatal, the processing will be always aborted.
 */
public static final void reportDOMError(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
                    String message, short severity, String type ) {
    if( errorHandler!=null ) {
        error.reset();
        error.fMessage = message;
        error.fSeverity = severity;
        error.fLocator = locator;
        error.fType = type;
        error.fRelatedData = locator.fRelatedNode;

        if(!errorHandler.handleError(error))
            throw abort;
    }
    if( severity==DOMError.SEVERITY_FATAL_ERROR )
        throw abort;
}
项目:lookaside_java-1.8.0-openjdk    文件:DOMErrorHandlerWrapper.java   
/**
 * Reports a warning. Warnings are non-fatal and can be safely ignored
 * by most applications.
 *
 * @param domain    The domain of the warning. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this warning.
 * @param key       The warning key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */

public void warning(String domain, String key,
                    XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_WARNING;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode = fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:DOMErrorHandlerWrapper.java   
/**
 * Reports an error. Errors are non-fatal and usually signify that the
 * document is invalid with respect to its grammar(s).
 *
 * @param domain    The domain of the error. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this error.
 * @param key       The error key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */
public void error(String domain, String key,
                  XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_ERROR;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode= fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
项目:esper    文件:XSDSchemaMapper.java   
public boolean handleError(DOMError error) {
    String from = schemaResource != null ? schemaResource : "string";
    log.warn("DOM error reported loading schema from " + from + ":\n" +
            "  message: " + error.getMessage() + "\n" +
            "  type: " + error.getType() + "\n" +
            "  related data: " + error.getRelatedData() + "\n" +
            "  related exception: " + error.getRelatedException() + "\n" +
            "  severity: " + error.getSeverity() + "\n" +
            "  location: " + error.getLocation());

    if (error.getRelatedException() instanceof Throwable) {
        Throwable t = (Throwable) error.getRelatedException();
        log.warn("DOM error related exception: " + t.getMessage(), t);
    }

    return false;
}
项目:Push2Display    文件:AbstractDocument.java   
/**
 * Creates a DOMError object with the given parameters.
 */
protected DOMError createDOMError(String type,
                                  short severity,
                                  String key,
                                  Object[] args,
                                  Node related,
                                  Exception e) {
    try {
        return new DocumentError(type,
                                 severity,
                                 getCurrentDocument().formatMessage(key, args),
                                 related,
                                 e);
    } catch (Exception ex) {
        return new DocumentError(type,
                                 severity,
                                 key,
                                 related,
                                 e);
    }
}
项目:infobip-open-jdk-8    文件:DOMNormalizer.java   
/**
 * Reports a DOM error to the user handler.
 *
 * If the error is fatal, the processing will be always aborted.
 */
public static final void reportDOMError(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
                    String message, short severity, String type ) {
    if( errorHandler!=null ) {
        error.reset();
        error.fMessage = message;
        error.fSeverity = severity;
        error.fLocator = locator;
        error.fType = type;
        error.fRelatedData = locator.fRelatedNode;

        if(!errorHandler.handleError(error))
            throw abort;
    }
    if( severity==DOMError.SEVERITY_FATAL_ERROR )
        throw abort;
}
项目:infobip-open-jdk-8    文件:DOMErrorHandlerWrapper.java   
/**
 * Reports a warning. Warnings are non-fatal and can be safely ignored
 * by most applications.
 *
 * @param domain    The domain of the warning. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this warning.
 * @param key       The warning key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */

public void warning(String domain, String key,
                    XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_WARNING;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode = fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
项目:infobip-open-jdk-8    文件:DOMErrorHandlerWrapper.java   
/**
 * Reports an error. Errors are non-fatal and usually signify that the
 * document is invalid with respect to its grammar(s).
 *
 * @param domain    The domain of the error. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this error.
 * @param key       The error key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */
public void error(String domain, String key,
                  XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_ERROR;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode= fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
项目:feathers-sdk    文件:AbstractDocument.java   
/**
 * Creates a DOMError object with the given parameters.
 */
protected DOMError createDOMError(String type,
                                  short severity,
                                  String key,
                                  Object[] args,
                                  Node related,
                                  Exception e) {
    try {
        return new DocumentError(type,
                                 severity,
                                 getCurrentDocument().formatMessage(key, args),
                                 related,
                                 e);
    } catch (Exception ex) {
        return new DocumentError(type,
                                 severity,
                                 key,
                                 related,
                                 e);
    }
}
项目:In-the-Box-Fork    文件:DOM3TreeWalker.java   
/**
 * Checks if an CDATASection node is well-formed, by checking it's data
 * for well-formedness.  Note that the presence of a CDATA termination mark
 * in the contents of a CDATASection is handled by the parameter 
 * spli-cdata-sections
 * 
 * @param data The contents of the comment node
 */
protected void isCDATASectionWellFormed(CDATASection node) {
    // Does the data valid XML character data        
    Character invalidChar = isWFXMLChar(node.getData());
    //if (!isWFXMLChar(node.getData(), invalidChar)) {
    if (invalidChar != null) {
        String msg =
            Utils.messages.createMessage(
                MsgKey.ER_WF_INVALID_CHARACTER_IN_CDATA,
                new Object[] { Integer.toHexString(Character.getNumericValue(invalidChar.charValue())) });

        if (fErrorHandler != null) {
            fErrorHandler.handleError(
                new DOMErrorImpl(
                    DOMError.SEVERITY_FATAL_ERROR,
                    msg,
                    MsgKey.ER_WF_INVALID_CHARACTER,
                    null,
                    null,
                    null));
        }
    }
}
项目:In-the-Box-Fork    文件:DOM3TreeWalker.java   
/**
 * Checks if an Text node is well-formed, by checking if it contains invalid
 * XML characters.
 * 
 * @param data The contents of the comment node
 */
protected void isTextWellFormed(Text node) {
    // Does the data valid XML character data        
    Character invalidChar = isWFXMLChar(node.getData());
    if (invalidChar != null) {
        String msg =
            Utils.messages.createMessage(
                MsgKey.ER_WF_INVALID_CHARACTER_IN_TEXT,
                new Object[] { Integer.toHexString(Character.getNumericValue(invalidChar.charValue())) });

        if (fErrorHandler != null) {
            fErrorHandler.handleError(
                new DOMErrorImpl(
                    DOMError.SEVERITY_FATAL_ERROR,
                    msg,
                    MsgKey.ER_WF_INVALID_CHARACTER,
                    null,
                    null,
                    null));
        }
    }
}
项目:In-the-Box-Fork    文件:DOMErrorHandlerImpl.java   
/**
 * Implementation of DOMErrorHandler.handleError that
 * adds copy of error to list for later retrieval.
 *
 */
public boolean handleError(DOMError error) {
    boolean fail = true;
    String severity = null;
    if (error.getSeverity() == DOMError.SEVERITY_WARNING) {
        fail = false;
        severity = "[Warning]";
    } else if (error.getSeverity() == DOMError.SEVERITY_ERROR) {
        severity = "[Error]";
    } else if (error.getSeverity() == DOMError.SEVERITY_FATAL_ERROR) {
        severity = "[Fatal Error]";
    }

    System.err.println(severity + ": " + error.getMessage() + "\t");
    System.err.println("Type : " + error.getType() + "\t" + "Related Data: "
            + error.getRelatedData() + "\t" + "Related Exception: "
            + error.getRelatedException() );

    return fail;
}
项目:In-the-Box-Fork    文件:NormalizeTest.java   
public void testInvalidCharactersCdata() throws Exception {
    ErrorRecorder errorRecorder = new ErrorRecorder();
    domConfiguration.setParameter("cdata-sections", true);
    domConfiguration.setParameter("error-handler", errorRecorder);
    domConfiguration.setParameter("namespaces", false);
    Element root = document.createElement("foo");
    document.appendChild(root);
    CDATASection cdata = document.createCDATASection("");
    root.appendChild(cdata);

    for (int c = 0; c <= Character.MAX_VALUE; c++) {
        cdata.setData(new String(new char[]{ 'A', 'B', (char) c }));
        document.normalizeDocument();
        if (isValid((char) c)) {
            assertEquals(Collections.<DOMError>emptyList(), errorRecorder.errors);
        } else {
            errorRecorder.assertAllErrors("For character " + c,
                    DOMError.SEVERITY_ERROR, "wf-invalid-character");
        }
    }
}
项目:In-the-Box-Fork    文件:NormalizeTest.java   
public void testInvalidCharactersText() throws Exception {
    ErrorRecorder errorRecorder = new ErrorRecorder();
    domConfiguration.setParameter("error-handler", errorRecorder);
    domConfiguration.setParameter("namespaces", false);
    Element root = document.createElement("foo");
    document.appendChild(root);
    Text text = document.createTextNode("");
    root.appendChild(text);

    for (int c = 0; c <= Character.MAX_VALUE; c++) {
        text.setData(new String(new char[]{ 'A', 'B', (char) c }));
        document.normalizeDocument();
        if (isValid((char) c)) {
            assertEquals(Collections.<DOMError>emptyList(), errorRecorder.errors);
        } else {
            errorRecorder.assertAllErrors("For character " + c,
                    DOMError.SEVERITY_ERROR, "wf-invalid-character");
        }
    }
}
项目:In-the-Box-Fork    文件:NormalizeTest.java   
public void testInvalidCharactersAttribute() throws Exception {
    ErrorRecorder errorRecorder = new ErrorRecorder();
    domConfiguration.setParameter("error-handler", errorRecorder);
    domConfiguration.setParameter("namespaces", false);
    Element root = document.createElement("foo");
    document.appendChild(root);

    for (int c = 0; c <= Character.MAX_VALUE; c++) {
        root.setAttribute("bar", new String(new char[] { 'A', 'B', (char) c}));
        document.normalizeDocument();
        if (isValid((char) c)) {
            assertEquals(Collections.<DOMError>emptyList(), errorRecorder.errors);
        } else {
            errorRecorder.assertAllErrors("For character " + c,
                    DOMError.SEVERITY_ERROR, "wf-invalid-character");
        }
    }
}
项目:In-the-Box-Fork    文件:NormalizeTest.java   
public void testInvalidCharactersComment() throws Exception {
    ErrorRecorder errorRecorder = new ErrorRecorder();
    domConfiguration.setParameter("error-handler", errorRecorder);
    domConfiguration.setParameter("namespaces", false);
    Element root = document.createElement("foo");
    document.appendChild(root);
    Comment comment = document.createComment("");
    root.appendChild(comment);

    for (int c = 0; c <= Character.MAX_VALUE; c++) {
        comment.setData(new String(new char[] { 'A', 'B', (char) c}));
        document.normalizeDocument();
        if (isValid((char) c)) {
            assertEquals(Collections.<DOMError>emptyList(), errorRecorder.errors);
        } else {
            errorRecorder.assertAllErrors("For character " + c,
                    DOMError.SEVERITY_ERROR, "wf-invalid-character");
        }
    }
}
项目:In-the-Box-Fork    文件:NormalizeTest.java   
public void testInvalidCharactersProcessingInstructionData() throws Exception {
    ErrorRecorder errorRecorder = new ErrorRecorder();
    domConfiguration.setParameter("error-handler", errorRecorder);
    domConfiguration.setParameter("namespaces", false);
    Element root = document.createElement("foo");
    document.appendChild(root);
    ProcessingInstruction pi = document.createProcessingInstruction("foo", "");
    root.appendChild(pi);

    for (int c = 0; c <= Character.MAX_VALUE; c++) {
        pi.setData(new String(new char[] { 'A', 'B', (char) c}));
        document.normalizeDocument();
        if (isValid((char) c)) {
            assertEquals(Collections.<DOMError>emptyList(), errorRecorder.errors);
        } else {
            errorRecorder.assertAllErrors("For character " + c,
                    DOMError.SEVERITY_ERROR, "wf-invalid-character");
        }
    }
}
项目:OLD-OpenJDK8    文件:DOMNormalizer.java   
/**
 * Reports a DOM error to the user handler.
 *
 * If the error is fatal, the processing will be always aborted.
 */
public static final void reportDOMError(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
                    String message, short severity, String type ) {
    if( errorHandler!=null ) {
        error.reset();
        error.fMessage = message;
        error.fSeverity = severity;
        error.fLocator = locator;
        error.fType = type;
        error.fRelatedData = locator.fRelatedNode;

        if(!errorHandler.handleError(error))
            throw abort;
    }
    if( severity==DOMError.SEVERITY_FATAL_ERROR )
        throw abort;
}
项目:OLD-OpenJDK8    文件:DOMErrorHandlerWrapper.java   
/**
 * Reports a warning. Warnings are non-fatal and can be safely ignored
 * by most applications.
 *
 * @param domain    The domain of the warning. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this warning.
 * @param key       The warning key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */

public void warning(String domain, String key,
                    XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_WARNING;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode = fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
项目:OLD-OpenJDK8    文件:DOMErrorHandlerWrapper.java   
/**
 * Reports an error. Errors are non-fatal and usually signify that the
 * document is invalid with respect to its grammar(s).
 *
 * @param domain    The domain of the error. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this error.
 * @param key       The error key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */
public void error(String domain, String key,
                  XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_ERROR;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode= fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
项目:SplitCharater    文件:DOMNormalizer.java   
/**
 * Reports a DOM error to the user handler.
 * 
 * If the error is fatal, the processing will be always aborted.
 */
public static final void reportDOMError(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator, 
                    String message, short severity, String type ) {
    if( errorHandler!=null ) {
        error.reset();
        error.fMessage = message;
        error.fSeverity = severity;
        error.fLocator = locator;
        error.fType = type;
        error.fRelatedData = locator.fRelatedNode;

        if(!errorHandler.handleError(error))
            throw abort;
    }
    if( severity==DOMError.SEVERITY_FATAL_ERROR )
        throw abort;
}
项目:SplitCharater    文件:DOMErrorHandlerWrapper.java   
/**
 * Reports a warning. Warnings are non-fatal and can be safely ignored
 * by most applications.
 *
 * @param domain    The domain of the warning. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this warning.
 * @param key       The warning key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */

public void warning(String domain, String key, 
                    XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_WARNING;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;         
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode = fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    } 
}
项目:SplitCharater    文件:DOMErrorHandlerWrapper.java   
/**
 * Reports an error. Errors are non-fatal and usually signify that the
 * document is invalid with respect to its grammar(s).
 *
 * @param domain    The domain of the error. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this error.
 * @param key       The error key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */
public void error(String domain, String key, 
                  XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_ERROR;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode= fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
项目:openjdk-icedtea7    文件:DOMNormalizer.java   
/**
 * Reports a DOM error to the user handler.
 *
 * If the error is fatal, the processing will be always aborted.
 */
public static final void reportDOMError(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
                    String message, short severity, String type ) {
    if( errorHandler!=null ) {
        error.reset();
        error.fMessage = message;
        error.fSeverity = severity;
        error.fLocator = locator;
        error.fType = type;
        error.fRelatedData = locator.fRelatedNode;

        if(!errorHandler.handleError(error))
            throw abort;
    }
    if( severity==DOMError.SEVERITY_FATAL_ERROR )
        throw abort;
}