[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Splitting file into N-sized chunks

Subject: RE: Splitting file into N-sized chunks
From: "Houghton,Andrew" <houghtoa@xxxxxxxx>
Date: Tue, 4 Aug 2009 17:29:47 -0400
RE:  Splitting file into N-sized chunks
> From: Martynas Jusevicius [mailto:martynas.jusevicius@xxxxxxxxx]
> Sent: Tuesday, August 04, 2009 5:10 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  Splitting file into N-sized chunks
>
> 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?

If you are using Saxon you can use the saxon:string-to-utf8(), but that
assumes that your XHTML output encoding is going to be UTF-8.  If your
XHMTL output encoding is going to be UTF-16, then you probably can use
the XSLT string-length() function.

If you are not using Saxon, but using XSLT 2, you can use the XSLT
string-to-codepoints() function and calculate the UTF-8 length based on
the codepoints.  I did that for a project back a while ago that wasn't
using Saxon.

Everytime you output a tag, whitespace or text you will have to keep
track of its length.  Since you will always have a static XHTML header
and footer that wraps your content, you might pre-calculate that length
rather than calculate it on the fly.


Hope this helps, Andy.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.