[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Recursio and filepathstripping...

Subject: Recursio and filepathstripping...
From: Jukka.T.Lehtinen@xxxxxxxxx
Date: Mon, 19 Feb 2001 14:56:29 +0200
recursio
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.