List of usage examples for org.xml.sax SAXException getMessage
public String getMessage()
From source file:com.telefonica.euro_iaas.paasmanager.installator.rec.services.impl.AbstractBaseService.java
public Document getDocument(String xml) throws ProductInstallatorException { Document doc;//from w w w . j av a 2 s. c o m DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder; try { docBuilder = docBuilderFactory.newDocumentBuilder(); InputStream is = new ByteArrayInputStream(xml.getBytes("UTF-8")); doc = docBuilder.parse(is); } catch (ParserConfigurationException e1) { String msg = "Error parsing vsstring. Desc: " + e1.getMessage(); throw new ProductInstallatorException(msg); } catch (SAXException e) { String msg = "SAXException. Desc: " + e.getMessage(); throw new ProductInstallatorException(msg); } catch (IOException e) { String msg = "IOException. Desc: " + e.getMessage(); throw new ProductInstallatorException(msg); } return doc; }
From source file:org.callimachusproject.xproc.SparqlStep.java
public void run() throws SaxonApiException { if (queryPipe == null || !queryPipe.moreDocuments()) { throw XProcException.dynamicError(6, step.getNode(), "No query provided."); }//from w w w . j av a 2s .c om try { RepositoryConnection con; if (endpoint == null || endpoint.length() == 0) { con = createConnection(); } else { con = createConnection(resolve(endpoint)); } try { while (sourcePipe != null && sourcePipe.moreDocuments()) { importData(sourcePipe.read(), con); } while (queryPipe.moreDocuments()) { XdmNode query = queryPipe.read(); String queryBaseURI = resolve(query.getBaseURI().toASCIIString()); String queryString = getQueryString(query); XdmNode factory = evaluate(queryString, queryBaseURI, con); resultPipe.write(factory); } } finally { Repository repo = con.getRepository(); con.close(); if (endpoint == null || endpoint.length() == 0) { repo.shutDown(); } } } catch (SAXException e) { throw XProcException.dynamicError(30, step.getNode(), e, e.getMessage()); } catch (SaxonApiException e) { throw XProcException.dynamicError(30, step.getNode(), e, e.getMessage()); } catch (FluidException e) { throw XProcException.dynamicError(30, step.getNode(), e, e.getMessage()); } catch (IOException e) { throw XProcException.dynamicError(30, step.getNode(), e, e.getMessage()); } catch (OpenRDFException e) { throw XProcException.dynamicError(30, step.getNode(), e, e.getMessage()); } }
From source file:com.w20e.socrates.factories.XMLQuestionnaireFactory.java
/** * Create the Survey Model identified by a URL. The URL specifies the * protocol to retrieve the questionnaire, and all possible parts to * uniquely identify the questionnaire for this protocol. In case of the * file protocol for example, the URL should look like: file:// [path to * file].//ww w . j ava2 s. c om * * Note that each time a new Digester is created. This is because the API * sais you should... * * @param url * Indicating the location of the model. * @throws UnsupportedProtocolException * When the protocol in URL is not supported * @return a WoliWeb model. * @throws NotFoundException * @throws InvalidException * @throws * @todo which protocols are supported by digester? * @todo Maybe rendering/instance parsing can be made more efficient? */ @Override public final synchronized Questionnaire createQuestionnaire(final URI uri, final Configuration cfg) throws UnsupportedProtocolException, NotFoundException, InvalidException { String uristr = uri.toString(); if (uristr.startsWith("file:")) { LOGGER.fine("We have a file URI..."); uristr = uristr.replace("$HOME", System.getProperty("user.home")); if (uristr.startsWith("file:.")) { if (System.getProperty("socrates.cfg.root") != null) { uristr = uristr.replaceAll("^file:\\.", "file:" + System.getProperty("socrates.cfg.root")); } } } LOGGER.fine("Creating model for " + uristr); try { QuestionnaireImpl q = (QuestionnaireImpl) createInstanceDigester().parse(uristr); q.setRenderConfig((RenderConfig) createRenderingDigester(cfg).parse(uristr)); return q; } catch (IOException e) { LOGGER.severe("Couldn't create model: " + e.getMessage()); throw new NotFoundException(e); } catch (SAXException se) { LOGGER.severe("Couldn't create model: " + se.getMessage()); throw new InvalidException(se); } }
From source file:com.icesoft.jasper.xmlparser.ParserUtils.java
/** * Parse the specified XML document, and return a <code>TreeNode</code> that * corresponds to the root node of the document tree. * * @param uri URI of the XML document being parsed * @param is Input stream containing the deployment descriptor * @throws JasperException if an input/output error occurs * @throws JasperException if a parsing error occurs *//* w ww . j av a2 s. co m*/ public TreeNode parseXMLDocument(String uri, InputStream is) throws JasperException { Document document = null; // Perform an XML parse of this document, via JAXP try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(validating); DocumentBuilder builder = factory.newDocumentBuilder(); builder.setEntityResolver(entityResolver); builder.setErrorHandler(errorHandler); document = builder.parse(is); } catch (ParserConfigurationException ex) { throw new JasperException(Localizer.getMessage("jsp.error.parse.xml", uri), ex); } catch (SAXParseException ex) { throw new JasperException(Localizer.getMessage("jsp.error.parse.xml.line", uri, Integer.toString(ex.getLineNumber()), Integer.toString(ex.getColumnNumber())), ex); } catch (SAXException sx) { if (log.isErrorEnabled()) { log.error("XML parsing failed for " + uri + "SAXException: " + sx.getMessage()); } throw new JasperException( Localizer.getMessage("jsp.error.parse.xml", uri) + "SAXException: " + sx.getMessage(), sx); } catch (IOException io) { throw new JasperException(Localizer.getMessage("jsp.error.parse.xml", uri), io); } // Convert the resulting document to a graph of TreeNodes return (convert(null, document.getDocumentElement())); }
From source file:eu.eidas.auth.engine.SAMLEngineUtils.java
private static void parseSignedDoc(List<XMLObject> attributeValues, String nameSpace, String prefix, String value) {//from w ww .ja v a 2 s .co m DocumentBuilderFactory domFactory = EIDASSAMLEngine.newDocumentBuilderFactory(); domFactory.setNamespaceAware(true); Document document = null; DocumentBuilder builder; // Parse the signedDoc value into an XML DOM Document try { builder = domFactory.newDocumentBuilder(); InputStream is; is = new ByteArrayInputStream(value.trim().getBytes("UTF-8")); document = builder.parse(is); is.close(); } catch (SAXException e1) { LOG.info("ERROR : SAX Error while parsing signModule attribute", e1.getMessage()); LOG.debug("ERROR : SAX Error while parsing signModule attribute", e1); throw new EIDASSAMLEngineRuntimeException(e1); } catch (ParserConfigurationException e2) { LOG.info("ERROR : Parser Configuration Error while parsing signModule attribute", e2.getMessage()); LOG.debug("ERROR : Parser Configuration Error while parsing signModule attribute", e2); throw new EIDASSAMLEngineRuntimeException(e2); } catch (UnsupportedEncodingException e3) { LOG.info("ERROR : Unsupported encoding Error while parsing signModule attribute", e3.getMessage()); LOG.debug("ERROR : Unsupported encoding Error while parsing signModule attribute", e3); throw new EIDASSAMLEngineRuntimeException(e3); } catch (IOException e4) { LOG.info("ERROR : IO Error while parsing signModule attribute", e4.getMessage()); LOG.debug("ERROR : IO Error while parsing signModule attribute", e4); throw new EIDASSAMLEngineRuntimeException(e4); } // Create the XML statement(this will be overwritten with the previous DOM structure) final XSAny xmlValue = (XSAny) SAMLEngineUtils.createSamlObject(new QName(nameSpace, "XMLValue", prefix), XSAny.TYPE_NAME); //Set the signedDoc XML content to this element xmlValue.setDOM(document.getDocumentElement()); // Create the attribute statement final XSAny attrValue = (XSAny) SAMLEngineUtils .createSamlObject(new QName(nameSpace, "AttributeValue", prefix), XSAny.TYPE_NAME); //Add previous signedDocXML to the AttributeValue Element attrValue.getUnknownXMLObjects().add(xmlValue); attributeValues.add(attrValue); }
From source file:demo.SourceHttpMessageConverter.java
private SAXSource readSAXSource(InputStream body) throws IOException { try {/*from w w w. j a v a 2s .co m*/ XMLReader reader = XMLReaderFactory.createXMLReader(); reader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", !isSupportDtd()); reader.setFeature("http://xml.org/sax/features/external-general-entities", isProcessExternalEntities()); if (!isProcessExternalEntities()) { reader.setEntityResolver(NO_OP_ENTITY_RESOLVER); } byte[] bytes = StreamUtils.copyToByteArray(body); return new SAXSource(reader, new InputSource(new ByteArrayInputStream(bytes))); } catch (SAXException ex) { throw new HttpMessageNotReadableException("Could not parse document: " + ex.getMessage(), ex); } }
From source file:fr.paris.lutece.plugins.dila.modules.solr.utils.parsers.DilaSolrLocalParser.java
/** * Launches the parsing on each local card * * @param localCardsList the local cards * @param parser the SAX parser/*from www . j ava 2s .c o m*/ */ private void parseAllLocalCards(List<LocalDTO> localCardsList, SAXParser parser) { if (CollectionUtils.isNotEmpty(localCardsList)) { for (LocalDTO currentCard : localCardsList) { InputStream xmlInput = new ByteArrayInputStream(currentCard.getXml().getBytes()); // Launches the parsing of this local card (with the current handler) try { parser.parse(xmlInput, this); } catch (SAXException e) { AppLogService.error(e.getMessage(), e); } catch (IOException e) { AppLogService.error(e.getMessage(), e); } } } }
From source file:com.keithhutton.ws.proxy.ProxyServlet.java
protected void writeResponse(XmlRpcStreamRequestConfig pConfig, OutputStream pStream, Object pResult) throws XmlRpcException { try {//w ww. j a v a2s. c o m getXmlRpcWriter(pConfig, pStream).write(pConfig, pResult); } catch (SAXException e) { throw new XmlRpcException("Failed to write XML-RPC response: " + e.getMessage(), e); } }
From source file:net.sf.joost.trax.TemplatesImpl.java
/** * Method returns a Transformer-instance for transformation-process * @return A <code>Transformer</code> object. * @throws TransformerConfigurationException *///from w w w .j a va2s.co m public Transformer newTransformer() throws TransformerConfigurationException { synchronized (reentryGuard) { if (DEBUG) log.debug("calling newTransformer to get a " + "Transformer object for Transformation"); try { // register the processor Transformer transformer = new TransformerImpl(processor.copy()); if (factory.getURIResolver() != null) transformer.setURIResolver(factory.getURIResolver()); return transformer; } catch (SAXException e) { if (log != null) log.fatal(e); throw new TransformerConfigurationException(e.getMessage()); } } }
From source file:XMLProperties.java
/** * Reads a property list from an input stream. * /*from ww w. j av a 2 s .c o m*/ * @param in * the input stream. * @exception IOException * if an error occurred when reading from the input stream. * @since JDK1.0 */ public synchronized void load(InputStream in) throws IOException { XMLParser p = null; try { p = new XMLParser(in); } catch (SAXException e) { throw new IOException(e.getMessage()); } }