[xsl] Xalan: Pagination of transformation output

Subject: [xsl] Xalan: Pagination of transformation output
From: "Andrew andrew.hallam@xxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 21 Sep 2015 10:49:30 -0000
Hi all.
Im looking for advice on paginating the output of a transformation.
Some of the XML documents we pass through our transformations produce very
large HTML output.  We would like to paginate this output.
We cannot split the source XML into manageable chunks and process them
individually.  It has to be transformed as a whole (// matches etc).
Currently the transformation produces a valid block of HTML - not the whole
HTML page.  This is then poked into the main page via Ajax.
I was thinking of wrapping the FileOutputStream of the transformation with a
stream to monitor the size of HTML output so far so as to know when my 'chunk'
size limit is reached.
Obviously the output HTML 'chunk' needs to be valid HTML.

Some initial thoughts on this:I would need a stack of somekind to keep track
of what HTML elements have already been output so as to be able to close them
off (and re-open them for that matter). I.e div within a div within a
div...Our transformation output is quite 'clean', mainly div's etc but there
are HTML tables - would probably not split tables due to headings etc (and
would generally look bad/be confusing I think).
I'm not sure if this is achievable just via monitoring the output stream
though.  Maybe I will need to hook into the actual transformation events
themselves so as to know where I am in the document.Think TransformerHandler
might be able to help me here... This gives me startElement, endElement,
characters listener events.
Would just like to put this interesting problem to the floor for any
suggestions.
Many thanks

Current Thread