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.