DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18458>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18458

Using an InputStream with "getAssociatedStylesheet()" causes IOException

           Summary: Using an InputStream with "getAssociatedStylesheet()"
                    causes IOException
           Product: XalanJ2
           Version: 2.3
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: org.apache.xalan.transformer
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Using an InputStream as the Source XML along with "getAssociatedStylesheet()"
causes the transformation to fail with an IOException due to Stream closed.
This probably happens because the "getAssociatedStylesheet()" method causes the
stream to be closed at the end. This happens because the Xerces SAX Parser
Implementation seems to be closing the InputStream passed to it for parsing
(which may be good in some cases, but can cause problems when used in the
following manner).
The subsequent call to "transform(source, result)" therefore acts on a closed
source stream and throws the IOException.
Sample code:
------------
public void transform(InputStream source, OutputStream result)
{
    Source style = TransformerFactory.newInstance().getAssociatedStylesheet(
                                         source, null, null, null);
    Transformer t = TransformerFactory.newInstance().newTransformer();
    if(style != null){
        t = TransformerFactory.newInstance().newTransformer(style);
    }
    t.transform(new StreamSource(source), new StreamResult(result));
}

Exception:
----------
java.io.IOException: The system cannot find the path specified
        at java.io.FileInputStream.read(Native Method)
        at
org.apache.xerces.impl.XMLEntityManager$RewindableInputStream.read(XMLEntityManager.java:3278)
        at
org.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.java:742)
        at
org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(XMLEntityManager.java:676)
        at
org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(XMLDocumentScannerImpl.java:252)
        at
org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:499)
        at
org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:581)
        at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)
        at
org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1157)
        at
org.apache.xml.dtm.ref.DTMManagerDefault.getDTM(DTMManagerDefault.java:449)
        at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:625)
        at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1088)
        at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1066)
        at com.vigorsoft.xsl.XSLTHelper.transform(XSLTHelper.java:93)
        at com.vigorsoft.xsl.XSLTHelper.transform(XSLTHelper.java:77)
        at com.vigorsoft.xsl.XSLTHelper.main(XSLTHelper.java:104)

Reply via email to