You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by "Trenton D. Adams" <tr...@athabascau.ca> on 2009/11/05 21:00:00 UTC
Stream Closed on xsl transformation
Hi Guys,
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));
Any ideas why this wouldn't work?
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: javax.xml.transform.TransformerException: java.io.IOException: Stream closed
at org.apache.xalan.transformer.TransformerImpl.fatalError(TransformerImpl.java:741)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:715)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1129)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1107)
at ca.athabascau.apas.xml.XMLUtil.xslTransformation(XMLUtil.java:226)
at ca.athabascau.apas.xml.XMLUtil.xslTransformation(XMLUtil.java:251)
at ca.athabascau.apas.IncomingTranscripts.processTranscript(IncomingTranscripts.java:348)
at ca.athabascau.apas.IncomingTranscripts.processWaitingTranscripts(IncomingTranscripts.java:107)
... 28 more
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)
at org.apache.xerces.impl.XMLEntityManager$EntityScanner.skipString(XMLEntityManager.java:3017)
at org.apache.xerces.impl.XMLDocumentScannerImpl$XMLDeclDispatcher.dispatch(XMLDocumentScannerImpl.java:577)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:333)
at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:524)
at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:580)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1169)
at org.apache.xml.dtm.ref.DTMManagerDefault.getDTM(DTMManagerDefault.java:495)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:658)
... 34 more
Trenton D. Adams
Systems Analyst/Web Software Engineer
Navy Penguins at your service!
Athabasca University
(780) 675-6195
:wq!
__
This communication is intended for the use of the recipient to whom it
is addressed, and may contain confidential, personal, and or privileged
information. Please contact us immediately if you are not the intended
recipient of this communication, and do not copy, distribute, or take
action relying on it. Any communications received in error, or
subsequent reply, should be deleted or destroyed.
---
Re: Stream Closed on xsl transformation
Posted by "Trenton D. Adams" <tr...@athabascau.ca>.
Hi Michael,
----- "Michael Ludwig" <mi...@gmx.de> wrote:
> From: "Michael Ludwig" <mi...@gmx.de>
> To: xalan-j-users@xml.apache.org
> Sent: Thursday, November 5, 2009 6:08:04 PM GMT -07:00 US/Canada Mountain
> Subject: Re: Stream Closed on xsl transformation
>
> 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/>"));
Yeah, that wouldn't be a problem, as it does not have an xml-stylesheet processing instruction.
>
> > 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.
Yes, I did narrow it down to a small test case (or semi-small, the xml/xslt isn't so small). I will see if I can provide it when I get to work tomorrow. I'll also see if I can make it happen with a smaller XML/XSLT.
>
> Best,
>
> Michael Ludwig
__
This communication is intended for the use of the recipient to whom it
is addressed, and may contain confidential, personal, and or privileged
information. Please contact us immediately if you are not the intended
recipient of this communication, and do not copy, distribute, or take
action relying on it. Any communications received in error, or
subsequent reply, should be deleted or destroyed.
---
Re: Stream Closed on xsl transformation
Posted by Michael Ludwig <mi...@gmx.de>.
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