Re: [xsl] substrings and identical numbers

Subject: Re: [xsl] substrings and identical numbers
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 9 May 2001 18:48:20 +0100
Hi Tobi,

> <!-- I need to get the first three places. They can be of any
> length. Why does only the second one work like expected? The first
> one doesn't work if the two numbers are the same. (uncomment one
> then the other) -->

Just to explain why the first one doesn't work, take the string:

  a_a_7000_7000

You have the expression:

   substring-before($input,
                    substring-after(
                       substring-after(
                          substring-after($input, '_'), '_'), '_'))

Substituting in the $input:

   substring-before('a_a_7000_7000',
                    substring-after(
                       substring-after(
                          substring-after('a_a_7000_7000', '_'),
                          '_'), '_'))

Evaluating the inner-most substring-after():

   substring-before('a_a_7000_7000',
                    substring-after(
                       substring-after('a_7000_7000', '_'), '_'))

Evaluting the inner-most substring-after():

   substring-before('a_a_7000_7000',
                    substring-after('7000_7000', '_'))

And evaluating that last substring-after():

   substring-before('a_a_7000_7000', '7000')

The substring-before() function finds the first occurrence of the
second argument string in the first argument string, and returns the
string that occurs before it.  The first occurrence of the string
'7000' in the string 'a_a_7000_7000' is the first '7000' in that
string, so the substring-before() is:

  'a_a_'

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



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


Current Thread