Coverage Report - org.apache.ws.scout.util.XMLUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
XMLUtils
0%
0/16
N/A
3
 
 1  
 package org.apache.ws.scout.util;
 2  
 
 3  
 import java.io.StringWriter;
 4  
 
 5  
 import javax.xml.transform.Source;
 6  
 import javax.xml.transform.Transformer;
 7  
 import javax.xml.transform.TransformerConfigurationException;
 8  
 import javax.xml.transform.TransformerException;
 9  
 import javax.xml.transform.TransformerFactory;
 10  
 import javax.xml.transform.dom.DOMSource;
 11  
 import javax.xml.transform.stream.StreamResult;
 12  
 
 13  
 import org.apache.commons.logging.Log;
 14  
 import org.apache.commons.logging.LogFactory;
 15  
 import org.w3c.dom.Node;
 16  
 
 17  
 /**
 18  
  * Utilies for covertion between w3c formats and XML.
 19  
  * @author Kurt Stam (kurt.stam@jboss.com)
 20  
  */
 21  0
 public class XMLUtils {
 22  0
         private static Log log = LogFactory.getLog(XMLUtils.class);
 23  
         
 24  
         /**
 25  
          * Convert a org.w3c.dom.Node into an XML representation.
 26  
          * @param node - containing an xml tree.
 27  
          * @return - String containing the XML.
 28  
          */
 29  
         public static String convertNodeToXMLString(Node node)
 30  
           {
 31  0
                   String xml=null;
 32  
                   try {
 33  0
                       Source source = new DOMSource(node);
 34  0
                       StringWriter stringWriter = new StringWriter();
 35  0
                       javax.xml.transform.Result result = new StreamResult(stringWriter);
 36  0
                       TransformerFactory factory = TransformerFactory.newInstance();
 37  0
                       Transformer transformer = factory.newTransformer();
 38  0
                       transformer.transform(source, result);
 39  0
                       xml=stringWriter.getBuffer().toString();
 40  0
                   } catch (TransformerConfigurationException e) {
 41  0
                       log.error("Could not obtain the XML. ", e);
 42  0
                   } catch (TransformerException e) {
 43  0
                           log.error("Could not obtain the XML. ",e);
 44  0
                   }
 45  0
                   return xml;
 46  
           }
 47  
 }