Package javax.xml.transform.dom

Examples of javax.xml.transform.dom.DOMSource


        try {
            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 {
View Full Code Here


  
   private String getDocumentAsString(Document doc){
     
      try
      {
         final Source source = new DOMSource(doc);
         final StringWriter writer = new StringWriter();
         final StreamResult result = new StreamResult(writer);
         TransformerFactory.newInstance().newTransformer().transform(source, result);
         return writer.toString();
      }
View Full Code Here

        try {
            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 {
View Full Code Here

      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());

      conn.close();
View Full Code Here

    */
   private void outputXmlFile(Document doc, File file)
      throws Exception
   {
      // Prepare the DOM document for writing
      Source source = new DOMSource(doc);   
     
      // Use an OutputStream rather than a File
      OutputStream out = new FileOutputStream(file);
     
      // Prepare the output
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

        }
      } else if (mode.equals("saxon")) {
        saxonSerializer.transform(saxonDoc, new StreamResult(out));
        data = out.toByteArray();
      } else if (mode.equals("dom")) {
        domSerializer.transform(new DOMSource(domDoc), new StreamResult(out));
        data = out.toByteArray();
      } else if (mode.startsWith("fi")) {
        if (mode.indexOf("stax") >= 0) {
//          data = serializeWithStax(doc, staxOutputFactory);
          data = serializeWithFastInfosetStax(doc, (XMLStreamWriter)fiSerializer, fiMethod, out);
View Full Code Here

  public final void print(Document document) throws Exception
  {
    TransformerFactory factory = TransformerFactory.newInstance();
    javax.xml.transform.Transformer serializer = factory.newTransformer();
    serializer.transform(new DOMSource(document), new StreamResult(System.out));
    System.out.println();
  }
View Full Code Here

                    }
                  } else if (mode.equals("saxon")) {
                    saxonSerializer.transform(saxonDoc, new StreamResult(out));
                    data = out.toByteArray();
                  } else if (mode.equals("dom")) {
                    domSerializer.transform(new DOMSource(domDoc), new StreamResult(out));
                    data = out.toByteArray();
                  } else if (mode.startsWith("fi")) {
                    if (mode.indexOf("stax") >= 0) {
//                      data = serializeWithStax(doc, staxOutputFactory);
                      data = serializeWithFastInfosetStax(doc, (XMLStreamWriter)fiSerializer, fiMethod, out);
View Full Code Here

    DOMResult result = new DOMResult();
    serializer.setResult(result);

    processor.setContentHandler(new WhitespaceFilter(serializer, new ConsoleLog(ConsoleLog.INFO)));

    streamer.transform(new DOMSource(node), new SAXResult(processor));

    return (Document)result.getNode();
  }
View Full Code Here

TOP

Related Classes of javax.xml.transform.dom.DOMSource

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.