XsltCompiler.Compile closes the input stream
Added by Anonymous over 15 years ago
Legacy ID: #7401642 Legacy Poster: Max Toro (maxtoroq)
Hello Michael, I'm using Saxon 9.1.0.3 on .NET When I call XsltCompiler.Compile and pass a Stream as argument Saxon disposes the stream. I think this is a bug, because Saxon shouldn't adopt the stream without my permission, what if I want to do further processing with it? Here's a test: void Saxon_Disposes_Stream_On_Compile() { byte[] stylesheet = Encoding.UTF8.GetBytes("<foo xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xsl:version='2.0'><a/></foo>"); Stream stream = new MemoryStream(); stream.Write(stylesheet, 0, stylesheet.Length); stream.Position = 0; var compiler = new Saxon.Api.Processor().NewXsltCompiler(); compiler.Compile(stream); try { var length = stream.Length; } catch (ObjectDisposedException ex) { Debug.Assert(ex == null, "Saxon disposed my stream!"); } }
Replies (1)
RE: XsltCompiler.Compile closes the input stream - Added by Anonymous over 15 years ago
Legacy ID: #7402501 Legacy Poster: Michael Kay (mhkay)
Generally Saxon goes to considerable lengths to avoid closing an input stream unless it created the stream itself, and as far as I can see from code inspection, that's the case here. This would suggest that it's the XML parser that is closing the stream. (The parser that's used is the Java parser in the OpenJDK library.) If that's the case there's not much I can do about it. I can't actually verify this immediately without doing a diagnostic build.
Please register to reply