This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Recursio and filepathstripping...
- To: xsl-list at lists dot mulberrytech dot com
- Subject: [xsl] Recursio and filepathstripping...
- From: Jukka dot T dot Lehtinen at nokia dot com
- Date: Mon, 19 Feb 2001 14:56:29 +0200
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi all...
I'm having filepath in one attribute (e.g.
source="result\test\tomorrow\now.txt" or source="test\file.gif") and I need
that "now" or "file" infrormation from that source attribute.
So I tryed to do thos recursive (because I cannot know how long (or deep)
the path is):
cut ---------------8<--------------8<----------
<xsl:template name="attributes"> <!-- This is called from some element,
where I need that function-->
<xsl:variable name="identifiir" > <!-- I try to get that filename to
variable so that I can use it later -->
<xsl:call-template name="identifierrip"> <!-- sorry about my funny
names.. Identifier Rip :) -->
<xsl:with-param name="source" select="@source" /> <!-- give ripper
path where identifier is located-->
</xsl:call-template>
</xsl:variable>
<xsl:attribute name="file"><xsl:value-of select="$identifiir"
/></xsl:attribute>
</xsl:template>
<xsl:template name="identifierrip">
<xsl:param name="source" />
<xsl:variable name="sourcevariable" select="substring-before($source,
'.')" /> <!-- file extension is cutted out -->
<xsl:choose>
<xsl:when test="contains($sourcevariable, '/')">
<xsl:variable name="sourcevariable2"
select="substring-after($sourcevariable, '/')" />
<xsl:call-template name="identifierrip"> <!-- there I try to do
'ripping' again -->
<xsl:with-param name="source" select="$sourcevariable2" />
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($sourcevariable, '\')">
<xsl:variable name="sourcevariable2"
select="substring-after($sourcevariable, '\')" />
<xsl:call-template name="identifierrip">
<xsl:with-param name="source" select="$sourcevariable2" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="dino" select="substring-before($source, 'x')"
/>
<xsl:value-of select="$dino" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
cut ---------------8<--------------8<----------
Why this doesn't work ?
>From "result\test\tomorrow\now.txt" I get "test\tomorrow\now" ???
It works half way, but this recursion thing doesn't give any life signs.
How should I do this right ?
Thanks in advance.
Jukka Lehtinen
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list