You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2013/07/04 01:54:48 UTC

svn commit: r1499608 - in /cxf/trunk: api/src/main/java/org/apache/cxf/helpers/ api/src/main/java/org/apache/cxf/interceptor/ api/src/main/java/org/apache/cxf/staxutils/ api/src/test/java/org/apache/cxf/common/xmlschema/ rt/databinding/aegis/src/main/j...

Author: dkulp
Date: Wed Jul  3 23:54:47 2013
New Revision: 1499608

URL: http://svn.apache.org/r1499608
Log:
Start moving ALL the XML parsing and printing to using Stax.  Should help performance and security.

Added:
    cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/PrettyPrintXMLStreamWriter.java
      - copied, changed from r1499490, cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl/PrettyPrintXMLStreamWriter.java
Removed:
    cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl/PrettyPrintXMLStreamWriter.java
Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/helpers/DOMUtils.java
    cxf/trunk/api/src/main/java/org/apache/cxf/helpers/XMLUtils.java
    cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
    cxf/trunk/api/src/test/java/org/apache/cxf/common/xmlschema/ImportRepairTest.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/xml/XMLSource.java
    cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JInOutTest.java
    cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/SamlTokenTest.java
    cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java
    cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl11/SchemaSerializer.java
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AttachmentStreamSourceXMLProvider.java
    cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/SchemaWriterImpl.java
    cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLCorbaWriterImpl.java
    cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/AegisTest.java
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/HandlerConfigGenerator.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/helpers/DOMUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/helpers/DOMUtils.java?rev=1499608&r1=1499607&r2=1499608&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/helpers/DOMUtils.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/helpers/DOMUtils.java Wed Jul  3 23:54:47 2013
@@ -25,11 +25,8 @@ import java.io.OutputStream;
 import java.io.Reader;
 import java.io.StringReader;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Map;
-import java.util.WeakHashMap;
 
 import javax.xml.XMLConstants;
 import javax.xml.namespace.QName;
@@ -64,28 +61,9 @@ import org.apache.cxf.common.util.String
 public final class DOMUtils {
     private static final String XMLNAMESPACE = "xmlns";
 
-    private static final Map<ClassLoader, DocumentBuilder> DOCUMENT_BUILDERS = Collections
-        .synchronizedMap(new WeakHashMap<ClassLoader, DocumentBuilder>());
-
     private DOMUtils() {
     }
 
-    private static DocumentBuilder getBuilder() throws ParserConfigurationException {
-        ClassLoader loader = Thread.currentThread().getContextClassLoader();
-        if (loader == null) {
-            loader = DOMUtils.class.getClassLoader();
-        }
-        if (loader == null) {
-            return XMLUtils.getParser();
-        }
-        DocumentBuilder builder = DOCUMENT_BUILDERS.get(loader);
-        if (builder == null) {
-            builder = XMLUtils.getParser();
-            DOCUMENT_BUILDERS.put(loader, builder);
-        }
-        return builder;
-    }
-
     /**
      * This function is much like getAttribute, but returns null, not "", for a nonexistent attribute.
      * 
@@ -517,17 +495,9 @@ public final class DOMUtils {
         t.transform(new DOMSource(n), new StreamResult(os));
     }
 
-    public static DocumentBuilder createDocumentBuilder() {
-        try {
-            return getBuilder();
-        } catch (ParserConfigurationException e) {
-            throw new RuntimeException("Couldn't find a DOM parser.", e);
-        }
-    }
-
     public static Document createDocument() {
         try {
-            return getBuilder().newDocument();
+            return XMLUtils.newDocument();
         } catch (ParserConfigurationException e) {
             throw new RuntimeException("Couldn't find a DOM parser.", e);
         }

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/helpers/XMLUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/helpers/XMLUtils.java?rev=1499608&r1=1499607&r2=1499608&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/helpers/XMLUtils.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/helpers/XMLUtils.java Wed Jul  3 23:54:47 2013
@@ -20,11 +20,12 @@
 package org.apache.cxf.helpers;
 
 import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.StringReader;
 import java.io.StringWriter;
 import java.io.Writer;
 import java.util.Collections;
@@ -32,7 +33,6 @@ import java.util.HashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 import java.util.Set;
 import java.util.StringTokenizer;
 import java.util.WeakHashMap;
@@ -45,43 +45,34 @@ import javax.xml.namespace.QName;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
 
 import org.w3c.dom.Attr;
-import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.Text;
-import org.w3c.dom.bootstrap.DOMImplementationRegistry;
-import org.w3c.dom.ls.DOMImplementationLS;
-import org.w3c.dom.ls.LSOutput;
-import org.w3c.dom.ls.LSSerializer;
+
 import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.staxutils.PrettyPrintXMLStreamWriter;
+import org.apache.cxf.staxutils.StaxUtils;
 
 public final class XMLUtils {
 
     private static final Logger LOG = LogUtils.getL7dLogger(XMLUtils.class);
     
-    private static final Map<ClassLoader, DocumentBuilderFactory> DOCUMENT_BUILDER_FACTORIES
-        = Collections.synchronizedMap(new WeakHashMap<ClassLoader, DocumentBuilderFactory>());
+    private static final Map<ClassLoader, DocumentBuilder> DOCUMENT_BUILDERS
+        = Collections.synchronizedMap(new WeakHashMap<ClassLoader, DocumentBuilder>());
     
-    private static final Map<ClassLoader, TransformerFactory> TRANSFORMER_FACTORIES
-        = Collections.synchronizedMap(new WeakHashMap<ClassLoader, TransformerFactory>());
-
     private static final Pattern XML_ESCAPE_CHARS = Pattern.compile("[\"'&<>]");
     private static final Map<String, String> XML_ENCODING_TABLE;
     static {
@@ -96,113 +87,87 @@ public final class XMLUtils {
     private XMLUtils() {
     }
 
-    private static TransformerFactory getTransformerFactory() {
+    private static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException {
         ClassLoader loader = Thread.currentThread().getContextClassLoader();
         if (loader == null) {
             loader = XMLUtils.class.getClassLoader();
         }
         if (loader == null) {
-            return TransformerFactory.newInstance();
+            return DocumentBuilderFactory.newInstance().newDocumentBuilder();
         }
-        TransformerFactory factory = TRANSFORMER_FACTORIES.get(loader);
+        DocumentBuilder factory = DOCUMENT_BUILDERS.get(loader);
         if (factory == null) {
-            factory = TransformerFactory.newInstance();
-            TRANSFORMER_FACTORIES.put(loader, factory);
+            DocumentBuilderFactory f2 = DocumentBuilderFactory.newInstance();
+            f2.setNamespaceAware(true);
+            factory = f2.newDocumentBuilder();
+            DOCUMENT_BUILDERS.put(loader, factory);
         }
         return factory;
     }
-    private static DocumentBuilderFactory getDocumentBuilderFactory() {
-        ClassLoader loader = Thread.currentThread().getContextClassLoader();
-        if (loader == null) {
-            loader = XMLUtils.class.getClassLoader();
-        }
-        if (loader == null) {
-            return DocumentBuilderFactory.newInstance();
-        }
-        DocumentBuilderFactory factory = DOCUMENT_BUILDER_FACTORIES.get(loader);
-        if (factory == null) {
-            factory = DocumentBuilderFactory.newInstance();
-            factory.setNamespaceAware(true);
-            DOCUMENT_BUILDER_FACTORIES.put(loader, factory);
-        }
-        return factory;
-    }
-    public static Transformer newTransformer() throws TransformerConfigurationException {
-        return getTransformerFactory().newTransformer();
-    }
-    public static Transformer newTransformer(int indent) throws TransformerConfigurationException {
-        if (indent > 0) {
-            TransformerFactory f = TransformerFactory.newInstance();
-            try {
-                //sun way of setting indent
-                f.setAttribute("indent-number", Integer.toString(indent));
-            } catch (Throwable t) {
-                //ignore
-            }
-            return f.newTransformer();
-        }
-        return getTransformerFactory().newTransformer();
-    }
 
-    public static DocumentBuilder getParser() throws ParserConfigurationException {
-        return getDocumentBuilderFactory().newDocumentBuilder();
-    }
 
-    public static Document parse(InputSource is) throws ParserConfigurationException, SAXException,
-        IOException {
-        return getParser().parse(is);
+    public static Document parse(InputSource is) throws XMLStreamException {
+        return StaxUtils.read(is);
     }
 
-    public static Document parse(File is) throws ParserConfigurationException, SAXException,
-        IOException {
-        return getParser().parse(is);
+    public static Document parse(File is) throws XMLStreamException, IOException {
+        InputStream fin = new FileInputStream(is);
+        try {
+            return StaxUtils.read(fin);
+        } finally {
+            fin.close();
+        }
     }
 
-    public static Document parse(InputStream in) throws ParserConfigurationException, SAXException,
-        IOException {
+    public static Document parse(InputStream in) throws XMLStreamException {
         if (in == null && LOG.isLoggable(Level.FINE)) {
             LOG.fine("XMLUtils trying to parse a null inputstream");
         }
-        return getParser().parse(in);
+        return StaxUtils.read(in);
     }
 
-    public static Document parse(String in) throws ParserConfigurationException, SAXException, IOException {
-        return parse(in.getBytes());
+    public static Document parse(String in) throws XMLStreamException {
+        XMLStreamReader reader = StaxUtils.createXMLStreamReader(new StringReader(in));
+        try {
+            return StaxUtils.read(reader);
+        } finally {
+            reader.close();
+        }
     }
 
-    public static Document parse(byte[] in) throws ParserConfigurationException, SAXException, IOException {
+    public static Document parse(byte[] in) throws XMLStreamException {
         if (in == null) {
             if (LOG.isLoggable(Level.FINE)) {
                 LOG.fine("XMLUtils trying to parse a null bytes");
             }
             return null;
         }
-        return getParser().parse(new ByteArrayInputStream(in));
+        return StaxUtils.read(new ByteArrayInputStream(in));
     }
 
     public static Document newDocument() throws ParserConfigurationException {
-        return getParser().newDocument();
+        return getDocumentBuilder().newDocument();
     }
 
-    public static void writeTo(Node node, OutputStream os) {
+    public static void writeTo(Node node, OutputStream os) throws XMLStreamException {
         writeTo(new DOMSource(node), os);
     }
-    public static void writeTo(Node node, OutputStream os, int indent) {
+    public static void writeTo(Node node, OutputStream os, int indent) throws XMLStreamException {
         writeTo(new DOMSource(node), os, indent);
     }
-    public static void writeTo(Source src, OutputStream os) {
+    public static void writeTo(Source src, OutputStream os) throws XMLStreamException {
         writeTo(src, os, -1);
     }
-    public static void writeTo(Node node, Writer os) {
+    public static void writeTo(Node node, Writer os) throws XMLStreamException {
         writeTo(new DOMSource(node), os);
     }
-    public static void writeTo(Node node, Writer os, int indent) {
+    public static void writeTo(Node node, Writer os, int indent) throws XMLStreamException {
         writeTo(new DOMSource(node), os, indent);
     }
-    public static void writeTo(Source src, Writer os) {
+    public static void writeTo(Source src, Writer os) throws XMLStreamException {
         writeTo(src, os, -1);
     }
-    public static void writeTo(Source src, OutputStream os, int indent) {
+    public static void writeTo(Source src, OutputStream os, int indent) throws XMLStreamException {
         String enc = null;
         if (src instanceof DOMSource
             && ((DOMSource)src).getNode() instanceof Document) {
@@ -212,9 +177,9 @@ public final class XMLUtils {
                 //ignore - not DOM level 3
             }
         }
-        writeTo(src, os, indent, enc, "no");
+        writeTo(src, os, indent, enc, false);
     }
-    public static void writeTo(Source src, Writer os, int indent) {
+    public static void writeTo(Source src, Writer os, int indent) throws XMLStreamException {
         String enc = null;
         if (src instanceof DOMSource
             && ((DOMSource)src).getNode() instanceof Document) {
@@ -224,84 +189,79 @@ public final class XMLUtils {
                 //ignore - not DOM level 3
             }
         }
-        writeTo(src, os, indent, enc, "no");
+        writeTo(src, os, indent, enc, false);
     }
     public static void writeTo(Source src,
                                OutputStream os,
                                int indent,
                                String charset,
-                               String omitXmlDecl) {
-        Transformer it;
-        try {
-            if (StringUtils.isEmpty(charset)) {
-                charset = "utf-8"; 
-            }
-
-            it = newTransformer(indent);
-            it.setOutputProperty(OutputKeys.METHOD, "xml");
-            if (indent > -1) {
-                it.setOutputProperty(OutputKeys.INDENT, "yes");
-                it.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
-                                     Integer.toString(indent));
-            }
-            it.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, omitXmlDecl);
-            it.setOutputProperty(OutputKeys.ENCODING, charset);
-            it.transform(src, new StreamResult(os));
-        } catch (TransformerException e) {
-            throw new RuntimeException("Failed to configure TRaX", e);
+                               boolean omitXmlDecl) throws XMLStreamException {
+        
+        if (StringUtils.isEmpty(charset)) {
+            charset = "utf-8"; 
+        }
+        XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(os, charset);
+        if (indent > 0) {
+            writer = new PrettyPrintXMLStreamWriter(writer, 0, indent);
+        }
+        if (!omitXmlDecl) {
+            writer.writeStartDocument(charset, "1.0");
         }
+        StaxUtils.copy(src, writer);
+        if (!omitXmlDecl) {
+            writer.writeEndDocument();
+        }
+        writer.close();
     }
     public static void writeTo(Source src,
                                Writer os,
                                int indent,
                                String charset,
-                               String omitXmlDecl) {
-        Transformer it;
-        try {
-            if (StringUtils.isEmpty(charset)) {
-                charset = "utf-8"; 
-            }
-
-            it = newTransformer(indent);
-            it.setOutputProperty(OutputKeys.METHOD, "xml");
-            if (indent > -1) {
-                it.setOutputProperty(OutputKeys.INDENT, "yes");
-                it.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
-                                     Integer.toString(indent));
-            }
-            it.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, omitXmlDecl);
-            it.setOutputProperty(OutputKeys.ENCODING, charset);
-            it.transform(src, new StreamResult(os));
-        } catch (TransformerException e) {
-            throw new RuntimeException("Failed to configure TRaX", e);
+                               boolean omitXmlDecl) throws XMLStreamException {
+        if (StringUtils.isEmpty(charset)) {
+            charset = "utf-8"; 
         }
+        XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(os);
+        if (indent > 0) {
+            writer = new PrettyPrintXMLStreamWriter(writer, 0, indent);
+        }
+        if (!omitXmlDecl) {
+            writer.writeStartDocument(charset, "1.0");
+        }
+        StaxUtils.copy(src, writer);
+        if (!omitXmlDecl) {
+            writer.writeEndDocument();
+        }
+        writer.close();
     }
+    
+    
     public static String toString(Source source) throws TransformerException, IOException {
-        return toString(source, null);
-    }
-
-    public static String toString(Source source, Properties props) throws TransformerException, IOException {
-        StringWriter bos = new StringWriter();
-        StreamResult sr = new StreamResult(bos);
-        Transformer trans = newTransformer();
-        if (props == null) {
-            props = new Properties();
-            props.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
-        }
-        trans.setOutputProperties(props);
-        trans.transform(source, sr);
-        bos.close();
-        return bos.toString();
+        StringWriter out = new StringWriter();
+        try {
+            writeTo(source, out, 0, "utf-8", true);
+        } catch (XMLStreamException ex) {
+            throw new RuntimeException(ex);
+        }
+        return out.toString();
     }
 
     public static String toString(Node node, int indent) {
-        ByteArrayOutputStream out = new ByteArrayOutputStream();
-        writeTo(node, out, indent);
+        StringWriter out = new StringWriter();
+        try {
+            writeTo(node, out, indent);
+        } catch (XMLStreamException ex) {
+            throw new RuntimeException(ex);
+        }
         return out.toString();
     }
     public static String toString(Node node) {
-        ByteArrayOutputStream out = new ByteArrayOutputStream();
-        writeTo(node, out);
+        StringWriter out = new StringWriter();
+        try {
+            writeTo(node, out);
+        } catch (XMLStreamException ex) {
+            throw new RuntimeException(ex);
+        }
         return out.toString();
     }
 
@@ -364,18 +324,8 @@ public final class XMLUtils {
         return new QName(namespceURI, localName);
     }
 
-    public static void generateXMLFile(Element element, Writer writer) {
-        try {
-            Transformer it = newTransformer();
-
-            it.setOutputProperty(OutputKeys.METHOD, "xml");
-            it.setOutputProperty(OutputKeys.INDENT, "yes");
-            it.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
-            it.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
-            it.transform(new DOMSource(element), new StreamResult(writer));
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
+    public static void generateXMLFile(Element element, Writer writer) throws XMLStreamException {
+        writeTo(new DOMSource(element), writer, 2, "UTF-8", false);
     }
 
     public static Element createElementNS(Node node, QName name) {
@@ -407,29 +357,11 @@ public final class XMLUtils {
     }
 
     public static InputStream getInputStream(Document doc) throws Exception {
-        DOMImplementationLS impl = null;
-        DOMImplementation docImpl = doc.getImplementation();
-        // Try to get the DOMImplementation from doc first before
-        // defaulting to the sun implementation.
-        if (docImpl != null && docImpl.hasFeature("LS", "3.0")) {
-            impl = (DOMImplementationLS)docImpl.getFeature("LS", "3.0");
-        } else {
-            DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
-            impl = (DOMImplementationLS)registry.getDOMImplementation("LS");
-            if (impl == null) {
-                System.setProperty(DOMImplementationRegistry.PROPERTY,
-                                   "com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");
-                registry = DOMImplementationRegistry.newInstance();
-                impl = (DOMImplementationLS)registry.getDOMImplementation("LS");
-            }
-        }
-        LSOutput output = impl.createLSOutput();
-        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-        output.setByteStream(byteArrayOutputStream);
-        LSSerializer writer = impl.createLSSerializer();
-        writer.write(doc, output);
-        byte[] buf = byteArrayOutputStream.toByteArray();
-        return new ByteArrayInputStream(buf);
+        LoadingByteArrayOutputStream out = new LoadingByteArrayOutputStream();
+        XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(out, "UTF-8");
+        StaxUtils.writeDocument(doc, writer, true);
+        writer.close();
+        return out.createInputStream();
     }
 
     public static Element fetchElementByNameAttribute(Element parent, String targetName, String nameValue) {
@@ -465,12 +397,8 @@ public final class XMLUtils {
         return new QName(ns, localName, prefix);
     }
 
-    public static Node  fromSource(Source src) throws Exception {
-
-        Transformer trans = TransformerFactory.newInstance().newTransformer();
-        DOMResult res = new DOMResult();
-        trans.transform(src, res);
-        return res.getNode();
+    public static Node fromSource(Source src) throws Exception {
+        return StaxUtils.read(src);
     }
     
     public static QName convertStringToQName(String expandedQName) {

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java?rev=1499608&r1=1499607&r2=1499608&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java Wed Jul  3 23:54:47 2013
@@ -20,6 +20,7 @@ package org.apache.cxf.interceptor;
 
 import java.io.File;
 import java.io.FileWriter;
+import java.io.InputStream;
 import java.io.PrintWriter;
 import java.io.StringReader;
 import java.io.StringWriter;
@@ -30,19 +31,18 @@ import java.util.logging.Level;
 import java.util.logging.LogRecord;
 import java.util.logging.Logger;
 
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.stream.StreamResult;
+import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.stream.StreamSource;
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.InterfaceInfo;
+import org.apache.cxf.staxutils.PrettyPrintXMLStreamWriter;
+import org.apache.cxf.staxutils.StaxUtils;
 
 /**
  * A simple logging handler which outputs the bytes of the message to the
@@ -150,13 +150,15 @@ public abstract class AbstractLoggingInt
         // Just transform the XML message when the cos has content
         if (isPrettyLogging() && (contentType != null && contentType.indexOf("xml") >= 0 
             && contentType.toLowerCase().indexOf("multipart/related") < 0) && cos.size() > 0) {
-            Transformer serializer = XMLUtils.newTransformer(2);
-            // 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(new StreamSource(cos.getInputStream()), new StreamResult(swriter));
+            XMLStreamWriter xwriter = StaxUtils.createXMLStreamWriter(swriter);
+            xwriter = new PrettyPrintXMLStreamWriter(xwriter, 0, 2);
+            InputStream in = cos.getInputStream();
+            StaxUtils.copy(new StreamSource(in), xwriter);
+            xwriter.close();
+            in.close();
+            
             String result = swriter.toString();
             if (result.length() < limit || limit == -1) {
                 builder.append(swriter.toString());
@@ -182,14 +184,13 @@ public abstract class AbstractLoggingInt
             && contentType != null 
             && contentType.indexOf("xml") >= 0 
             && stringWriter.getBuffer().length() > 0) {
-            Transformer serializer = XMLUtils.newTransformer(2);
-            // 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(new StreamSource(new StringReader(stringWriter.getBuffer().toString())),
-                                 new StreamResult(swriter));
+            XMLStreamWriter xwriter = StaxUtils.createXMLStreamWriter(swriter);
+            xwriter = new PrettyPrintXMLStreamWriter(xwriter, 0, 2);
+            StaxUtils.copy(new StreamSource(new StringReader(stringWriter.getBuffer().toString())), xwriter);
+            xwriter.close();
+            
             String result = swriter.toString();
             if (result.length() < limit || limit == -1) {
                 builder.append(swriter.toString());

Copied: cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/PrettyPrintXMLStreamWriter.java (from r1499490, cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl/PrettyPrintXMLStreamWriter.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/PrettyPrintXMLStreamWriter.java?p2=cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/PrettyPrintXMLStreamWriter.java&p1=cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl/PrettyPrintXMLStreamWriter.java&r1=1499490&r2=1499608&rev=1499608&view=diff
==============================================================================
--- cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl/PrettyPrintXMLStreamWriter.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/PrettyPrintXMLStreamWriter.java Wed Jul  3 23:54:47 2013
@@ -17,23 +17,10 @@
  * under the License.
  */
 
-package org.apache.cxf.wsdl;
+package org.apache.cxf.staxutils;
 
-import java.util.HashMap;
-import java.util.Map;
 import java.util.Stack;
 
-import javax.wsdl.Binding;
-import javax.wsdl.BindingFault;
-import javax.wsdl.BindingInput;
-import javax.wsdl.BindingOperation;
-import javax.wsdl.BindingOutput;
-import javax.wsdl.Definition;
-import javax.wsdl.Message;
-import javax.wsdl.Operation;
-import javax.wsdl.Port;
-import javax.wsdl.Service;
-import javax.wsdl.Types;
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
@@ -41,24 +28,31 @@ import javax.xml.stream.XMLStreamWriter;
 
 public class PrettyPrintXMLStreamWriter implements XMLStreamWriter {
 
-    static final Map<Class<?>, Integer> WSDL_INDENT_MAP = new HashMap<Class<?>, Integer>();
     static final int DEFAULT_INDENT_LEVEL = 2;
 
     XMLStreamWriter baseWriter;
 
-    int indent;
+    int curIndent;
+    int indentAmount = DEFAULT_INDENT_LEVEL;
     Stack<CurrentElement> elems = new Stack<CurrentElement>();
     QName currElem;
     boolean nestedStartElement;   
 
     public PrettyPrintXMLStreamWriter(XMLStreamWriter writer,
-                                      Class<?> parent) {
+                                      int initialLevel) {
         baseWriter = writer;
-        indent = getIndentLevel(parent);
+        curIndent = initialLevel;
+    }
+    public PrettyPrintXMLStreamWriter(XMLStreamWriter writer,
+                                      int initialLevel,
+                                      int indentAmount) {
+        baseWriter = writer;
+        curIndent = initialLevel;
+        this.indentAmount = indentAmount;
     }
 
     public void writeSpaces() throws XMLStreamException {
-        for (int i = 0; i < indent; i++) {
+        for (int i = 0; i < curIndent; i++) {
             baseWriter.writeCharacters(" ");
         }
     }
@@ -69,11 +63,11 @@ public class PrettyPrintXMLStreamWriter 
     }
 
     public void indent() {
-        indent += DEFAULT_INDENT_LEVEL;
+        curIndent += indentAmount;
     }
     
     public void unindent() {
-        indent -= DEFAULT_INDENT_LEVEL;
+        curIndent -= indentAmount;
     }
 
     public void close() throws XMLStreamException {
@@ -248,27 +242,6 @@ public class PrettyPrintXMLStreamWriter 
         elems.push(new CurrentElement(currElemName));
     }
 
-    private int getIndentLevel(Class<?> parent) {
-        Integer result = WSDL_INDENT_MAP.get(parent);
-        if (result == null) {
-            return DEFAULT_INDENT_LEVEL;
-        }
-        return result.intValue();
-    }
-
-    static {
-        WSDL_INDENT_MAP.put(Definition.class, Integer.valueOf(DEFAULT_INDENT_LEVEL));
-        WSDL_INDENT_MAP.put(Binding.class, Integer.valueOf(DEFAULT_INDENT_LEVEL * 2));
-        WSDL_INDENT_MAP.put(BindingFault.class, Integer.valueOf(DEFAULT_INDENT_LEVEL * 3));
-        WSDL_INDENT_MAP.put(BindingInput.class, Integer.valueOf(DEFAULT_INDENT_LEVEL * 3));
-        WSDL_INDENT_MAP.put(BindingOutput.class, Integer.valueOf(DEFAULT_INDENT_LEVEL * 3));
-        WSDL_INDENT_MAP.put(BindingOperation.class, Integer.valueOf(DEFAULT_INDENT_LEVEL * 3));
-        WSDL_INDENT_MAP.put(Message.class, Integer.valueOf(DEFAULT_INDENT_LEVEL * 2));
-        WSDL_INDENT_MAP.put(Operation.class, Integer.valueOf(DEFAULT_INDENT_LEVEL * 3));
-        WSDL_INDENT_MAP.put(Port.class, Integer.valueOf(DEFAULT_INDENT_LEVEL * 3));
-        WSDL_INDENT_MAP.put(Service.class, Integer.valueOf(DEFAULT_INDENT_LEVEL * 2));
-        WSDL_INDENT_MAP.put(Types.class, Integer.valueOf(DEFAULT_INDENT_LEVEL * 2));
-    }
 
     class CurrentElement {
         private QName name;

Modified: cxf/trunk/api/src/test/java/org/apache/cxf/common/xmlschema/ImportRepairTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/test/java/org/apache/cxf/common/xmlschema/ImportRepairTest.java?rev=1499608&r1=1499607&r2=1499608&view=diff
==============================================================================
--- cxf/trunk/api/src/test/java/org/apache/cxf/common/xmlschema/ImportRepairTest.java (original)
+++ cxf/trunk/api/src/test/java/org/apache/cxf/common/xmlschema/ImportRepairTest.java Wed Jul  3 23:54:47 2013
@@ -27,11 +27,8 @@ import java.util.logging.Logger;
 
 import javax.xml.XMLConstants;
 import javax.xml.namespace.QName;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
+import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
 
 import org.w3c.dom.DOMError;
 import org.w3c.dom.DOMErrorHandler;
@@ -41,7 +38,8 @@ import org.w3c.dom.ls.LSInput;
 import org.w3c.dom.ls.LSResourceResolver;
 
 import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.staxutils.PrettyPrintXMLStreamWriter;
+import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaAttribute;
 import org.apache.ws.commons.schema.XmlSchemaComplexContent;
@@ -51,7 +49,6 @@ import org.apache.ws.commons.schema.XmlS
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaSequence;
 import org.apache.ws.commons.schema.XmlSchemaSerializer;
-import org.apache.ws.commons.schema.XmlSchemaSerializer.XmlSchemaSerializerException;
 import org.apache.ws.commons.schema.XmlSchemaSimpleType;
 import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction;
 import org.apache.ws.commons.schema.utils.NamespaceMap;
@@ -156,8 +153,7 @@ public class ImportRepairTest extends As
         tryToParseSchemas();
     }
 
-    private void tryToParseSchemas() throws ClassNotFoundException, InstantiationException,
-        IllegalAccessException, XmlSchemaSerializerException, TransformerException {
+    private void tryToParseSchemas() throws Exception {
         // Get DOM Implementation using DOM Registry
         final List<DOMLSInput> inputs = new ArrayList<DOMLSInput>();
         final Map<String, LSInput> resolverMap = new HashMap<String, LSInput>();
@@ -203,18 +199,15 @@ public class ImportRepairTest extends As
         schemaLoader.loadInputList(new ListLSInput(inputs));
     }
 
-    private void dumpSchema(Document document) {
+    private void dumpSchema(Document document) throws Exception {
         if (!dumpSchemas) {
             return;
         }
-        try {
-            Transformer t = XMLUtils.newTransformer(2);
-            t.setOutputProperty(OutputKeys.INDENT, "yes");
-            t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
-            t.transform(new DOMSource(document), new StreamResult(System.err));
-        } catch (Exception e) {
-            //
-        }
+        
+        XMLStreamWriter xwriter = StaxUtils.createXMLStreamWriter(System.err);
+        xwriter = new PrettyPrintXMLStreamWriter(xwriter, 0, 2);
+        StaxUtils.copy(new DOMSource(document), xwriter);
+        xwriter.close();
     }
 
     private void createTypeImportedByElement(XmlSchema elementTypeSchema) {

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java?rev=1499608&r1=1499607&r2=1499608&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java Wed Jul  3 23:54:47 2013
@@ -18,7 +18,6 @@
  */
 package org.apache.cxf.aegis;
 
-import java.io.IOException;
 import java.lang.reflect.Array;
 import java.lang.reflect.GenericArrayType;
 import java.lang.reflect.ParameterizedType;
@@ -28,14 +27,12 @@ import java.util.Map;
 import java.util.Set;
 
 import javax.xml.namespace.QName;
-import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
 import org.w3c.dom.Document;
 
-import org.xml.sax.SAXException;
-
 import org.apache.cxf.aegis.type.AbstractTypeCreator;
 import org.apache.cxf.aegis.type.AegisType;
 import org.apache.cxf.aegis.type.DefaultTypeCreator;
@@ -301,11 +298,7 @@ public class AegisContext {
     private Document getSchemaDocument(String resourcePath) { 
         try {
             return XMLUtils.parse(getClass().getResourceAsStream(resourcePath));
-        } catch (ParserConfigurationException e) {
-            throw new RuntimeException(e);
-        } catch (SAXException e) {
-            throw new RuntimeException(e);
-        } catch (IOException e) {
+        } catch (XMLStreamException e) {
             throw new RuntimeException(e);
         }
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/xml/XMLSource.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/xml/XMLSource.java?rev=1499608&r1=1499607&r2=1499608&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/xml/XMLSource.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/xml/XMLSource.java Wed Jul  3 23:54:47 2013
@@ -18,9 +18,7 @@
  */
 package org.apache.cxf.jaxrs.ext.xml;
 
-import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Array;
 import java.net.URI;
 import java.util.Collections;
@@ -43,13 +41,13 @@ import javax.xml.xpath.XPathExpressionEx
 import javax.xml.xpath.XPathFactory;
 
 import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
 import org.xml.sax.InputSource;
 
 import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.jaxrs.provider.JAXBElementProvider;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.staxutils.StaxUtils;
@@ -331,11 +329,9 @@ public class XMLSource {
     private <T> Object readPrimitiveValue(Node node, Class<T> cls) {
         if (String.class == cls) {
             if (node.getNodeType() == Node.ELEMENT_NODE) {
-                ByteArrayOutputStream bos = new ByteArrayOutputStream();
-                XMLUtils.writeTo(new DOMSource(node), bos, 0, "", "yes");
                 try {
-                    return cls.cast(bos.toString("UTF-8"));
-                } catch (UnsupportedEncodingException ex) {
+                    return StaxUtils.toString((Element)node);
+                } catch (XMLStreamException e) {
                     // won't happen
                 }
             } else {

Modified: cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JInOutTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JInOutTest.java?rev=1499608&r1=1499607&r2=1499608&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JInOutTest.java (original)
+++ cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JInOutTest.java Wed Jul  3 23:54:47 2013
@@ -585,7 +585,7 @@ public class WSS4JInOutTest extends Abst
     }
     
     // FOR DEBUGGING ONLY
-    /*private*/ static String serialize(Document doc) {
+    /*private*/ static String serialize(Document doc) throws Exception {
         return XMLUtils.toString(doc);
     }
 }

Modified: cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/SamlTokenTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/SamlTokenTest.java?rev=1499608&r1=1499607&r2=1499608&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/SamlTokenTest.java (original)
+++ cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/SamlTokenTest.java Wed Jul  3 23:54:47 2013
@@ -595,7 +595,7 @@ public class SamlTokenTest extends Abstr
     }
 
     // FOR DEBUGGING ONLY
-    /*private*/ static String serialize(Document doc) {
+    /*private*/ static String serialize(Document doc) throws Exception {
         return XMLUtils.toString(doc);
     }
 }

Modified: cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java?rev=1499608&r1=1499607&r2=1499608&view=diff
==============================================================================
--- cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java (original)
+++ cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java Wed Jul  3 23:54:47 2013
@@ -21,13 +21,24 @@ package org.apache.cxf.wsdl;
 
 import java.io.PrintWriter;
 import java.lang.reflect.Method;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.wsdl.Binding;
+import javax.wsdl.BindingFault;
+import javax.wsdl.BindingInput;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.BindingOutput;
 import javax.wsdl.Definition;
+import javax.wsdl.Message;
+import javax.wsdl.Operation;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.Types;
 import javax.wsdl.WSDLException;
 import javax.wsdl.extensions.ExtensibilityElement;
 import javax.wsdl.extensions.ExtensionDeserializer;
@@ -63,6 +74,7 @@ import org.apache.cxf.common.util.ASMHel
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.staxutils.PrettyPrintXMLStreamWriter;
 import org.apache.cxf.staxutils.StaxUtils;
 
 
@@ -70,7 +82,9 @@ import org.apache.cxf.staxutils.StaxUtil
  * JAXBExtensionHelper
  */
 public class JAXBExtensionHelper implements ExtensionSerializer, ExtensionDeserializer {
+    static final Map<Class<?>, Integer> WSDL_INDENT_MAP = new HashMap<Class<?>, Integer>();
     private static final Logger LOG = LogUtils.getL7dLogger(JAXBExtensionHelper.class);
+    private static final int DEFAULT_INDENT_LEVEL = 2;
 
     final Class<?> typeClass;
     final String namespace;
@@ -96,6 +110,29 @@ public class JAXBExtensionHelper impleme
         extensionClass = cls;
     }
     
+    private int getIndentLevel(Class<?> parent) {
+        Integer result = WSDL_INDENT_MAP.get(parent);
+        if (result == null) {
+            return DEFAULT_INDENT_LEVEL;
+        }
+        return result.intValue();
+    }
+
+    static {
+        WSDL_INDENT_MAP.put(Definition.class, Integer.valueOf(DEFAULT_INDENT_LEVEL));
+        WSDL_INDENT_MAP.put(Binding.class, Integer.valueOf(DEFAULT_INDENT_LEVEL * 2));
+        WSDL_INDENT_MAP.put(BindingFault.class, Integer.valueOf(DEFAULT_INDENT_LEVEL * 3));
+        WSDL_INDENT_MAP.put(BindingInput.class, Integer.valueOf(DEFAULT_INDENT_LEVEL * 3));
+        WSDL_INDENT_MAP.put(BindingOutput.class, Integer.valueOf(DEFAULT_INDENT_LEVEL * 3));
+        WSDL_INDENT_MAP.put(BindingOperation.class, Integer.valueOf(DEFAULT_INDENT_LEVEL * 3));
+        WSDL_INDENT_MAP.put(Message.class, Integer.valueOf(DEFAULT_INDENT_LEVEL * 2));
+        WSDL_INDENT_MAP.put(Operation.class, Integer.valueOf(DEFAULT_INDENT_LEVEL * 3));
+        WSDL_INDENT_MAP.put(Port.class, Integer.valueOf(DEFAULT_INDENT_LEVEL * 3));
+        WSDL_INDENT_MAP.put(Service.class, Integer.valueOf(DEFAULT_INDENT_LEVEL * 2));
+        WSDL_INDENT_MAP.put(Types.class, Integer.valueOf(DEFAULT_INDENT_LEVEL * 2));
+    }
+    
+    
     public static void addExtensions(ExtensionRegistry registry, String parentType, String elementType)
         throws JAXBException, ClassNotFoundException {
         Class<?> parentTypeClass = ClassLoaderUtils.loadClass(parentType, JAXBExtensionHelper.class);
@@ -261,7 +298,7 @@ public class JAXBExtensionHelper impleme
             
             javax.xml.stream.XMLOutputFactory fact = javax.xml.stream.XMLOutputFactory.newInstance();
             XMLStreamWriter writer =
-                new PrettyPrintXMLStreamWriter(fact.createXMLStreamWriter(pw), parent);
+                new PrettyPrintXMLStreamWriter(fact.createXMLStreamWriter(pw), getIndentLevel(parent));
             writer.setNamespaceContext(new javax.xml.namespace.NamespaceContext() {
                 
                 public String getNamespaceURI(String arg) {

Modified: cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl11/SchemaSerializer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl11/SchemaSerializer.java?rev=1499608&r1=1499607&r2=1499608&view=diff
==============================================================================
--- cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl11/SchemaSerializer.java (original)
+++ cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl11/SchemaSerializer.java Wed Jul  3 23:54:47 2013
@@ -28,15 +28,14 @@ import javax.wsdl.extensions.ExtensionRe
 import javax.wsdl.extensions.ExtensionSerializer;
 import javax.wsdl.extensions.schema.Schema;
 import javax.xml.namespace.QName;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
 
 import org.w3c.dom.Node;
 
-import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.staxutils.PrettyPrintXMLStreamWriter;
+import org.apache.cxf.staxutils.StaxUtils;
 
 /**
  * A custom Schema serializer because WSDL4J's is buggy.
@@ -48,15 +47,15 @@ public class SchemaSerializer implements
                          Definition def, ExtensionRegistry extReg) throws WSDLException {
         try {
             writeXml(((Schema)extension).getElement(), pw);
-        } catch (TransformerException e) {
+        } catch (XMLStreamException e) {
             throw new WSDLException("", "Could not write schema.", e);
         }
     }
 
-    private void writeXml(Node n, PrintWriter pw) throws TransformerException {
-        Transformer t = XMLUtils.newTransformer(2);
-        t.setOutputProperty(OutputKeys.INDENT, "yes");
-        t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
-        t.transform(new DOMSource(n), new StreamResult(pw));
+    private void writeXml(Node n, PrintWriter pw) throws XMLStreamException {
+        XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(pw);
+        writer = new PrettyPrintXMLStreamWriter(writer, 0, 2);
+        StaxUtils.copy(new DOMSource(n), writer);
+        writer.close();
     }
 }

Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AttachmentStreamSourceXMLProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AttachmentStreamSourceXMLProvider.java?rev=1499608&r1=1499607&r2=1499608&view=diff
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AttachmentStreamSourceXMLProvider.java (original)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AttachmentStreamSourceXMLProvider.java Wed Jul  3 23:54:47 2013
@@ -32,8 +32,6 @@ import java.util.Map;
 import javax.activation.DataHandler;
 import javax.annotation.Resource;
 import javax.mail.util.ByteArrayDataSource;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.stream.StreamSource;
 import javax.xml.ws.Provider;
 import javax.xml.ws.Service;
@@ -47,8 +45,8 @@ import org.w3c.dom.Document;
 import org.apache.cxf.common.util.Base64Utility;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.IOUtils;
-import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.message.Message;
+import org.apache.cxf.staxutils.StaxUtils;
 
 @WebServiceProvider(serviceName = "AttachmentStreamSourceXMLProvider")
 @ServiceMode(value = Service.Mode.PAYLOAD)
@@ -67,12 +65,9 @@ public class AttachmentStreamSourceXMLPr
             
             int count = 0;
             // we really want to verify that a root part is a proper XML as expected
-            DOMResult result = new DOMResult();
             try {
-                Transformer transformer = XMLUtils.newTransformer();
-                transformer.transform(source, result);
-                count = 
-                    Integer.parseInt(((Document)result.getNode()).getDocumentElement().getAttribute("count"));
+                Document doc = StaxUtils.read(source);
+                count = Integer.parseInt(doc.getDocumentElement().getAttribute("count"));
             } catch (Exception ex) {
                 // ignore
             }

Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/SchemaWriterImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/SchemaWriterImpl.java?rev=1499608&r1=1499607&r2=1499608&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/SchemaWriterImpl.java (original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/SchemaWriterImpl.java Wed Jul  3 23:54:47 2013
@@ -29,6 +29,7 @@ import javax.wsdl.WSDLException;
 import javax.wsdl.extensions.ExtensibilityElement;
 import javax.wsdl.extensions.schema.Schema;
 import javax.wsdl.xml.WSDLWriter;
+import javax.xml.stream.XMLStreamException;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -82,9 +83,17 @@ public class SchemaWriterImpl implements
     }
 
     public void writeWSDL(Definition wsdlDef, Writer sink) throws WSDLException {
-        XMLUtils.writeTo(getDocument(wsdlDef), sink, 2);
+        try {
+            XMLUtils.writeTo(getDocument(wsdlDef), sink, 2);
+        } catch (XMLStreamException e) {
+            throw new RuntimeException(e);
+        }
     }    
     public void writeWSDL(Definition wsdlDef, OutputStream sink) throws WSDLException {
-        XMLUtils.writeTo(getDocument(wsdlDef), sink, 2);
+        try {
+            XMLUtils.writeTo(getDocument(wsdlDef), sink, 2);
+        } catch (XMLStreamException e) {
+            throw new RuntimeException(e);
+        }
     }   
 }

Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLCorbaWriterImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLCorbaWriterImpl.java?rev=1499608&r1=1499607&r2=1499608&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLCorbaWriterImpl.java (original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLCorbaWriterImpl.java Wed Jul  3 23:54:47 2013
@@ -31,6 +31,7 @@ import javax.wsdl.extensions.Extensibili
 import javax.wsdl.extensions.schema.Schema;
 import javax.wsdl.xml.WSDLWriter;
 import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLStreamException;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -141,10 +142,18 @@ public class WSDLCorbaWriterImpl impleme
 
 
     public void writeWSDL(Definition wsdlDef, Writer sink) throws WSDLException {
-        XMLUtils.writeTo(getDocument(wsdlDef), sink, 2);
+        try {
+            XMLUtils.writeTo(getDocument(wsdlDef), sink, 2);
+        } catch (XMLStreamException e) {
+            throw new RuntimeException(e);
+        }
     }    
     public void writeWSDL(Definition wsdlDef, OutputStream sink) throws WSDLException {
-        XMLUtils.writeTo(getDocument(wsdlDef), sink, 2);
+        try {
+            XMLUtils.writeTo(getDocument(wsdlDef), sink, 2);
+        } catch (XMLStreamException e) {
+            throw new RuntimeException(e);
+        }
     }        
     
 }

Modified: cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java?rev=1499608&r1=1499607&r2=1499608&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java (original)
+++ cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java Wed Jul  3 23:54:47 2013
@@ -30,11 +30,13 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+
 import javax.wsdl.Definition;
 import javax.wsdl.Import;
 import javax.wsdl.WSDLException;
 import javax.wsdl.factory.WSDLFactory;
 import javax.wsdl.xml.WSDLWriter;
+import javax.xml.stream.XMLStreamException;
 
 import org.w3c.dom.Element;
 
@@ -122,6 +124,8 @@ public class WSDL11Generator extends Abs
             throw new ToolException("Output file " + file + " not found", fnfe);
         } catch (IOException e) {
             e.printStackTrace();
+        } catch (XMLStreamException e) {
+            e.printStackTrace();
         }
         return def;
     }

Modified: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/AegisTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/AegisTest.java?rev=1499608&r1=1499607&r2=1499608&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/AegisTest.java (original)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/AegisTest.java Wed Jul  3 23:54:47 2013
@@ -26,6 +26,7 @@ import java.util.Map;
 import javax.wsdl.Definition;
 import javax.wsdl.factory.WSDLFactory;
 import javax.wsdl.xml.WSDLReader;
+import javax.xml.stream.XMLStreamException;
 import javax.xml.xpath.XPathConstants;
 
 import org.w3c.dom.Document;
@@ -36,6 +37,7 @@ import org.apache.cxf.helpers.FileUtils;
 import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.helpers.XPathUtils;
 import org.apache.cxf.tools.common.ToolTestBase;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -135,7 +137,7 @@ public class AegisTest extends ToolTestB
         return namespaces;
     }
     
-    private void assertValid(String xpathExpression, Document doc) {
+    private void assertValid(String xpathExpression, Document doc) throws XMLStreamException {
         XPathUtils xpu = new XPathUtils(getNSMap());
         if (!xpu.isExist(xpathExpression, doc, XPathConstants.NODE)) {
             throw new AssertionFailedError("Failed to select any nodes for expression:\n" + xpathExpression

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/HandlerConfigGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/HandlerConfigGenerator.java?rev=1499608&r1=1499607&r2=1499608&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/HandlerConfigGenerator.java (original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/HandlerConfigGenerator.java Wed Jul  3 23:54:47 2013
@@ -19,7 +19,6 @@
 
 package org.apache.cxf.tools.wsdlto.frontend.jaxws.generators;
 
-import java.io.IOException;
 import java.io.Writer;
 import java.util.List;
 
@@ -94,7 +93,7 @@ public class HandlerConfigGenerator exte
         try {
             XMLUtils.generateXMLFile(hChains, writer);
             writer.close();
-        } catch (IOException ex) {
+        } catch (Exception ex) {
             throw new ToolException(ex);
         }
     }