Hello,
I am stumped and need some help.
I want to know how you can count the number of certain character
inside one element.
For example, counting commas.
<place>CA,USA</placeshould return 1
<place>Los Angeles,CA,USA</placeshould return 2
<place>90210,Los Angeles,CA,USA</placeshould return 3 7 2599
Use XSLT's string-manipulation functions. You may also have to write a
recursive template to iterate through the string.
--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
In article <11**********************@y5g2000hsa.googlegroups. com>,
anitawa <an*****@gmail.comwrote:
>I want to know how you can count the number of certain character inside one element.
For example, counting commas.
<place>CA,USA</placeshould return 1
<place>Los Angeles,CA,USA</placeshould return 2
<place>90210,Los Angeles,CA,USA</placeshould return 3
Ok, here's a disgusting hack:
string-length(.)-string-length(translate(., ',', ''))
-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Richard Tobin <ri*****@cogsci.ed.ac.ukwrote in
<f1**********@pc-news.cogsci.ed.ac.uk>:
In article
<11**********************@y5g2000hsa.googlegroups. com>,
anitawa <an*****@gmail.comwrote:
>>I want to know how you can count the number of certain character inside one element.
Ok, here's a disgusting hack:
string-length(.)-string-length(translate(., ',', ''))
Looks elegant and not at all disgusting to me. Better than
coding a D&C named template to do something this trivial,
anyway.
--
Pavel Lepin
Pavel Lepin wrote:
Richard Tobin <ri*****@cogsci.ed.ac.ukwrote in
>Ok, here's a disgusting hack: string-length(.)-string-length(translate(., ',', ''))
Looks elegant and not at all disgusting to me. Better than
coding a D&C named template to do something this trivial,
anyway.
I agree; that's a good solution to the comma-counting problem.
(Cue the music: "Comma, comma, comma, Camellia; you come and go..."
Though I have to admit I spent years wondering what a "karma chameleon"
was.)
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Joe Kesselman <ke************@comcast.netwrote in
<tp******************************@comcast.com>:
Pavel Lepin wrote:
>Richard Tobin <ri*****@cogsci.ed.ac.ukwrote in
>>Ok, here's a disgusting hack: string-length(.)-string-length(translate(., ',', ''))
Looks elegant and not at all disgusting to me. Better than coding a D&C named template to do something this trivial, anyway.
I agree; that's a good solution to the comma-counting
problem.
(Cue the music: "Comma, comma, comma, Camellia; you come
and go..." Though I have to admit I spent years wondering
what a "karma chameleon" was.)
I always thought it was 'come a million', which usually made
me, well, a bit uneasy just thinking about it. But then, my
English listening comprehension ain't anything I'd
call 'good' even now, and it was even worse those days.
--
Pavel Lepin
Joe Kesselman wrote:
Pavel Lepin wrote:
>Richard Tobin <ri*****@cogsci.ed.ac.ukwrote in
>>Ok, here's a disgusting hack: string-length(.)-string-length(translate(., ',', ''))
Looks elegant and not at all disgusting to me. Better than coding a D&C named template to do something this trivial, anyway.
I agree; that's a good solution to the comma-counting problem.
(Cue the music: "Comma, comma, comma, Camellia; you come and go..."
Though I have to admit I spent years wondering what a "karma chameleon"
was.)
I must be very warped. I got it first time I heard it.
///Peter
Peter Flynn <pe********@m.silmaril.iewrote in
<5a*************@mid.individual.net>:
Joe Kesselman wrote:
>Pavel Lepin wrote:
>>Richard Tobin <ri*****@cogsci.ed.ac.ukwrote in Ok, here's a disgusting hack: string-length(.)-string-length(translate(., ',', ''))
Looks elegant and not at all disgusting to me. Better than coding a D&C named template to do something this trivial, anyway.
I agree; that's a good solution to the comma-counting problem.
I must be very warped. I got it first time I heard it.
By the way, just to let you know, the OP is quite grateful
for the solution. It's just that for some reason instead of
expressing his gratitude to you on the group, he expressed
his gratitude to you in my mail:
On Thursday 10 May 2007 22:15, you wrote:
[...]
Thats exactly what i was looking for.
Thanks a lot!
--
Pavel Lepin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Brett conklin |
last post by:
I would like to not use the google groups as a crutch in my XSLT
journey. What is the best xslt reference out there? Is it a book? Is
it a web site? I am finding that I can come up with nearly...
|
by: Jeff Rubard |
last post by:
I am curious to know whether anyone has experience using XSLT for
web XML (non-XHTML) styling, either with CSS or standalone. I
myself have engaged in rather unsuccessful experiments with the...
|
by: el_bandido |
last post by:
Hello,
I've tried the FAQ and some minutes in googl'ing but was not happy with
what I got. Basically I'd like to get a _simple_ example on how I could
create a web based (portable across all...
|
by: Mark |
last post by:
I must say that I'm quite the newb with XML/XSLT. I kind of stubmled
upon using it for a report I'm trying to make. If someone would be so
kind as to help out with the following I would be...
|
by: sam |
last post by:
Hi, I've been buried in xsl and xslt articles for several days now, and am
still unsure as to what I need to do...
Basically, my vb.net app loads up an XML file from an external source...
|
by: Gauthier |
last post by:
Hi, I've a simple issue with the use of extension objects.
I'm trying to call a text formating method from an object that I add to
my arguments collection, this method take an input string and...
|
by: Christopher |
last post by:
I am currently in the process of evaluating the performance hits of moving
to the .NET platform for our application. I created a sample project that
loads the transforms the same XML and XSLT in...
|
by: Sergey Dubinets |
last post by:
In effort to prioritize our goals we composed the list of random features
each of them may add value to set of XSLT tools offered from Microsoft.
1. XSLTc (Compiler for XSLT...
|
by: Yarik |
last post by:
Hello,
I am not sure the subject of my post adequately describes the problem I
am trying to solve, so I think a specific example would be helpful.
Let's say there are XML descriptions of...
|
by: yinglcs |
last post by:
Hi,
I have a newbie XSLT question. I have the following xml, and I would
like to
find out the children of feature element in each 'features' element.
i.e. for each <featuresI would like to...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |