I have a HTML file I want to parse using XSLT 1.0
the file is in the form <file name="/var/application-data/..../application/controllers/cgu.php" />
and I want it to be
<file filename="cgu.php" folderName="controller/"/>
I managed to do this using <xsl:value-of select="substring-before(substring(@name, 85), '/')"/>
, but I want it to work for all length of path.
is it possible to count the number of occurences of "/" to retrieve only the last part of the path ?
I used a recursive template to retrieve only the filename, but I need the folder name too
<xsl:template name="substring-after-last">
<xsl:param name="string"/>
<xsl:choose>
<xsl:when test="contains($string, '/')">
<xsl:call-template name="substring-after-last">
<xsl:with-param name="string" select="substring-after($string, '/')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>