xsl-list
[Top] [All Lists]

[xsl] remove relative path

2006-05-16 16:38:21
Hi All, 

I have looked through the list, archives etc and come up some code based on
what I summized from it, but of course it does not work.

For an OS project, I'm trying to remove all ../ from the supplied @src path.
Obviously they can be nested values too such as  ../../../

So I need to remove all these leaving just the filename. (I can then prepend
A predetermined path onto it.)

I have a template :-

<xsl:template name="removedotdots">
          <xsl:param name="path"/>
          <xsl:variable name="removedirs"
select="substring-after(string($path),'../')"/>
          <xsl:variable name="removeagain"
select="starts-with(string($removedirs),'../')"/>
          <xsl:if test="$removeagain">
                  <xsl:call-template name="removedotdots">
                          <xsl:with-param name="path"
select="substring-after(string($removedirs),'../')"/>
                  </xsl:call-template>
          </xsl:if>
          </xsl:template>

And the calling code :-

        <xsl:variable name="path" select="@src"/>
                <xsl:call-template name="removedotdots">
                        <xsl:with-param name="path" select="$path"/>
                </xsl:call-template>

However the @src is either not coming in or the altered path not
Coming out, my fo ends up

<fo:external-graphic src=""/>

So I'm not getting a value. Been scratching my head and trying some
Alterations and scratching my head again. Would appreciate a 
Pointer as to something I have missed.

Thanks

Gav...



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>