Hi Trenton,
Trenton D. Adams schrieb am 05.11.2009 um 13:00:00 (-0700):
> I'm having some strange problems with a stream being closed when I do
> an XSL transformation on an XML document that has an xml-stylesheet
> that is at a remote location. If I instead put it locally, and and
> specify it as an xsltSource, it works fine.
>
> I have also narrowed it down to the following working...
> final Document doc = stringToDocument((String) xml);
> logger.debug(documentToString(doc));
> xmlSource = new DOMSource(doc);
>
> But not this...
> xmlSource = new StreamSource(new StringReader((String) xml));
This approach works fine for me as in:
Source src = new StreamSource(new StringReader("<Urmel/>"));
> I get a stack trace like the following; where the final "Caused by"
> indicates it has a problem with the StringReader in the second example
> above. But, my stringToDocument() method also does a StringReader.
> Caused by: java.io.IOException: Stream closed
>
> at java.io.StringReader.ensureOpen(StringReader.java:39)
>
> at java.io.StringReader.read(StringReader.java:73)
>
> at
> org.apache.xerces.impl.XMLEntityManager$EntityScanner.load(XMLEntityManager.java:3257)
The exception seems to occur in a large program. There must be something
wrong in those lines that you haven't shown. Rather than posting the
massive program, try boiling it down to a small, self-contained test
case. If the error persists, you might want to post the small test
program.
Best,
Michael Ludwig