This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: substrings and identical numbers


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]