FileToBase64
Version 7.1 by Outhman Moustaghfir on 2023/07/24 14:52
FileToBase64
This function encodes a file into Base64 format.
Uses
The syntax to be used : AddFileConnector({connectorAlias} , {sensType}, {fileType})
where :
- connectorAlias: the alias used in the scenario to define a connector. (SplitXML1 , AlertJob2 ...)
- sensType: input or output files ( IN or OUT ), it's optional and takes as default value ANY.
- fileType: EDI, Format, StyleSheet ...
Examples
In this example, we send an XML file and try to encode a file.
the XSL used :
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:ixf="http://www.ixPath.com/Function" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ix="localFunction" xmlns:fn="http://www.w3.org/2005/xpath-functions" >
<xsl:output method="xml" indent="yes"/>
<!-- Beginning of the Translation -->
<xsl:template match="/">
<ixDOC>
<TEST><xsl:value-of select="ixf:FileToBase64('FtpListener1')"/></TEST>
</ixDOC>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:ixf="http://www.ixPath.com/Function" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ix="localFunction" xmlns:fn="http://www.w3.org/2005/xpath-functions" >
<xsl:output method="xml" indent="yes"/>
<!-- Beginning of the Translation -->
<xsl:template match="/">
<ixDOC>
<TEST><xsl:value-of select="ixf:FileToBase64('FtpListener1')"/></TEST>
</ixDOC>
</xsl:template>
</xsl:stylesheet>
Upon execution, a file is generated, containing the encoded value of the file in base 64 format, enclosed within the 'TEST' tag
<?xml version="1.0" encoding="UTF-8"?>
<ixDOC xmlns:ixf="http://www.ixPath.com/Function"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ix="localFunction"
xmlns:fn="http://www.w3.org/2005/xpath-functions">
<TEST>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCg0KICAgPGl4RG9jPg0KICAgIA0KCQ0KCTxNZXNzYWdlIHNlbGVjdD0gIkEubnVtYmVyLEMuTkFNRSBBUyBuYW1lc3RlLEIuTkFNRSBBUyBuYW1lY2xpZW50LCBBLnNvdXJjZSwgQS5jcmVhdGVkICwgRC5zdWJqZWN0ICIgICANCgkgICAgICAgICBmcm9tID0ib3N0X3RpY2tldCBBIEpPSU4gb3N0X3VzZXIgQiBKT0lOIG9zdF9vcmdhbml6YXRpb24gQyBKT0lOIG9zdF90aWNrZXRfX2NkYXRhIEQiIA0KCSAgICAgICAgIHdoZXJlPSIoKEIuaWQ9QS51c2VyX2lkKSBhbmQgKEIub3JnX2lkPUMuaWQpKWFuZCAoRC50aWNrZXRfaWQgPSBBLnRpY2tldF9pZCkgIg0KCSAgICAgICAgID4NCgkNCgk8L01lc3NhZ2U+DQoJDQogIDwvaXhEb2M+</TEST>
</ixDOC>
<ixDOC xmlns:ixf="http://www.ixPath.com/Function"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ix="localFunction"
xmlns:fn="http://www.w3.org/2005/xpath-functions">
<TEST>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCg0KICAgPGl4RG9jPg0KICAgIA0KCQ0KCTxNZXNzYWdlIHNlbGVjdD0gIkEubnVtYmVyLEMuTkFNRSBBUyBuYW1lc3RlLEIuTkFNRSBBUyBuYW1lY2xpZW50LCBBLnNvdXJjZSwgQS5jcmVhdGVkICwgRC5zdWJqZWN0ICIgICANCgkgICAgICAgICBmcm9tID0ib3N0X3RpY2tldCBBIEpPSU4gb3N0X3VzZXIgQiBKT0lOIG9zdF9vcmdhbml6YXRpb24gQyBKT0lOIG9zdF90aWNrZXRfX2NkYXRhIEQiIA0KCSAgICAgICAgIHdoZXJlPSIoKEIuaWQ9QS51c2VyX2lkKSBhbmQgKEIub3JnX2lkPUMuaWQpKWFuZCAoRC50aWNrZXRfaWQgPSBBLnRpY2tldF9pZCkgIg0KCSAgICAgICAgID4NCgkNCgk8L01lc3NhZ2U+DQoJDQogIDwvaXhEb2M+</TEST>
</ixDOC>