Hi All,
We have been trying multiple times to create a dynamic folder in sftp server using XSLT, not able to get that. Kindly help me on this with some links or explantion , Immediate responses would be grateful as i am reaching a target date delivery.
Tried This: 1
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dp="http://www.datapower.com/extensions"
extension-element-prefixes="dp"
exclude-result-prefixes="dp">
<xsl:template match="/">
<xsl:variable name="currentDate" select="dp:date('yyyyMMdd')"/>
<dp:set-variable name="'var://context/backend/router'" value="concat('sftp://192.168.1.199:22/home/bandaru/Documents/standard-test/envivar/', $currentDate, '/')"/>
</xsl:template>
</xsl:stylesheet>
Tried This :2
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
xmlns:dp="http://www.datapower.com/extensions"
extension-element-prefixes="dp">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<!-- Create a date-based folder name (e.g., 20241104) -->
<xsl:variable name="current-date" select="dp:format-dateTime(dp:dateTime(), '[Y0001][M01][D01]')" />
<xsl:variable name="folder-name" select="concat('folder_', $current-date)" />
<!-- Construct the SFTP URL to create the directory -->
<!-- Replace 'username', 'password', 'sftp-server' and 'basepath' with your actual server details -->
<xsl:variable name="sftp-url" select="concat('sftp://bandaru:sarasu10@192.168.1.199:22/home/bandaru/Documents/standard-test/envivar/', $folder-name, '/')" />
<!-- Attempt to create the folder by sending a URL open command -->
<xsl:variable name="result" select="dp:url-open($sftp-url, 'POST')" />
<!-- Output the Result -->
<Result>
<Status>
<xsl:value-of select="$result"/>
</Status>
<FolderName>
<xsl:value-of select="$folder-name"/>
</FolderName>
</Result>
</xsl:template>
</xsl:stylesheet>
Upender Kuncham