List of usage examples for org.xml.sax SAXException getMessage
public String getMessage()
From source file:com.janoz.tvapilib.support.XmlParsingObject.java
protected void parse(AbstractSaxParser parser, InputStream inputStream) { try {//from w w w .jav a 2 s.c o m InputSource input = new InputSource(inputStream); input.setPublicId(""); input.setSystemId(""); XMLReader reader = XMLReaderFactory.createXMLReader(); reader.setContentHandler(parser); reader.parse(input); } catch (SAXException e) { LOG.info("Error parsing XML data.", e); throw new TvApiException(e.getMessage(), e); } catch (IOException e) { LOG.info("IO error while parsing XML data.", e); throw new TvApiException("IO error while parsing XML data.", e); } }
From source file:com.wudaosoft.net.httpclient.SAXSourceResponseHandler.java
private SAXSource readSAXSource(InputStream body) throws IOException { try {// www . j ava2 s .com XMLReader reader = XMLReaderFactory.createXMLReader(); reader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); reader.setFeature("http://xml.org/sax/features/external-general-entities", false); reader.setEntityResolver(NO_OP_ENTITY_RESOLVER); return new SAXSource(reader, new InputSource(body)); } catch (SAXException ex) { throw new ClientProtocolException("Could not parse document: " + ex.getMessage(), ex); } }
From source file:org.omg.bpmn.miwg.bpmn2_0.comparison.Bpmn20ConformanceChecker.java
public List<Difference> getSignificantDifferences(InputStream expectedBpmnXml, InputStream actualBpmnXml) throws IOException, ParserConfigurationException { try {/* www .j a v a 2 s.c o m*/ Document expectedBpmnXmlDoc = docBuilder.parse(expectedBpmnXml); Document actualBpmnXmlDoc = docBuilder.parse(actualBpmnXml); return xmlDiff.areDocumentsEqualReporting(expectedBpmnXmlDoc, actualBpmnXmlDoc); } catch (SAXException e) { throw new IOException(e.getMessage(), e.getCause()); } }
From source file:fr.paris.lutece.plugins.mylutece.modules.oauth.authentication.XMLCredentialRetriever.java
/** * *{@inheritDoc}/*from ww w. jav a 2 s. co m*/ */ public void doRetrieveUserInfo(HttpResponse httpResponse, OAuthUser user) { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(httpResponse.getEntity().getContent()); for (Entry<String, String[]> entry : getTags().entrySet()) { for (String strTag : entry.getValue()) { NodeList nodeList = doc.getElementsByTagName(strTag); if ((nodeList != null) && (nodeList.getLength() > 0)) { String strValue = nodeList.item(0).getFirstChild().getNodeValue(); if (AppLogService.isDebugEnabled()) { AppLogService.debug("Retrieved " + strValue + " for " + entry.getKey()); } user.setUserInfo(entry.getKey(), strValue); if (entry.getKey().equals(LuteceUser.NAME_FAMILY)) { user.setName(strValue); } break; // no need to find other values } } } } catch (SAXException e) { AppLogService.error(e.getMessage(), e); } catch (ParserConfigurationException e) { AppLogService.error(e.getMessage(), e); } catch (IllegalStateException e) { AppLogService.error(e.getMessage(), e); } catch (IOException e) { AppLogService.error(e.getMessage(), e); } }
From source file:org.energyos.espi.datacustodian.web.custodian.UploadController.java
@RequestMapping(value = Routes.DATA_CUSTODIAN_UPLOAD, method = RequestMethod.POST) public String uploadPost(@ModelAttribute UploadForm uploadForm, BindingResult result) throws IOException, JAXBException { try {/* www . jav a2 s . c om*/ importService.importData(uploadForm.getFile().getInputStream(), null); return "redirect:/custodian/retailcustomers"; } catch (SAXException e) { result.addError(new ObjectError("uploadForm", e.getMessage())); return "/custodian/upload"; } catch (Exception e) { result.addError(new ObjectError("uploadForm", "Unable to process file")); return "/custodian/upload"; } }
From source file:de.weltraumschaf.groundzero.transform.ReportReader.java
/** * Dedicated constructor./*w w w. j a v a 2 s. co m*/ * * Set up the XML reader with the SAX handler. * * @param handler must not be {@code null} * @throws CreateXmlReaderException if creation of XML reader fails */ ReportReader(final CheckstyleSaxHandler handler) throws CreateXmlReaderException { super(); Validate.notNull(handler, "Parameter handler must not be null!"); this.handler = handler; try { xmlReader = XMLReaderFactory.createXMLReader(); } catch (final SAXException ex) { throw new CreateXmlReaderException(ex.getMessage(), ex); } xmlReader.setContentHandler(handler); xmlReader.setErrorHandler(handler); }
From source file:com.ebay.jetstream.event.processor.esper.raw.EsperTestConfigurationValidator.java
public boolean validate(String instance, String schema) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try {// w w w . j ava 2 s .c o m warnings = 0; errors = 0; fatalErrors = 0; try { //Set the validation feature factory.setFeature("http://xml.org/sax/features/validation", true); //Set the schema validation feature factory.setFeature("http://apache.org/xml/features/validation/schema", true); //Set schema full grammar checking factory.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true); // If there is an external schema set it if (schema != null) { SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema s = sf.newSchema(new StreamSource(schema)); factory.setSchema(s); } DocumentBuilder parser = factory.newDocumentBuilder(); parser.setErrorHandler(this); // Parse and validate parser.parse(instance); // Return true if we made it this far with no errors return ((errors == 0) && (fatalErrors == 0)); } catch (SAXException e) { log.error("Could not activate validation features - " + e.getMessage()); } } catch (Exception e) { log.error(e.getMessage()); } return false; }
From source file:net.nicholaswilliams.java.teamcity.plugin.buildNumber.TestConfigurationDigesterModule.java
@Test public void testInvalidFile() throws IOException, SAXException { try {// w w w . j a v a 2 s . com this.digester.parse(this.getResource("testInvalidFile.xml")); fail("Expected exception org.xml.sax.SAXException, got no exception."); } catch (SAXException e) { assertTrue("The error message [" + e.getMessage() + "] is not correct.", e.getMessage() .contains("The content of element 'shared-build-number-config' is not complete.")); } }
From source file:net.nicholaswilliams.java.teamcity.plugin.buildNumber.TestConfigurationDigesterModule.java
@Test public void testInvalidLastUpdateDate() throws IOException, SAXException { try {/*w w w.j av a 2s. c o m*/ this.digester.parse(this.getResource("testInvalidLastUpdateDate.xml")); fail("Expected exception org.xml.sax.SAXException, got no exception."); } catch (SAXException e) { assertTrue("The error message [" + e.getMessage() + "] is not correct.", e.getMessage().contains("is not a valid value for 'dateTime'.")); } }
From source file:net.i2cat.netconf.test.TransportContentparserTest.java
private void parseMessage(String message) throws IOException, SAXException { try {/*from ww w. j a v a 2 s.com*/ parser.parse(new InputSource(new StringReader(message))); } catch (SAXException e) { if (e.getMessage().contentEquals("Content is not allowed in trailing section.")) { // Using shitty non-xml delimiters forces us to detect // end-of-frame by a SAX error. // Blame netconf } else { throw e; } } }