Jump to content

string parsing


rnv

Recommended Posts

Hi,it must be simple but I cannot get it.. hope some one can help. I have a complete file path. from it i need to get the file name.e.g., c:\data\xxx\filename.docfrom above string I need to get filename. which string function(s) allows me to get it?I thought of using last-index-of(..) but it does not exist in xslt. will appreciate your help. with regards,rnv

Link to comment
Share on other sites

Well the current version of XSLT and XPath is the version 2.0 so with that version respectively if you use an XSLT 2.0 processor you can do e.g.

<xsl:variable name="path">c:\data\xxx\filename.doc</xsl:variable><xsl:variable name="file-name" select="tokenize($path, "\\")[last()]"/>

That way the variable "file-name" is of type string with the value "filename.doc".With an XSLT 1.0 processor you will need to check whether an extension like http://www.exslt.org/str/functions/tokenize/index.html is supported or you can make use of callable templates like in http://www.dpawson.co.uk/xsl/sect2/N7240.html#d10127e349.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...