servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r358593 - in /incubator/servicemix/trunk/servicemix-core: ./ .cvsignore src/main/java/org/servicemix/jbi/jaxp/SourceTransformer.java src/main/java/org/servicemix/jbi/jaxp/StAXSourceTransformer.java
Date Thu, 22 Dec 2005 17:30:25 GMT
Author: gnodet
Date: Thu Dec 22 09:30:19 2005
New Revision: 358593

URL: http://svn.apache.org/viewcvs?rev=358593&view=rev
Log:
Add a few transformation functions to SourceTransformer.

Removed:
    incubator/servicemix/trunk/servicemix-core/.cvsignore
Modified:
    incubator/servicemix/trunk/servicemix-core/   (props changed)
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/servicemix/jbi/jaxp/SourceTransformer.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/servicemix/jbi/jaxp/StAXSourceTransformer.java

Propchange: incubator/servicemix/trunk/servicemix-core/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu Dec 22 09:30:19 2005
@@ -3,3 +3,5 @@
 target
 testWDIR
 testWDR
+.classpath
+.project

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/servicemix/jbi/jaxp/SourceTransformer.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/servicemix/jbi/jaxp/SourceTransformer.java?rev=358593&r1=358592&r2=358593&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/servicemix/jbi/jaxp/SourceTransformer.java
(original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/servicemix/jbi/jaxp/SourceTransformer.java
Thu Dec 22 09:30:19 2005
@@ -46,6 +46,7 @@
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.io.Reader;
 import java.io.StringWriter;
 
@@ -203,6 +204,15 @@
         inputSource.setPublicId(source.getPublicId());
         return new SAXSource(inputSource);
     }
+	
+	public Reader toReaderFromSource(Source src) throws TransformerException {
+		StreamSource stSrc = toStreamSource(src);
+		Reader r = stSrc.getReader();
+		if (r == null) {
+			r = new InputStreamReader(stSrc.getInputStream());
+		}
+		return r;
+	}
 
     public DOMSource toDOMSourceFromStream(StreamSource source) throws ParserConfigurationException,
IOException, SAXException {
         DocumentBuilder builder = createDocumentBuilder();
@@ -231,11 +241,15 @@
     }
 
     public DOMSource toDOMSourceFromSAX(SAXSource source) throws IOException, SAXException,
ParserConfigurationException {
+        return new DOMSource(toDOMNodeFromSAX(source));
+    }
+    
+    public Node toDOMNodeFromSAX(SAXSource source) throws ParserConfigurationException, IOException,
SAXException {
         SAX2DOM converter = new SAX2DOM(createDocument());
         XMLReader xmlReader = source.getXMLReader();
         xmlReader.setContentHandler(converter);
         xmlReader.parse(source.getInputSource());
-        return new DOMSource(converter.getDOM());
+        return converter.getDOM();
     }
 
 

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/servicemix/jbi/jaxp/StAXSourceTransformer.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/servicemix/jbi/jaxp/StAXSourceTransformer.java?rev=358593&r1=358592&r2=358593&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/servicemix/jbi/jaxp/StAXSourceTransformer.java
(original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/servicemix/jbi/jaxp/StAXSourceTransformer.java
Thu Dec 22 09:30:19 2005
@@ -59,6 +59,15 @@
             return new StAXSource(reader);
         }
     }
+    
+    public XMLStreamReader toXMLStreamReader(Source source) throws XMLStreamException, TransformerException
{
+        XMLInputFactory factory = getInputFactory();
+        try {
+        	return factory.createXMLStreamReader(source);
+        } catch (XMLStreamException e) {
+        	return factory.createXMLStreamReader(toReaderFromSource(source));
+        }
+    }
 
     public DOMSource toDOMSource(Source source) throws ParserConfigurationException, IOException,
SAXException, TransformerException {
         DOMSource answer = super.toDOMSource(source);



Mime
View raw message