[xsl] remove relative path

Subject: [xsl] remove relative path
From: "Gav...." <brightoncomputers@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 17 May 2006 07:31:07 +0800
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...

Current Thread