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:Main.java

private void printInfo(SAXParseException e) {
    System.out.println("   Public ID: " + e.getPublicId());
    System.out.println("   System ID: " + e.getSystemId());
    System.out.println("   Line number: " + e.getLineNumber());
    System.out.println("   Column number: " + e.getColumnNumber());
    System.out.println("   Message: " + e.getMessage());
}

From source file:de.dfki.iui.mmds.dialogue.SiamStateMachine.java

private SCXML load(final String scxml) {

    ErrorHandler errHandler = new ErrorHandler() {
        @Override//from   www. j  ava 2  s  .  com
        public void error(SAXParseException e) throws SAXException {
            System.err.println(e.getMessage());

        }

        @Override
        public void fatalError(SAXParseException e) throws SAXException {
            System.err.println(e.getMessage());

        }

        @Override
        public void warning(SAXParseException e) throws SAXException {
            System.err.println(e.getMessage());
        }
    };

    SCXML stateMachine = null;
    try {
        stateMachine = SCXMLParser.parse(new InputSource(new StringReader(scxml)), errHandler);// ca
        // );
    } catch (IOException | SAXException | ModelException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return stateMachine;
}

From source file:gov.nih.nci.cabig.caaers.esb.client.ESBMessageConsumerImpl.java

public void error(SAXParseException exception) throws SAXException {
    // Bring things to a crashing halt
    log.warn("**Parsing Error**" + "  Line:    " + exception.getLineNumber() + "" + "  URI:     "
            + exception.getSystemId() + "" + "  Message: " + exception.getMessage());
    throw new SAXException("Error encountered");
}

From source file:com.connexta.arbitro.ctx.InputParser.java

/**
 * Standard handler routine for the XML parsing.
 * //from   w ww .  j a v a2  s  .co  m
 * @param exception information on what caused the problem
 */
public void warning(SAXParseException exception) throws SAXException {
    if (logger.isWarnEnabled())
        logger.warn("Warning on line " + exception.getLineNumber() + ": " + exception.getMessage());
}

From source file:gov.nih.nci.cabig.caaers.esb.client.ESBMessageConsumerImpl.java

public void warning(SAXParseException exception) throws SAXException {
    // Bring things to a crashing halt
    log.warn("**Parsing Warning**" + "  Line:    " + exception.getLineNumber() + "" + "  URI:     "
            + exception.getSystemId() + "" + "  Message: " + exception.getMessage());
    throw new SAXException("Warning encountered");
}

From source file:com.connexta.arbitro.ctx.InputParser.java

/**
 * Standard handler routine for the XML parsing.
 * /*from ww w  .j ava  2  s  . co  m*/
 * @param exception information on what caused the problem
 * 
 * @throws SAXException always to halt parsing on errors
 */
public void error(SAXParseException exception) throws SAXException {
    if (logger.isErrorEnabled())
        logger.error("Error on line " + exception.getLineNumber() + ": " + exception.getMessage());

    throw new SAXException("invalid context document");
}

From source file:gov.nih.nci.cabig.caaers.esb.client.ESBMessageConsumerImpl.java

public void fatalError(SAXParseException exception) throws SAXException {
    // Bring things to a crashing halt
    log.warn("**Parsing Fatal Error**" + "  Line:    " + exception.getLineNumber() + "" + "  URI:     "
            + exception.getSystemId() + "" + "  Message: " + exception.getMessage());
    throw new SAXException("Fatal Error encountered");
}

From source file:com.connexta.arbitro.ctx.InputParser.java

/**
 * Standard handler routine for the XML parsing.
 * //ww  w.ja v a  2  s .  c  o m
 * @param exception information on what caused the problem
 * 
 * @throws SAXException always to halt parsing on errors
 */
public void fatalError(SAXParseException exception) throws SAXException {
    if (logger.isErrorEnabled())
        logger.error("FatalError on line " + exception.getLineNumber() + ": " + exception.getMessage());

    throw new SAXException("invalid context document");
}

From source file:edu.scripps.fl.pubchem.web.entrez.ELinkWebSession.java

@SuppressWarnings("unchecked")
protected Collection<ELinkResult> getELinkResultsSAX(final Collection<ELinkResult> relations) throws Exception {
    log.info("Memory in use before inputstream: " + memUsage());
    InputStream is = EUtilsWebSession.getInstance()
            .getInputStream("http://eutils.ncbi.nlm.nih.gov/entrez/eutils/elink.fcgi", getParams()).call();
    log.info("Memory in use after inputstream: " + memUsage());
    SAXParserFactory factory = SAXParserFactory.newInstance();
    SAXParser saxParser = factory.newSAXParser();
    DefaultHandler handler = new DefaultHandler() {
        private ELinkResult result;
        private List<Long> idList;
        private StringBuffer buf;
        private int depth;
        private String linkName;
        private String dbTo;

        public void characters(char ch[], int start, int length) throws SAXException {
            buf.append(ch, start, length);
        }//from w  w w. jav a  2s  . c  om

        public void endElement(String uri, String localName, String qName) throws SAXException {
            if (qName.equalsIgnoreCase("LinkSet"))
                relations.add(result);
            else if (qName.equalsIgnoreCase("LinkSetDb")) {
                if (idList.size() > 0)
                    result.setIds(dbTo, linkName, idList);
            } else if (qName.equalsIgnoreCase("LinkName"))
                linkName = buf.toString();
            else if (qName.equalsIgnoreCase("dbTo"))
                dbTo = buf.toString();
            else if (qName.equalsIgnoreCase("DbFrom"))
                result.setDbFrom(buf.toString());
            else if (qName.equalsIgnoreCase("Id")) {
                Long id = Long.parseLong(buf.toString());
                if (depth == 4)
                    result.setId(id);
                else if (depth == 5)
                    idList.add(id);
            }
            depth--;
        }

        public void startElement(String uri, String localName, String qName, Attributes attributes)
                throws SAXException {
            depth++;
            buf = new StringBuffer();
            if (qName.equalsIgnoreCase("LinkSet"))
                result = new ELinkResult();
            else if (qName.equalsIgnoreCase("LinkSetDb"))
                idList = new ArrayList();
        }
    };
    log.info("Memory in use before parsing: " + memUsage());
    log.info("Parsing elink results using SAX.");
    try {
        saxParser.parse(is, handler);
    } catch (SAXParseException ex) {
        throw new Exception("Error parsing ELink output: " + ex.getMessage());
    }
    log.info("Finished parsing elink results.");
    log.info("Memory in use after parsing: " + memUsage());
    return relations;
}

From source file:com.adaptris.core.transform.XmlSchemaValidator.java

@Override
public void validate(AdaptrisMessage msg) throws CoreException {
    try (InputStream in = msg.getInputStream()) {
        Validator validator = this.obtainSchemaToUse(msg).newValidator();
        validator.setErrorHandler(new ErrorHandlerImp());
        validator.validate(new SAXSource(new InputSource(in)));
    } catch (SAXParseException e) {
        throw new ServiceException(String.format("Error validating message[%s] line [%s] column[%s]",
                e.getMessage(), e.getLineNumber(), e.getColumnNumber()), e);
    } catch (Exception e) {
        throw ExceptionHelper.wrapServiceException("Failed to validate message", e);
    }//from  ww w  .  j a va 2  s  . co  m
}