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

parsing a long string into chunks

Subject: parsing a long string into chunks
From: "Tim Wilkins" <Tim.Wilkins@xxxxxxxxxxxxxxxx>
Date: Thu, 10 Apr 2003 17:32:08 +0100
parse string to long
I have input data of the form
<coordinates>x1,y1 x2,y2 x3,y3</coordinates>
e.g.
<coordinates>10,10 10,20 20,20</coordinates>
There can be any number of space-delimited substrings.  At present this is
parsed using substring-before and substring-after with a recursive template,
to generate a sequence of elements <Point X="10" Y="10"/> etc.
Unfortunately this can sometimes be slow for long lists (by which I mean
5000 or so x,y pairs).  In addition I have to divide up the resultant list
of elements into chunks (to avoid exceeding a limit on the number of points
in a line), although this can easily be done on a second pass (it's then a
similar problem to splitting up for a table with a given number of columns).

i.e. I want

<coordinates>x1,x2 ...

to become someething like (ignoring attributes for simplicity!)

<Polyline>
<Point><Point><Point><Point>
</Polyline>
<Polyline>
<Point><Point><Point><Point>
</Polyline>

Can anyone think of a better way, especially a way of splitting up without
the need for a second pass?  What I'd really like is a trivial way to make
xsl treat the string as a node list split at whitespace, but I suspect that
that isn't possible!

Tim


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.