[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Getting text from string


Subject: Re: [xsl] Getting text from string
From: Stan Mikita <markev8@xxxxxxxxx>
Date: Thu, 3 Nov 2011 12:28:20 -0400

I used the following:

<xsl:variable name="varPath" select="string-join(tokenize(@path,
'/')[position() ne last()], '/')"/>


On Thu, Nov 3, 2011 at 8:21 AM, Andrew Welch <andrew.j.welch@xxxxxxxxx>
wrote:
> On 3 November 2011 12:04, Stan Mikita <markev8@xxxxxxxxx> wrote:
>> Thanks!
>>
>> Is it also possible to use the tokenize to retrieve the following?
>>
>> Input: @path = "dir1/dir2/dir3/dir4/filename"
>>
>> Output: @path = "dir1/dir2/dir3/dir4"
>
> Yep, tokenize(@path, '/') will return a sequence of strings, 'dir1',
> 'dir'2 etc, everything except the string used to split them.
>
> You can then rejoin them using string-join($tokens[position() ne last()],
'/')
>
>
> --
> Andrew Welch
> http://andrewjwelch.com


Current Thread