Split and count number of string in xslt 1.0 -


i have strings below,

788565591,1,444,0,15956,555,126.99,15956,666,0,15956,777,101.66,15956 788565591,1,444,0,,555,126.99,,,0,15956,777 

i trying write xslt template find out number of comma's in string. based on count need add/delete few more normalize length 32.

please advice/ give me idea in form of code.

assuming current context node 1 value want process, then

<xsl:variable name="numcommas"               select="string-length() - string-length(translate(., ',', ''))" /> 

would give number of commas in string (literally it's calculating length of string minus length of the-string-with-all-commas-removed). if have variable containing 32 commas (this global variable defined outside templates):

<xsl:variable name="thirtytwocommas"               select="',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,'" /> 

then can take substring($thirtytwocommas, $numcommas + 1) string containing number of commas need add original string make 32. if there's 32 or more commas in original string empty.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -