You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Aki Yoshida <el...@gmail.com> on 2015/05/07 16:26:00 UTC

StAXSource to InputStream direct conversion

Hi,
There is currently no direct type conversion from StAXSource or
XMLStreamReadder to InputStream. Am I correct? I noticed this while
looking at the camel-cxf's StAXSource related xml-namespace issue
(CAMEL-8663) when converting to InputStream, the conversion succeeded
but went via DOM's NodeList, which you wouldn't really want.

Assuming this assumption, I am wondering if we can add a direct
converter. I wrote a class that can convert XMLStreamReader to
InputStream or Reader using a small buffer while I was doing the
xmltokenizer last year. A converter can be easily written using this
approach.

The code is available here and you can look at them.

https://github.com/elakito/misc-xml/blob/master/src/main/java/de/elakito/misc/xml/util/XMLStreamReaderInputStream.java
https://github.com/elakito/misc-xml/blob/master/src/main/java/de/elakito/misc/xml/util/XMLStreamReaderReader.java

Let me know what you think.

regards, aki

Re: StAXSource to InputStream direct conversion

Posted by Aki Yoshida <el...@gmail.com>.
Hi Claus,
thanks for your reply. I'll look into it next week.
regards, aki

2015-05-07 20:14 GMT+02:00 Claus Ibsen <cl...@gmail.com>:
> Hi
>
> Yeah sounds much better if the conversion can happen more directly and
> faster in a streaming style.
>
> On Thu, May 7, 2015 at 4:26 PM, Aki Yoshida <el...@gmail.com> wrote:
>> Hi,
>> There is currently no direct type conversion from StAXSource or
>> XMLStreamReadder to InputStream. Am I correct? I noticed this while
>> looking at the camel-cxf's StAXSource related xml-namespace issue
>> (CAMEL-8663) when converting to InputStream, the conversion succeeded
>> but went via DOM's NodeList, which you wouldn't really want.
>>
>> Assuming this assumption, I am wondering if we can add a direct
>> converter. I wrote a class that can convert XMLStreamReader to
>> InputStream or Reader using a small buffer while I was doing the
>> xmltokenizer last year. A converter can be easily written using this
>> approach.
>>
>> The code is available here and you can look at them.
>>
>> https://github.com/elakito/misc-xml/blob/master/src/main/java/de/elakito/misc/xml/util/XMLStreamReaderInputStream.java
>> https://github.com/elakito/misc-xml/blob/master/src/main/java/de/elakito/misc/xml/util/XMLStreamReaderReader.java
>>
>> Let me know what you think.
>>
>> regards, aki
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/

Re: StAXSource to InputStream direct conversion

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah sounds much better if the conversion can happen more directly and
faster in a streaming style.

On Thu, May 7, 2015 at 4:26 PM, Aki Yoshida <el...@gmail.com> wrote:
> Hi,
> There is currently no direct type conversion from StAXSource or
> XMLStreamReadder to InputStream. Am I correct? I noticed this while
> looking at the camel-cxf's StAXSource related xml-namespace issue
> (CAMEL-8663) when converting to InputStream, the conversion succeeded
> but went via DOM's NodeList, which you wouldn't really want.
>
> Assuming this assumption, I am wondering if we can add a direct
> converter. I wrote a class that can convert XMLStreamReader to
> InputStream or Reader using a small buffer while I was doing the
> xmltokenizer last year. A converter can be easily written using this
> approach.
>
> The code is available here and you can look at them.
>
> https://github.com/elakito/misc-xml/blob/master/src/main/java/de/elakito/misc/xml/util/XMLStreamReaderInputStream.java
> https://github.com/elakito/misc-xml/blob/master/src/main/java/de/elakito/misc/xml/util/XMLStreamReaderReader.java
>
> Let me know what you think.
>
> regards, aki



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/