Subject: Re: [xsl] Splitting a relative link in 2 parts From: "Myriam Delperier" <myriam.delperier@xxxxxxxxx> Date: Wed, 21 May 2003 15:01:25 +0200 |
Wolfgang Schreurs wrote: || Could anyone help me with this? I need to split a parameter like: || /careers/sites/en/page.htm || in 2 parts. I want to get the following results: || 1: /careers/sites/en || 2: page.htm || hello, i've tryed this and it seems to work : <xsl:template name="something"> <xsl:param name="parameter" select="''"/> <xsl:variable name="first"> <xsl:call-template name="find-first"> <xsl:with-param name="first" select="$parameter"/> </xsl:call-template> </xsl:variable> <xsl:variable name="second"> <xsl:call-template name="find-second"> <xsl:with-param name="second" select="$parameter"/> </xsl:call-template> </xsl:variable> <xsl:value-of select="concat('1:',$first)"/> <xsl:value-of select="concat('2:',$second)"/> </xsl:template> <xsl:template name="find-first"> <xsl:param name="first" select="''"/> <xsl:choose> <xsl:when test="contains($first,'/')"> <xsl:value-of select="substring-before($first,'/')"/> <xsl:if test="contains(substring-after($first,'/'),'/')"> <xsl:value-of select="'/'"/> </xsl:if> <xsl:call-template name="find-first"> <xsl:with-param name="first" select="substring-after($first,'/')"/> </xsl:call-template> </xsl:when> </xsl:choose> </xsl:template> <xsl:template name="find-second"> <xsl:param name="second" select="''"/> <xsl:choose> <xsl:when test="contains($second,'/')"> <xsl:call-template name="find-second"> <xsl:with-param name="second" select="substring-after($second,'/')"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$second"/> </xsl:otherwise> </xsl:choose> </xsl:template> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Splitting a relative link in , Wolfgang Schreurs | Thread | Re: [xsl] Splitting a relative link, Wolfgang Schreurs |
RE: [xsl] [OT] Can XML elements con, David Neary | Date | Re: [xsl] [OT] Can XML elements con, Simon Kelly |
Month |