cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1522623 - /cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/SchemaSerializer.java
Date Thu, 12 Sep 2013 15:37:34 GMT
Author: dkulp
Date: Thu Sep 12 15:37:33 2013
New Revision: 1522623

URL: http://svn.apache.org/r1522623
Log:
Merged revisions 1522601 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes

........
  r1522601 | dkulp | 2013-09-12 10:48:43 -0400 (Thu, 12 Sep 2013) | 2 lines

  Use staxutils to write the schema. (more reliable, faster)

........

Modified:
    cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/SchemaSerializer.java

Modified: cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/SchemaSerializer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/SchemaSerializer.java?rev=1522623&r1=1522622&r2=1522623&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/SchemaSerializer.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/SchemaSerializer.java
Thu Sep 12 15:37:33 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, 2);
+        StaxUtils.copy(new DOMSource(n), writer);
+        writer.close();
     }
 }



Mime
View raw message