472,353 Members | 2,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

XSL count specific characters in string

Hi -

Using XSL I need to count the number of times character appears in a
string. My guess is I need to recurse through the value of x, but I'm
having trouble getting my head around the solution. In the example
below I'd like to count the number of '-' in x and write the sum to y.
<x>10-10-10</x>
<x>10-10-100</x>
<x>10-100-10</x>
<x>10-10</x>
<x>10-10-10-100</x>

<y>2</y>
<y>2</y>
<y>2</y>
<y>1</y>
<y>3</y>
Can anyone point me in the right direction?

Thanks,

Jerry

Jul 20 '05 #1
2 15539
Tempore 03:42:58, die Thursday 13 January 2005 AD, hinc in foro {comp.text.xml} scripsit Jerry <jo******@jerryo.com>:

Using XSL I need to count the number of times character appears in a
string. My guess is I need to recurse through the value of x, but I'm
having trouble getting my head around the solution. In the example
below I'd like to count the number of '-' in x and write the sum to y.


If the string to search for contains only one character, like in your example, you might use this:

<xsl:template match="x">
<y><xsl:value-of select="string-length(.)-string-length(translate(.,'-',''))"/></y>
</xsl:template>

regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Vincit omnia simplicitas
Keep it simple
Jul 20 '05 #2
Joris -

This is perfect and very clever.

Much thanks,

Jerry Orabona

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Martin Nadoll | last post by:
Hello, I am working on a form-validation script. There is a input-field where you input a float or integer numper (maximum price to output in...
10
by: Jon | last post by:
I want to count the number of instances of a certain string(delimiter) in another string. I didn't see a function to do this in the framework (if...
3
by: Dana King | last post by:
I'm looking for some other developers opinions, I'm trying to find the best way to count strings within a string using VB.net. I have tested five...
5
by: fressanme | last post by:
im trying to create this crossout puzzle generator..ill try to upload my code later since i dont have it at the moment..but the problem im trying to...
6
by: bgeyer14 | last post by:
Hello I am writing a program that I have gotten stuck on. I have gotten the characters to show but don't know how to do and get the vowels and...
12
by: KWSW | last post by:
Got this assignment due a few weeks later and since I am done with the up coming assignment, decided to try out the next one early rather than rush...
5
by: Dean | last post by:
Hi, I have a table with non-unique identifiers. I need to take all the values with the same ID's and combine them into one field with a semicolon...
3
by: waynejr25 | last post by:
can anyone debug my program and get it to run. #include <fstream> #include <iostream> #include <string> #include <cstdlib> #include...
3
by: cppman | last post by:
Hello, I am very new to C++ programming. I am trying to read a file with very large strings back to back, no commas or any other seperations...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.