xsl-list
[Top] [All Lists]

RE: [xsl] Splitting file into N-sized chunks

2009-08-04 17:56:46
Well it doesn't have to be exactly 300K, could be less of 
course :) But XHTML needs to be valid.
So any ideas on (roughly) calculating the size? Number of 
characters perhaps?

A lot depends on how far you want to go. If you're prepared to split it at a
boundary between children of the body element, it's not too hard. If you
need to cater for deeply-nested tables, with the possibility of having 500K
of text in a single table cell, then it's much harder.

For the first case, it's a fairly simple exercise in sibling recursion:
write a template that processes the first child of <body>, and then calls
itself to process the next child (following-sibling::*[1]) and so on,
passing the accumulated text size as a parameter, and exiting when this
reaches some threshold.

(I say simple, but I use this as an exercise on XSLT courses and some people
find it very difficult, if they're not used to recursive list processing).

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>