XSLT required for placing the files in target directory

76 Views Asked by At

I have a requirement where the source file name is Rocky_InvoiceNo(uniquevalue)_Timestamp.xml..

Target system wants the filename to InvoiceNo(uniquevalue)_Timestamp.xml. Can anyone please share the xslt code to achieve this.

2

There are 2 best solutions below

0
Ajeet Singh On

check this code:-

        <xsl:variable name="outputpath_1" select="substring-after('Rocky_InvoiceNo(uniquevalue)_Timestamp.xml', '_')"/>
    <xsl:value-of select="$outputpath_1"/>
2
michael.hor257k On

The context of your question is not entirely clear.

In general, you can retrieve the filepath of the source XML document using the base-uri() or the document-uri() function, e.g.

<xsl:variable name="source-path" select="base-uri()"/>

Then you can remove the "Rocky_" part of the filename using:

<xsl:variable name="target-path" select="replace($source-path, 'Rocky_', '')"/>

and use the resulting path to create a result document using the xsl:result-document instruction, e.g.

<xsl:result-document href="{$target-path}">
    <!-- your tranformation here -->
</xsl:result-document>

However, IMHO it would be much simpler to perform this task by the application that initiates the XSL transformation instead of in the XSLT stylesheet itself.