List of usage examples for javax.xml.transform.stream StreamResult StreamResult
public StreamResult(File f)
From source file:Main.java
public static void main(String args[]) throws Exception { StreamSource source = new StreamSource(args[0]); StreamSource stylesource = new StreamSource(args[1]); TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(stylesource); StreamResult result = new StreamResult(System.out); transformer.transform(source, result); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Document doc = null;//from w w w .j av a 2 s .c o m String filename = "name.xml"; Source source = new DOMSource(doc); File file = new File(filename); Result result = new StreamResult(file); Transformer xformer = TransformerFactory.newInstance().newTransformer(); xformer.transform(source, result); }
From source file:Main.java
public static void main(String[] args) throws Exception { Source xslSource = new StreamSource(Main.class.getResourceAsStream("test.xsl")); Source xmlSource = new StreamSource(Main.class.getResourceAsStream("test.xml")); Transformer transf = TransformerFactory.newInstance().newTransformer(xslSource); StreamResult transformedXml = new StreamResult(System.out); transf.transform(xmlSource, transformedXml); }
From source file:Main.java
public static void main(String[] args) throws Exception { StreamSource xmlFile = new StreamSource(new File(args[0])); StreamSource xsltFile = new StreamSource(new File(args[1])); TransformerFactory xsltFactory = TransformerFactory.newInstance(); Transformer transformer = xsltFactory.newTransformer(xsltFile); StreamResult resultStream = new StreamResult(System.out); transformer.transform(xmlFile, resultStream); }
From source file:Main.java
public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(Main.class); jc.generateSchema(new SchemaOutputResolver() { @Override/* w ww. j ava2 s. c o m*/ public Result createOutput(String namespaceURI, String suggestedFileName) throws IOException { System.out.println(suggestedFileName); return new StreamResult(suggestedFileName); } }); }
From source file:JAXPTransform.java
public static void main(String args[]) throws TransformerConfigurationException, TransformerException, FileNotFoundException { TransformerFactory factory = TransformerFactory.newInstance(); StreamSource stylesheet = new StreamSource(args[1]); StreamSource xmlDoc = new StreamSource(args[0]); StreamResult result = new StreamResult(new FileOutputStream(args[2])); Transformer transFormer = factory.newTransformer(stylesheet); transFormer.transform(xmlDoc, result); }
From source file:PrintDOM.java
public static void main(String[] args) throws Exception { DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document document = parser.parse(new InputSource("zooinventory.xml")); Transformer transformer = TransformerFactory.newInstance().newTransformer(); Source source = new DOMSource(document); Result output = new StreamResult(System.out); transformer.transform(source, output); }
From source file:JAXPTransformNode.java
public static void main(String args[]) throws Exception, TransformerException, FileNotFoundException { TransformerFactory factory = TransformerFactory.newInstance(); DOMSource stylesheet = new DOMSource(buildDoc(args[1])); StreamSource xmlDoc = new StreamSource(args[0]); StreamResult result = new StreamResult(new FileOutputStream(args[2])); Transformer transFormer = factory.newTransformer(stylesheet); transFormer.transform(xmlDoc, result); }
From source file:Main.java
public static void main(String[] args) throws Exception { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = docBuilderFactory.newDocumentBuilder(); Document node = documentBuilder.parse(new FileInputStream("data.xml")); cleanEmptyTextNodes(node);//from ww w.j a v a 2s . c om StreamResult result = new StreamResult(new StringWriter()); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", Integer.toString(4)); transformer.transform(new DOMSource(node), result); System.out.println(result.getWriter().toString()); }
From source file:MainClass.java
public static void main(String argv[]) throws Exception { Properties props = System.getProperties(); props.put("javax.xml.transform.TransformerFactory", "org.apache.xalan.xsltc.trax.TransformerFactoryImpl"); System.setProperties(props);/*from ww w . j ava 2s .c o m*/ TransformerFactory tFactory = TransformerFactory.newInstance(); Templates translet = tFactory.newTemplates(new StreamSource("OrderProcessing.xslt")); Transformer transformer = translet.newTransformer(); transformer.transform(new StreamSource("CustomerOrders.xml"), new StreamResult(new FileOutputStream("SortedOrders.html"))); transformer.transform(new StreamSource("CustomerOrders1.xml"), new StreamResult(new FileOutputStream("SortedOrders1.html"))); }