Solved

XSLT: Substring filename

Posted on 2006-06-12
1
528 Views
Last Modified: 2008-03-17
We've a complete filepath:

file://filer12/group/IT/MCU/css/initialize_ns4.css

We need to get ONLY the filename by means of XSL (initialize_ns4.css). How to?
0
Comment
Question by:go4java
1 Comment
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 16887093
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:call-template>
    </xsl:template>
    <xsl:template name="stripPath">
        <xsl:param name="path"/>
        <xsl:choose>
            <xsl:when test="not(contains($path, '/'))"><xsl:value-of select="$path"/></xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="stripPath">
                    <xsl:with-param name="path" select="substring-after($path, '/')"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
   
</xsl:stylesheet>

Cheers!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now