« Wildlife photography II | Main | Wildlife photography III »

java.io.Reader issues

October 25, 2003
Keywords:

I have developed an XML converter that is based on the Castor framework. It is quite simple as it takes certain Java objects (beans, collections and maps) and returns an XML representation.

Actually I have implemented it so it returns an InputSource which goes well with the next step in the process, the Xalan transformation.

The problem I am having is that the InputSource can only be used once whereas we would like to use it multiple times. At least once to log the converted XML and second time for the XSLT. As soon as the input source has been used for logging purposes of the XML, the internal reader is empty and I have not found any way of resetting it.

I see two solutions. Either redesign the XMLConverter to store the XML content internally in a different way or write a utility that copies the content of one reader to another reader, while it outputs the content.



Related entries:

Trackback Pings

TrackBack URL for this entry:
http://blog.davidkaspar.com/cgi-bin/fsdg39fmcnswgv.cgi/65

Comments

  1. Seyed Razavi Says:

    no gravatar

    What you probably want to do is implement a custom InputSource wrapper class that allows rewinding of the original data source, prob. with internal buffering... although that depends on whether it is more efficient to read / generate it multiple times from the original source or to cache it in memory (or on disk etc).

Post a Comment

 *

 *

 
Remember Me?

* (you may use HTML tags for style)