private static DocumentBuilder getParser() { try { // we'd really like to cache those DocumentBuilders, but we can't because: // 1. thread safety. parsers are not thread-safe, so at least // we need one instance per a thread. // 2. parsers are non-reentrant, so now we are looking at having a // pool of parsers. // 3. then the class loading issue. The look-up procedure of // DocumentBuilderFactory.newInstance() depends on context class loader // and system properties, which may change during the execution of JVM. // // so we really have to create a fresh DocumentBuilder every time we need one // - KK DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware( true ); dbf.setValidating( false ); return dbf.newDocumentBuilder(); } catch (ParserConfigurationException e) { // this should never happen with a well-behaving JAXP implementation. throw new Error(e.toString()); } }
private static DocumentBuilder getParser() { try { // we'd really like to cache those DocumentBuilders, but we can't because: // 1. thread safety. parsers are not thread-safe, so at least // we need one instance per a thread. // 2. parsers are non-reentrant, so now we are looking at having a // pool of parsers. // 3. then the class loading issue. The look-up procedure of // DocumentBuilderFactory.newInstance() depends on context class loader // and system properties, which may change during the execution of JVM. // // so we really have to create a fresh DocumentBuilder every time we need one // - KK DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware( true ); dbf.setValidating( false ); return dbf.newDocumentBuilder(); } catch (ParserConfigurationException e) { // this should never happen with a well-behaving JAXP implementation. throw new Error(e.toString()); } }
public void createFiles(OutputStream fos) throws IOException { try { final ScxmlStateDiagramStandard xmi; xmi = new ScxmlStateDiagramStandard(diagram); xmi.transformerXml(fos); } catch (ParserConfigurationException e) { Log.error(e.toString()); e.printStackTrace(); throw new IOException(e.toString()); } catch (TransformerException e) { Log.error(e.toString()); e.printStackTrace(); throw new IOException(e.toString()); } }
final IOException exception = new IOException(e.toString()); exception.initCause(e); throw exception;
public void createFiles(OutputStream fos) throws IOException { try { final IXmiClassDiagram xmi; if (diagram instanceof StateDiagram) { xmi = new XmiStateDiagram((StateDiagram) diagram); } else if (diagram instanceof DescriptionDiagram) { xmi = new XmiDescriptionDiagram((DescriptionDiagram) diagram); } else if (fileFormat == FileFormat.XMI_STANDARD) { xmi = new XmiClassDiagramStandard((ClassDiagram) diagram); } else if (fileFormat == FileFormat.XMI_ARGO) { xmi = new XmiClassDiagramArgo((ClassDiagram) diagram); } else if (fileFormat == FileFormat.XMI_STAR) { xmi = new XmiClassDiagramStar((ClassDiagram) diagram); } else { throw new UnsupportedOperationException(); } xmi.transformerXml(fos); } catch (ParserConfigurationException e) { Log.error(e.toString()); e.printStackTrace(); throw new IOException(e.toString()); } catch (TransformerException e) { Log.error(e.toString()); e.printStackTrace(); throw new IOException(e.toString()); } }
protected void printResponse() { try { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); DOMImplementationLS ls = (DOMImplementationLS)docBuilder.getDOMImplementation(); LSSerializer lss = ls.createLSSerializer(); System.out.println(lss.writeToString(_docResponse)); } catch (ParserConfigurationException e) { s_logger.error("Error parsing the repsonse : " + e.toString()); } } }
public Document getDOM() { try { if (document == null) { document = DomBuilder.build(getResult()); } return document; } catch (ParserConfigurationException e) { LOGGER.error(e); throw new RuntimeException(e.toString()); } }
protected void initialize() { try { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); docFactory.setNamespaceAware(true); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); _docResponse = docBuilder.parse(new InputSource(new StringReader(_xmlResponse))); if (_docResponse != null) { parse(_docResponse.getDocumentElement()); } } catch (ParserConfigurationException e) { s_logger.error("Error parsing the response : " + e.toString()); } catch (SAXException e) { s_logger.error("Error parsing the response : " + e.toString()); } catch (IOException e) { s_logger.error("Error parsing the response : " + e.toString()); } }
public LibvirtStorageVolumeDef parseStorageVolumeXML(String volXML) { DocumentBuilder builder; try { builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(volXML)); Document doc = builder.parse(is); Element rootElement = doc.getDocumentElement(); String VolName = getTagValue("name", rootElement); Element target = (Element)rootElement.getElementsByTagName("target").item(0); String format = getAttrValue("type", "format", target); Long capacity = Long.parseLong(getTagValue("capacity", rootElement)); return new LibvirtStorageVolumeDef(VolName, capacity, LibvirtStorageVolumeDef.VolumeFormat.getFormat(format), null, null); } catch (ParserConfigurationException e) { s_logger.debug(e.toString()); } catch (SAXException e) { s_logger.debug(e.toString()); } catch (IOException e) { s_logger.debug(e.toString()); } return null; }
s_logger.debug(e.toString()); } catch (SAXException e) { s_logger.debug(e.toString());
s_logger.debug(e.toString()); } catch (SAXException e) { s_logger.debug(e.toString());
s_logger.debug(e.toString()); } catch (SAXException e) { s_logger.debug(e.toString());
/** * Convert a configuration tree into a DOM Element tree. */ public static Element toElement(final ConfigurationHelper configuration) { try { final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); final DocumentBuilder builder = factory.newDocumentBuilder(); final Document document = builder.newDocument(); return createElement(document, configuration); } catch (final ParserConfigurationException pce) { throw new IllegalStateException(pce.toString()); } }
@Override public Element createElement(String tagName) throws DOMException { if (this.xmlDocument == null) { try { this.xmlDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); } catch (ParserConfigurationException ex) { throw new DOMException(DOMException.INVALID_STATE_ERR, ex.toString()); } } return this.xmlDocument.createElement(tagName); }
public FilterReader(Reader in) { super(in); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); parse(toInputStream(in), baos); this.in = new InputStreamReader(new ByteArrayInputStream(baos.toByteArray()), "utf-8"); } catch (IOException e) { throw new RuntimeException("Error while reading xcss content : " + e.toString(), e); } catch (SAXException e) { throw new RuntimeException("Error while reading xml xcss content : " + e.toString(), e); } catch (ParserConfigurationException e) { throw new RuntimeException("Error while parsing xml xcss content : " + e.toString(), e); } }
public void createFiles(OutputStream fos) throws IOException { try { final ScxmlStateDiagramStandard xmi; xmi = new ScxmlStateDiagramStandard(diagram); xmi.transformerXml(fos); } catch (ParserConfigurationException e) { Log.error(e.toString()); e.printStackTrace(); throw new IOException(e.toString()); } catch (TransformerException e) { Log.error(e.toString()); e.printStackTrace(); throw new IOException(e.toString()); } }
public Map<String, String> read(String response,String endpoint) throws ClientException{ Element root; try { root = XmlUtils.getRootElementFromString(response); read(root, endpoint, false); } catch (ParserConfigurationException e) { new ClientException("SDK.InvalidXMLParser", e.toString()); } catch (SAXException e) { new ClientException("SDK.InvalidXMLFormat", e.toString()); } catch (IOException e) { new ClientException("SDK.InvalidContent", e.toString()); } return map; }
@Override public ValidationMessage[] validate(String prefix, String uri, PageData page) { try { PermittedTaglibsHandler h = new PermittedTaglibsHandler(prefix, uri); parser.parse(page, h); return h.getResult(); } catch (SAXException ex) { return vmFromString(ex.toString()); } catch (ParserConfigurationException ex) { return vmFromString(ex.toString()); } catch (IOException ex) { return vmFromString(ex.toString()); } }
@Override public ValidationMessage[] validate(String prefix, String uri, PageData page) { try { PermittedTaglibsHandler h = new PermittedTaglibsHandler(prefix, uri); parser.parse(page, h); return h.getResult(); } catch (SAXException ex) { return vmFromString(ex.toString()); } catch (ParserConfigurationException ex) { return vmFromString(ex.toString()); } catch (IOException ex) { return vmFromString(ex.toString()); } }
@Override public Map<String, String> read(String response, String endpoint) throws ClientException { Element root; try { root = XmlUtils.getRootElementFromString(response); read(root, endpoint, false); } catch (ParserConfigurationException e) { new ClientException("SDK.InvalidXMLParser", e.toString()); } catch (SAXException e) { new ClientException("SDK.InvalidXMLFormat", e.toString()); } catch (IOException e) { new ClientException("SDK.InvalidContent", e.toString()); } return map; }