Java Code Examples for javax.xml.transform.TransformerException#printStackTrace()
The following examples show how to use
javax.xml.transform.TransformerException#printStackTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LearningDesignRepositoryServlet.java From lams with GNU General Public License v2.0 | 6 votes |
/** * the format should be something like this: [ ['My Workspace', null, ['Mary Morgan Folder', null, ['3 activity * sequence','1024'] ], ['Organisations', null, ['Developers Playpen', null, ['Lesson Sequence Folder', null, * ['',null] ] ], ['MATH111', null, ['Lesson Sequence Folder', null, ['',null] ] ] ] ] ] */ @Override public String toString() { // return '[' + convert() + ']'; Document document = getDocument(); try { DOMSource domSource = new DOMSource(document); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.transform(domSource, result); return writer.toString(); } catch (TransformerException ex) { ex.printStackTrace(); return null; } }
Example 2
Source File: AbstractYahooTermExtractor.java From wandora with GNU General Public License v3.0 | 6 votes |
protected String getStringFromDocument(Document doc) { try { DOMSource domSource = new DOMSource(doc); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.transform(domSource, result); return writer.toString(); } catch(TransformerException ex) { ex.printStackTrace(); return null; } }
Example 3
Source File: AbstractUClassifier.java From wandora with GNU General Public License v3.0 | 6 votes |
protected String getStringFromDocument(Document doc) { try { DOMSource domSource = new DOMSource(doc); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.transform(domSource, result); return writer.toString(); } catch(TransformerException ex) { ex.printStackTrace(); return null; } }
Example 4
Source File: MessageProviderWithAddressingPolicy.java From cxf with Apache License 2.0 | 6 votes |
public Source invoke(Source request) { TransformerFactory transformerFactory = TransformerFactory.newInstance(); try { transformerFactory.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true); /* tfactory.setAttribute("indent-number", "2"); */ Transformer serializer = transformerFactory.newTransformer(); // Setup indenting to "pretty print" serializer.setOutputProperty(OutputKeys.INDENT, "yes"); serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); StringWriter swriter = new StringWriter(); serializer.transform(request, new StreamResult(swriter)); swriter.flush(); LOG.info("Provider received a request\n" + swriter.toString()); } catch (TransformerException e) { e.printStackTrace(); } return null; }
Example 5
Source File: AbstractAlchemyExtractor.java From wandora with GNU General Public License v3.0 | 6 votes |
protected String getStringFromDocument(Document doc) { try { DOMSource domSource = new DOMSource(doc); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.transform(domSource, result); return writer.toString(); } catch(TransformerException ex) { ex.printStackTrace(); return null; } }
Example 6
Source File: Utils.java From iaf with Apache License 2.0 | 6 votes |
public static String source2String(Source source) { try { StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.transform(source, result); writer.flush(); return writer.toString(); } catch(TransformerException ex) { ex.printStackTrace(); return null; } }
Example 7
Source File: AbstractBingExtractor.java From wandora with GNU General Public License v3.0 | 6 votes |
protected String getStringFromDocument(Document doc) { try { DOMSource domSource = new DOMSource(doc); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.transform(domSource, result); return writer.toString(); } catch(TransformerException ex) { ex.printStackTrace(); return null; } }
Example 8
Source File: AbstractTagtheExtractor.java From wandora with GNU General Public License v3.0 | 6 votes |
protected String getStringFromDocument(Document doc) { try { DOMSource domSource = new DOMSource(doc); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.transform(domSource, result); return writer.toString(); } catch(TransformerException ex) { ex.printStackTrace(); return null; } }
Example 9
Source File: AbstractZemantaExtractor.java From wandora with GNU General Public License v3.0 | 6 votes |
protected String getStringFromDocument(Document doc) { try { DOMSource domSource = new DOMSource(doc); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.transform(domSource, result); return writer.toString(); } catch(TransformerException ex) { ex.printStackTrace(); return null; } }
Example 10
Source File: XMLFormatter.java From Siamese with GNU General Public License v3.0 | 6 votes |
public String getXMLAsString() { this.dom.appendChild(this.root); try { TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); StringWriter writer = new StringWriter(); transformer.transform(new DOMSource(dom), new StreamResult(writer)); return writer.toString(); } catch (TransformerException e) { e.printStackTrace(); return null; } }
Example 11
Source File: AbstractBossExtractor.java From wandora with GNU General Public License v3.0 | 6 votes |
protected String getStringFromDocument(Document doc) { try { DOMSource domSource = new DOMSource(doc); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.transform(domSource, result); return writer.toString(); } catch(TransformerException ex) { ex.printStackTrace(); return null; } }
Example 12
Source File: BaseRequestHandler.java From butterfly with Apache License 2.0 | 6 votes |
/** * Sends the response to the client. * @param request The original request. * @param response The response object we can use to send the data. * @param respBody The XML document of the response. * @return A response object for Spark */ protected Object sendResponse(final Request request, final Response response, final BaseXMLBuilder respBody) { // get the bytes of the XML document final ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { final TransformerFactory transformerFactory = TransformerFactory.newInstance(); final Transformer transformer = transformerFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); final DOMSource source = new DOMSource(respBody.getDocument()); final StreamResult result = new StreamResult(bos); transformer.transform(source, result); } catch (TransformerException e) { e.printStackTrace(); return 500; } byte[] respBytes = bos.toByteArray(); return this.sendBytesToClient(respBytes, request, response); }
Example 13
Source File: XmlUtils.java From jolie with GNU Lesser General Public License v2.1 | 5 votes |
public String transform( Value request ) throws FaultException { try { StreamSource source = new StreamSource( new StringReader( request.getFirstChild( "source" ).strValue() ) ); Transformer t = transformerFactory .newTransformer( new StreamSource( new StringReader( request.getFirstChild( "xslt" ).strValue() ) ) ); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult( writer ); t.transform( source, result ); return writer.toString(); } catch( TransformerException e ) { e.printStackTrace(); throw new FaultException( e ); } }
Example 14
Source File: XmlXpathDeserializer.java From ingestion with Apache License 2.0 | 5 votes |
public String nodeToString(Node node) { StringWriter writer = new StringWriter(); TransformerFactory tfactory = TransformerFactory.newInstance(); Transformer xform; try { xform = tfactory.newTransformer(); xform.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); Source src = new DOMSource(node); Result result = new StreamResult(writer); xform.transform(src, result); } catch (TransformerException e) { e.printStackTrace(); } return writer.toString(); }
Example 15
Source File: XMLUtils.java From mappwidget with Apache License 2.0 | 5 votes |
public static void saveDoc(Document doc, String fileName) { try { TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(new File(fileName)); transformer.transform(source, result); } catch (TransformerException e) { e.printStackTrace(); } }
Example 16
Source File: XMLUtil.java From SEAL with Apache License 2.0 | 5 votes |
static public Document cloneDocument(Document document) { if (document == null) return null; Document result = newDocument(); try { identityTransformer.transform(new DOMSource( document), new DOMResult( result)); } catch (TransformerException e) { e.printStackTrace(); } return result; }
Example 17
Source File: BaseXMLTestWriter.java From ECTester with MIT License | 5 votes |
@Override public void end() { try { DOMSource domSource = new DOMSource(doc); StreamResult result = new StreamResult(output); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); transformer.transform(domSource, result); } catch (TransformerException e) { e.printStackTrace(); } }
Example 18
Source File: XmlUtils.java From TranskribusCore with GNU General Public License v3.0 | 5 votes |
public static Node selectNode(Element documentElement, String xpath) { Node res = null; try { Node result = XPathAPI.selectSingleNode(documentElement, xpath); if (result!=null) res = result; } catch (TransformerException e) { e.printStackTrace(); } return res; }
Example 19
Source File: NewDataNotifyAccessSessionMySQL.java From Cynthia with GNU General Public License v2.0 | 5 votes |
public void run(){ while (true) { UUID newfilterId = null; int filterCount = 0; synchronized (filterIdList) { if (filterIdList.size() == 0) { break; } newfilterId = filterIdList.remove(0); } if (newfilterId != null) { try { filterCount = getFilterCount(newfilterId, username); } catch (TransformerException e) { e.printStackTrace(); } } synchronized (filterIdList) { filterDataCountMap.put(newfilterId, filterCount); } } countDown.countDown(); }
Example 20
Source File: ModifyXMLFile.java From maven-framework-project with MIT License | 4 votes |
public static void main(String argv[]) { try { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.parse(ClassLoader.getSystemResourceAsStream("file.xml")); // Get the root element //Node company = doc.getFirstChild(); // Get the staff element , it may not working if tag has spaces, or // whatever weird characters in front...it's better to use // getElementsByTagName() to get it directly. // Node staff = company.getFirstChild(); // Get the staff element by tag name directly Node staff = doc.getElementsByTagName("staff").item(0); // update staff attribute NamedNodeMap attr = staff.getAttributes(); Node nodeAttr = attr.getNamedItem("id"); nodeAttr.setTextContent("2"); // append a new node to staff Element age = doc.createElement("age"); age.appendChild(doc.createTextNode("28")); staff.appendChild(age); // loop the staff child node NodeList list = staff.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); // get the salary element, and update the value if ("salary".equals(node.getNodeName())) { node.setTextContent("2000000"); } //remove firstname if ("firstname".equals(node.getNodeName())) { staff.removeChild(node); } } // write the content into xml file TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(new File("target/file.xml")); transformer.transform(source, result); System.out.println("Done"); } catch (ParserConfigurationException pce) { pce.printStackTrace(); } catch (TransformerException tfe) { tfe.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } catch (SAXException sae) { sae.printStackTrace(); } }