Package javax.xml.transform.stream

Examples of javax.xml.transform.stream.StreamResult


        // PS: DOES NOT SUPPORT EXPORTING ONLY A SET OF ENTRIES

        try {
            DOMSource source = new DOMSource(md.getDOMrepresentation());
            StreamResult result = new StreamResult(ps);
            Transformer trans = TransformerFactory.newInstance().newTransformer();
            trans.setOutputProperty(OutputKeys.INDENT, "yes");
            trans.transform(source, result);
        }
        catch (Exception e) {
View Full Code Here


      // Get a parsable representation of this elements content
      DOMSource source = new DOMSource(content);
      TransformerFactory tFactory = TransformerFactory.newInstance();
      Transformer transformer = tFactory.newTransformer();
      StringWriter sw = new StringWriter();
      StreamResult result = new StreamResult(sw);
      transformer.transform(source, result);
      sw.close();
      return sw.getBuffer();
   }
View Full Code Here

            Writer ps = new OutputStreamWriter(new FileOutputStream(tmpFile), "UTF8");
            try {

                //            Writer ps = new FileWriter(tmpFile);
                DOMSource source = new DOMSource(od.getDOMrepresentation());
                StreamResult result = new StreamResult(ps);
                Transformer trans = TransformerFactory.newInstance().newTransformer();
                trans.setOutputProperty(OutputKeys.INDENT, "yes");
                trans.transform(source, result);
            } finally {
                ps.close();
View Full Code Here

            Writer ps = new OutputStreamWriter(new FileOutputStream(tmpFile), "UTF8");
            try {

                //            Writer ps = new FileWriter(tmpFile);
                DOMSource source = new DOMSource(od.getDOMrepresentation());
                StreamResult result = new StreamResult(ps);
                Transformer trans = TransformerFactory.newInstance().newTransformer();
                trans.setOutputProperty(OutputKeys.INDENT, "yes");
                trans.transform(source, result);
            } finally {
                ps.close();
View Full Code Here

     
      TransformerFactory transformerFactory = TransformerFactory.newInstance();
      Transformer transformer = transformerFactory.newTransformer();
     
      StringWriter xmlout = new StringWriter();
      StreamResult result = new StreamResult(xmlout);

      transformer.transform(new DOMSource(doc.getFirstChild()), result);
     
      ManagedConnectionPoolStatistics rawStatistics = (ManagedConnectionPoolStatistics)getServer().invoke(POOL_NAME, RAW_STATS_METHOD, new Object[0], new String[0]);
      JBossXmlSubPoolStatisticFormatter xmlFormatter = new JBossXmlSubPoolStatisticFormatter();
      String xml2 = (String)xmlFormatter.formatSubPoolStatistics(rawStatistics);
     
      Document doc2 = builder.parse(new InputSource(new StringReader(xml2)));


      StringWriter xmlout2 = new StringWriter();
      StreamResult result2 = new StreamResult(xmlout2);

      transformer.transform(new DOMSource(doc2.getFirstChild()), result2);
     
      //only compare xml content, ignore standalone="no"
      assertEquals(xmlout.toString(), xmlout2.toString());
View Full Code Here

     
      // Use an OutputStream rather than a File
      OutputStream out = new FileOutputStream(file);
     
      // Prepare the output
      Result result = new StreamResult(out);
     
      // Write the DOM document to the file
      Transformer xformer = TransformerFactory.newInstance().newTransformer();
     
      // Enable indentation
View Full Code Here

        StreamSource source = new StreamSource(xsl);
        Templates templates = tf.newTemplates(source);

        Transformer trf = templates.newTransformer();

        trf.transform(new StreamSource(input), new StreamResult(output));
    }
View Full Code Here

                InputStream dataStream = new FileInputStream(dataFile);
                InputStream styleStream = new FileInputStream(styleFile);
                // create XSLT Source and Result objects
                Source data = new StreamSource(dataStream);
                Source style = new StreamSource(styleStream);
                Result output = new StreamResult(System.out);
                // create Transformer and perform the tranfomation
                Transformer xslt =  TransformerFactory.newInstance().newTransformer(style);
                xslt.transform(data, output);
            }
            catch (Exception e) {
View Full Code Here

public class XMLTransformer {
 
  public static void transformToWriter(Transformer transformer, Document doc, Writer writer, String encoding) throws TransformerException{
    transformer.setOutputProperty(OutputKeys.ENCODING,encoding);
    transformer.transform(new DOMSource(doc), new StreamResult(writer));
 
View Full Code Here

    private Options createOptions() throws ExportException {
        JDKFontLocator locator = new JDKFontLocator();
        FontRecord[] fontRecords = locator.getFontRecords();
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        StreamResult output = new StreamResult(outputStream);
        try {
            TransformerHandler handler = getTransformerFactory()
                    .newTransformerHandler();
            handler.setResult(output);
            // just for nifty debugging :)
View Full Code Here

TOP

Related Classes of javax.xml.transform.stream.StreamResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.