Search code examples
xmlfilexslttexttrim

XSLT How to select files and remove some character from filename?


I'm wondering how can I remove/trim some character from filename in XSLT ,Infact I have to do some arithmetic process on my files and the key is the filename,but there are some files which have'text' before.. for example I have : sdx.doc sdx43.doc textsdx.doc ----> I want to trim text from file name and continue the process as --> sdx.doc

substring-after(filename, 'text')


Solution

  • I don't see what your XSLT code has to do with your question. If you have a filename such as:

    <filename>textsdx.doc</filename>
    

    use:

    substring-after(filename, 'text')
    

    to get:

    "sdx.doc"
    

    If you don't know which filenames to apply this to, select them by an expression such as:

    filename[starts-with(., 'text')]