This advanced converter workflow component can transform the XML payload with an XSL transformation.
The transformation can also be combined with a split in the Transform or split component.
The XSL transformation workflow component has these parameters:
You should only refer to either a transform stylesheet or a transform design.
Transform stylesheet
Here you can specify an xslt stylesheet to transform the input XML file. If a split XPath path has also been specified, then the input file will be split up prior to this transformation, so any lost header nodes (specified in a Split XPath above) cannot be added with this functionality.
You need to load the stylesheet into the transforms folder of the InterFormNG2 library. You can click on the line or the magnifying glass to select a fixed style sheet. You can also click this icon:
To select a dynamic transform style sheet file via an XPath expression.
One way to test and debug an xslt stylesheet is e.g. via an online tool like this: https://www.freeformatter.com/xsl-transformer.html
Remember however never to upload any confidential data to any online tool like this.
Transform design
This is an alternative to a normal xslt stylesheet. You can design your own transformations in a user friendly transformation designer. Such transformations can be referred to here.
A simple example of how to add extra conditioned nodes in an XML file via an xslt transformation is found in the section: Examples of simple XSLT transformations.
An example of how a transform can be used together with a split is included here.
You can also use workflow variables in an XSLT file e.g. to insert base64 data into an XML file. You can convert a file into base64 encoding with the workflow component, To base64 and then run a transformation like this:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:param name="Base64" />
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/Root/CompanyInfo">
<xsl:copy>
<xsl:copy-of select="node()"/>
<PDF_Base64><xsl:value-of select="$Base64" /></PDF_Base64>
<ReturnCode>OK</ReturnCode>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Please notice, that the workflow variable must be defined as so:
<xsl:param name="Base64" />
(This defines a variable called Base64).
In this line the value of the variable, Base64 is inserted into the node, PDF_Base64.
You can merge two XML files together, if you first insert one XML into a variable and then use an XSL transformation to insert the contents of the variable into the main XML file. Such an example is seen below, where the workflow variable, VarWithXML has been filled with the contents of an XML file e.g. with the workflow component, From file to workflow variable or with the component, Resource to workflow variable:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:param name="VarWithXML" />
<xsl:template match="/">
<root>
<xsl:copy-of select="fn:parse-xml($VarWithXML)" />
<xsl:copy-of select="form" />
</root>
</xsl:template>
</xsl:stylesheet>
If you want to sort an XML file, then you should refer to this section.