cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r836167 - in /cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils: AbstractDOMStreamReader.java StaxUtils.java W3CDOMStreamReader.java
Date Sat, 14 Nov 2009 13:27:18 GMT
Author: dkulp
Date: Sat Nov 14 13:27:18 2009
New Revision: 836167

URL: http://svn.apache.org/viewvc?rev=836167&view=rev
Log:
[CXF-2536] If .createXMLStreamReader(Source source) returns null, try
using the other methods.

Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/AbstractDOMStreamReader.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/AbstractDOMStreamReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/AbstractDOMStreamReader.java?rev=836167&r1=836166&r2=836167&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/AbstractDOMStreamReader.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/AbstractDOMStreamReader.java
Sat Nov 14 13:27:18 2009
@@ -325,6 +325,12 @@
                 || currentEvent == COMMENT || currentEvent == SPACE;
     }
 
+    public String getSystemId() {
+        return null;
+    }
+    public String getPublicId() {
+        return null;
+    }
     public Location getLocation() {
         return new Location() {
 
@@ -341,11 +347,11 @@
             }
 
             public String getPublicId() {
-                return null;
+                return AbstractDOMStreamReader.this.getPublicId();
             }
 
             public String getSystemId() {
-                return null;
+                return AbstractDOMStreamReader.this.getSystemId();
             }
 
         };

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=836167&r1=836166&r2=836167&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Sat Nov
14 13:27:18 2009
@@ -1047,7 +1047,7 @@
                 }
                 
                 if (null != el) {
-                    return new W3CDOMStreamReader(el);
+                    return new W3CDOMStreamReader(el, source.getSystemId());
                 }
             } else if ("javax.xml.transform.stax.StAXSource".equals(source.getClass().getName()))
{
                 try {
@@ -1060,7 +1060,19 @@
             
             XMLInputFactory factory = getXMLInputFactory();
             try {
-                return factory.createXMLStreamReader(source);
+                XMLStreamReader reader = factory.createXMLStreamReader(source);
+                if (reader == null && source instanceof StreamSource) {
+                    //createXMLStreamReader from Source is optional, we'll try and map it
+                    StreamSource ss = (StreamSource)source;
+                    if (ss.getInputStream() != null) {
+                        reader = factory.createXMLStreamReader(ss.getSystemId(),
+                                                               ss.getInputStream());
+                    } else {
+                        reader = factory.createXMLStreamReader(ss.getSystemId(),
+                                                               ss.getReader());
+                    }
+                }
+                return reader;
             } finally {
                 returnXMLInputFactory(factory);
             }

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java?rev=836167&r1=836166&r2=836167&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
Sat Nov 14 13:27:18 2009
@@ -44,6 +44,8 @@
     private Document document;
 
     private W3CNamespaceContext context;
+    
+    private String sysId;
 
     /**
      * @param element
@@ -55,6 +57,10 @@
                 
         this.document = element.getOwnerDocument();
     }
+    public W3CDOMStreamReader(Element element, String systemId) {
+        this(element);
+        sysId = systemId;
+    }
     public W3CDOMStreamReader(Document doc) {
         super(new ElementFrame<Node, Node>(doc, false) {
             public boolean isDocument() {
@@ -80,7 +86,9 @@
     public Document getDocument() {
         return document;
     }
-
+    public String getSystemId() {
+        return sysId == null ? document.getDocumentURI() : sysId;
+    }
     /**
      * Find name spaces declaration in atrributes and move them to separate
      * collection.



Mime
View raw message