• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 560
  • Last Modified:

XSLT: Substring filename

We've a complete filepath:


We need to get ONLY the filename by means of XSL (initialize_ns4.css). How to?
1 Solution
Geert BormansInformation ArchitectCommented:
Hi go4java,

you need to solve that recursively.
you can use this template "stripPath"
(I put it in a test XSL)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
        <xsl:call-template name="stripPath">
            <xsl:with-param name="path">c/blabla/blabla/test.xml</xsl:with-param>
    <xsl:template name="stripPath">
        <xsl:param name="path"/>
            <xsl:when test="not(contains($path, '/'))"><xsl:value-of select="$path"/></xsl:when>
                <xsl:call-template name="stripPath">
                    <xsl:with-param name="path" select="substring-after($path, '/')"/>

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now