Example usage for org.xml.sax SAXParseException getMessage

List of usage examples for org.xml.sax SAXParseException getMessage

Introduction

In this page you can find the example usage for org.xml.sax SAXParseException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Return a detail message for this exception.

Usage

From source file:org.plasma.sdo.xml.DefaultErrorHandler.java

public void fatalError(SAXParseException e) throws SAXException {
    String msg = "line:column[" + e.getLineNumber() + ":" + e.getColumnNumber() + "]";
    msg += " - " + e.getMessage();
    if (options.isFailOnValidationError()) {
        throw new SAXParseException(msg, new ErrorLocator(e));
    } else {//from  w  w  w  .  ja  va 2 s  .c  o m
        if (options.getValidationLog() != null) {
            options.getValidationLog().fatal(msg);
        } else
            log.fatal(msg);
    }
}

From source file:org.plasma.sdo.xml.DefaultErrorHandler.java

public void warning(SAXParseException e) throws SAXException {
    String msg = "line:column[" + e.getLineNumber() + ":" + e.getColumnNumber() + "]";
    msg += " - " + e.getMessage();
    if (options.getValidationLog() != null) {
        options.getValidationLog().warn(msg);
    } else/*from   w  ww .  j a va 2 s. com*/
        log.warn(msg);
}

From source file:org.roda.core.common.validation.ValidationUtils.java

private static ValidationIssue convertSAXParseException(SAXParseException e) {
    ValidationIssue issue = new ValidationIssue();
    issue.setMessage(e.getMessage());
    issue.setLineNumber(e.getLineNumber());
    issue.setColumnNumber(e.getColumnNumber());

    return issue;
}

From source file:org.sakaibrary.osid.repository.xserver.AssetIterator.java

/**
 * This method parses the xml StringBuilder and creates Assets, Records
 * and Parts in the Repository with the given repositoryId.
 *
 * @param xml input xml in "sakaibrary" format
 * @param log the log being used by the Repository
 * @param repositoryId the Id of the Repository in which to create Assets,
 * Records and Parts.//from   www  . ja v  a  2  s .c o  m
 *
 * @throws org.osid.repository.RepositoryException
 */
private void createAssets(java.io.ByteArrayInputStream xml, org.osid.shared.Id repositoryId)
        throws org.osid.repository.RepositoryException {
    this.repositoryId = repositoryId;
    recordStructureId = RecordStructure.getInstance().getId();
    textBuffer = new StringBuilder();

    // use a SAX parser
    javax.xml.parsers.SAXParserFactory factory;
    javax.xml.parsers.SAXParser saxParser;

    // set up the parser
    factory = javax.xml.parsers.SAXParserFactory.newInstance();
    factory.setNamespaceAware(true);

    // start parsing
    try {
        saxParser = factory.newSAXParser();
        saxParser.parse(xml, this);
        xml.close();
    } catch (SAXParseException spe) {
        // Use the contained exception, if any
        Exception x = spe;

        if (spe.getException() != null) {
            x = spe.getException();
        }

        // Error generated by the parser
        LOG.warn("createAssets() parsing exception: " + spe.getMessage() + " - xml line " + spe.getLineNumber()
                + ", uri " + spe.getSystemId(), x);
    } catch (SAXException sxe) {
        // Error generated by this application
        // (or a parser-initialization error)
        Exception x = sxe;

        if (sxe.getException() != null) {
            x = sxe.getException();
        }

        LOG.warn("createAssets() SAX exception: " + sxe.getMessage(), x);
    } catch (ParserConfigurationException pce) {
        // Parser with specified options can't be built
        LOG.warn("createAssets() SAX parser cannot be built with " + "specified options");
    } catch (IOException ioe) {
        // I/O error
        LOG.warn("createAssets() IO exception", ioe);
    }
}

From source file:org.sakaibrary.xserver.XMLCleanup.java

public ByteArrayOutputStream cleanup(InputStream xml) throws XServerException {
    inputXml = xml;/*from   w w  w . jav a 2s . c o  m*/

    // Use the default (non-validating) parser
    SAXParserFactory factory = SAXParserFactory.newInstance();

    try {
        // Parse the input
        SAXParser saxParser = factory.newSAXParser();
        saxParser.parse(inputXml, this);

        // close the stream
        inputXml.close();
    } catch (SAXParseException spe) {
        // Use the contained exception, if any
        Exception x = spe;

        if (spe.getException() != null) {
            x = spe.getException();
        }

        // Error generated by the parser
        LOG.warn("XMLCleanup.cleanup() parsing exception: " + spe.getMessage() + " - xml line "
                + spe.getLineNumber() + ", uri " + spe.getSystemId(), x);
    } catch (SAXException sxe) {
        // Error generated by this application
        // (or a parser-initialization error)
        Exception x = sxe;

        if (sxe.getException() != null) {
            x = sxe.getException();
        }

        LOG.warn("XMLCleanup.cleanup() SAX exception: " + sxe.getMessage(), x);
    } catch (ParserConfigurationException pce) {
        // Parser with specified options can't be built
        LOG.warn("XMLCleanup.cleanup() SAX parser cannot be built with " + "specified options");
    } catch (IOException ioe) {
        // I/O error
        LOG.warn("XMLCleanup.cleanup() IO exception", ioe);
    } catch (Throwable t) {
        LOG.warn("XMLCleanup.cleanup() exception", t);
    }

    if (error) {
        throw new XServerException(error_code, error_text);
    }

    return bytes;
}

From source file:org.sakaibrary.xserver.XMLCleanup.java

public void warning(SAXParseException err) throws SAXParseException {
    LOG.warn("SAXParser warning" + ", xml line " + err.getLineNumber() + ", uri " + err.getSystemId());
    LOG.warn("   " + err.getMessage());
}

From source file:org.seasar.mayaa.impl.builder.SpecificationNodeHandler.java

private String exceptionMessage(SAXParseException e) {
    return "The problem occurred during Perse. " + _specification.getSystemID()
            + ((e.getMessage() != null) ? " - " + e.getMessage() : "");
}

From source file:org.seasar.mayaa.impl.util.xml.XMLHandler.java

public void warning(SAXParseException e) {
    Log log = getLog();//from   ww  w .j  a va  2s .  c  o m
    if (log != null && log.isWarnEnabled()) {
        log.warn(e.getMessage(), e);
    }
}

From source file:org.seasar.mayaa.impl.util.xml.XMLHandler.java

public void error(SAXParseException e) {
    Log log = getLog();/*w ww.  j a va  2s .com*/
    if (log != null && log.isErrorEnabled()) {
        log.error(e.getMessage(), e);
    }
    throw new RuntimeException(e);
}

From source file:org.seasar.mayaa.impl.util.xml.XMLHandler.java

public void fatalError(SAXParseException e) {
    Log log = getLog();/*from   w w  w .  ja  v  a2  s  .  com*/
    if (log != null && log.isFatalEnabled()) {
        log.fatal(e.getMessage(), e);
    }
    throw new RuntimeException(e);
}