DataPower

DataPower

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Remove xsl declaration from SFTP file using xslt

  • 1.  Remove xsl declaration from SFTP file using xslt

    Posted Mon September 13, 2021 09:45 AM

    Dear,

    We are getting xml declaration in xml file when we send to SFTP.

    we are using url-open in xslt to send file.

    Thanks



    #DataPower
    #Support
    #SupportMigration


  • 2.  RE: Remove xsl declaration from SFTP file using xslt

    Posted Mon September 13, 2021 12:31 PM

    Dear Hermann,

    Please help



    #DataPower
    #Support
    #SupportMigration


  • 3.  RE: Remove xsl declaration from SFTP file using xslt

    Posted Tue September 14, 2021 05:06 AM

    Hi,

    can you please share your XSLT?

    --HP



    #DataPower
    #Support
    #SupportMigration


  • 4.  RE: Remove xsl declaration from SFTP file using xslt

    Posted Tue September 14, 2021 05:19 AM

    Dear,

    below xslt:



    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 

      xmlns:dp="http://www.datapower.com/extensions"

      xmlns:regexp="http://exslt.org/regular-expressions" 

    extension-element-prefixes="dp regexp"

      exclude-result-prefixes="dp regexp"

    version="2.0"

    xmlns:apim="http://www.ibm.com/apimanagement" 

    >

      <xsl:output method="xml" omit-xml-declaration="yes"/>

       

      

     

      

     <xsl:strip-space elements="*"/> 

      

       <xsl:template match="/">

      

      <xsl:variable name="onRequest">

           <xsl:copy-of select="."/>

      </xsl:variable>


      

      

      

     <xsl:variable name="ClientDt" select="apim:getVariable('message.headers.ClientDt')" />

      

      

      

      <xsl:variable name="path">

          <xsl:text>/usr/data/input/das</xsl:text>

      </xsl:variable>

      

      

      

    <xsl:variable name="Mqreq">

    <xsl:value-of select="concat($path,$ClientDt,'.xml')" />

    </xsl:variable>


    <xsl:variable name="filename">

    <xsl:value-of select="concat($MsgCode,$ClientDt,'.xml')" />

    </xsl:variable>

      

      

      <xsl:message dp:priority="error">Requ == : <xsl:value-of select="$myvar"/></xsl:message>

      <xsl:message dp:priority="error">mqreq == : <xsl:value-of select="$Mqreq"/></xsl:message>

    <xsl:message dp:priority="error">filename == : <xsl:value-of select="$filename"/></xsl:message>

    <xsl:message dp:priority="error">test == : <xsl:value-of select="$test"/></xsl:message>

     

      

      

      <xsl:variable name="encode">

         <xsl:value-of select="dp:encode($onRequest,'base-64')"/>

      </xsl:variable>

      

      

    <xsl:variable name="username" select="'apic'" />

    <xsl:variable name="password" select="'3edc$RFV21'" />

    <xsl:variable name="encodedusername" select="dp:encode($username,'url')" />

    <xsl:variable name="encodedpassword" select="dp:encode($password,'url')" /> 

    <xsl:variable name="BacksideFTP" select="concat('sftp://',$encodedusername,':',$encodedpassword,'','10.10.10.10:22',$Mqreq)"/>

    <xsl:message dp:priority="error">BacksideFTP == : <xsl:value-of select="$BacksideFTP"/></xsl:message>

    <xsl:variable name="response">

    <dp:url-open target="{$BacksideFTP}" response="ignore" data-type="text" content-type="text/text">

    <xsl:copy-of select="*"/>

    </dp:url-open> 

    </xsl:variable> 



      </xsl:template>

    </xsl:stylesheet>





    #DataPower
    #Support
    #SupportMigration


  • 5.  RE: Remove xsl declaration from SFTP file using xslt

    Posted Wed September 15, 2021 06:49 AM

    Dear Hermann,


    Any suggestion



    #DataPower
    #Support
    #SupportMigration


  • 6.  RE: Remove xsl declaration from SFTP file using xslt

    Posted Wed September 15, 2021 10:16 AM

    Not trying to answer on Hermann's behalf but my suggestion for a quick fix would be to drop the url-open and use a results action after the xform action. Remove url-open, put the ftp url to a context variable and then add a second results action to the flow that uses the context variable as the target address. And then from the results action advanced view change output type to binary.


    --HP



    #DataPower
    #Support
    #SupportMigration