Project

Profile

Help

Support #3237

closed

Calling transform calls closeResult for a StreamResult

Added by Aniruddha Joag almost 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
2017-05-25
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
9.7
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

I am using saxon9ee-9.7.0.18 and an XSLT in streaming mode intended to transform a large source file. I have a requirement for a TransformerHandler which I can then call SaxEevnts on and get resulting output as a stream of events. However the Xslt30Transformer / StreamingTransformerFactory does not provide a TransformerHandler.

As a workaround I am calling transform by passing in an XMLReader as source, and as expected the transformer sets the ContentHandler of the XMLReader to a ReceivingContentHandler, which I can now use to invoke my sax events on. Until this point, it works as expected but with the following two problems :

  1. The Controller calls closeResult as against waiting for the sax events to be processed and the callee calling close on the ResultStream.

  2. The behaviour is inconsistent :

a) If the source sax event stream is small, there is no output giving the impression that the resultStream is closed almost immediately (in attached Program.java set NUM_ROWS = 10)

b) If the source sax event stream is a bit bigger, the result stream hs the desired transformed output, but terminates prematurely and the last few sax events are missed.

Tried work-around :

I have tried setting the result to a NonCloseFileOutputStream where the close() method is commented (am writing stack trace instad to identify what is calling the close).

The work-around does not work as it appears something upstream has closed already and no more data is being sent to the stream.

Instructions to test :

  1. Attachd Program with main method and 4 other dependant classes.

  2. In the main, straightTransform() is commented and ws only used to test the basic transform works as expected. this can be left commented.

  3. Set RESULT_FILE to appropriate output file path.

  4. Run with NUM_ROWS = 10 and no output is received.

  5. Run with NUM_ROWS = 100 and desired transformed output is received by prematurely truncated.

Messages are written to StdOut to reflect :

  1. The ReceivingContentHandler being assigned as Contenthandler on the XMLReader

  2. The call to close the result stream

  3. The sax events being fired after the call to close()


Files

ContentHandlerForwarder.java (2.78 KB) ContentHandlerForwarder.java Aniruddha Joag, 2017-05-25 17:44
NonCloseFileOutputStream.java (759 Bytes) NonCloseFileOutputStream.java Aniruddha Joag, 2017-05-25 17:44
Program.java (3.11 KB) Program.java Aniruddha Joag, 2017-05-25 17:44
PseudoXMLReader.java (1.07 KB) PseudoXMLReader.java Aniruddha Joag, 2017-05-25 17:44
RowXMLReader.java (1.87 KB) RowXMLReader.java Aniruddha Joag, 2017-05-25 17:44
RowXMLReader.java (1.86 KB) RowXMLReader.java Aniruddha Joag, 2017-06-01 16:53
ContentHandlerForwarder.java (3.49 KB) ContentHandlerForwarder.java Aniruddha Joag, 2017-06-01 16:53
NonCloseFileOutputStream.java (895 Bytes) NonCloseFileOutputStream.java Aniruddha Joag, 2017-06-01 16:53
Program.java (3.62 KB) Program.java Aniruddha Joag, 2017-06-01 16:53
PseudoXMLReader.java (1.43 KB) PseudoXMLReader.java Aniruddha Joag, 2017-06-01 16:53
TransformationSequencingXMLReader.java (1.46 KB) TransformationSequencingXMLReader.java Aniruddha Joag, 2017-06-29 11:35
ContentHandlerForwarder.java (5.65 KB) ContentHandlerForwarder.java Aniruddha Joag, 2017-06-29 11:35
Program.java (3.75 KB) Program.java Aniruddha Joag, 2017-06-29 11:35
Transformation.java (1.03 KB) Transformation.java Aniruddha Joag, 2017-06-29 11:35
RowXMLReader.java (1.86 KB) RowXMLReader.java Aniruddha Joag, 2017-06-29 11:35

Please register to edit this issue

Also available in: Atom PDF