[xslt] XSLT to get certain token from a String list



Dear all,

I have an XML file (part of it) is similar to this:

<data>1 2.1 3.5 4 6 12.0</data>

Now, I am writing an xslt to transform an xml file. I
want to write a xslt to get the certain token from the
above xml data.

As an example: 

xsl:getToekenData($string, $position)

if $string is "1 2.1 3.5 4 6 12.0", and the position
is 2, it will return 2.1. But if the position
specified is 7, it will return "null", as the total
number of token in the string is 6.

Can any one tell me how to implement it. 

It would be very appreciated if some one can drop me
some code here.

The problem here is: 
1) if I specifies a certain position (e.g. position
2), and if I use for-loop with substring in the
template implementation, the xslt will continue to
loop over all the string tokens even if it has found
the right position, which may waste a little time. So
there must be a mechanism to stop the loop when the
position is reached. 

2) if I want to put each token to a html table, then
in order to extract data, template has to go through
the whole string list data one time for each token.
But considering if the list has 100 tokens, it will
parse the list 100 times, which takes a lot of time to
process.  


Many thanks.


__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]