XSLT Transform
The XSLT Transform task accepts an XML input file and transforms it to another format using an XSL transform file. XSL transforms can be used used to convert an XML file to another XML format, HTML, CSV, plain text and many more formats. You can pass through parameters to the XSLT at runtime if your XSLT file supports this. Please note that the task only supports XSLT 1.0, it does not support XSLT 2.0.
A basic tutorial for writing XSL transforms can be found Create an XSLT File, and more detailed information can be found at W3 Schools. You can find sample XSLT files in our Github repository.
Settings
Enable XSLT Debugging
Optional
Allows the XSLT to be debugged via Visual Studio. You must ensure that the 'Enable Just My Code' setting in the Visual Studio options is not checked, load the XSLT file in Visual Studio, and then attach Visual Studio to the Zynk.exe process. Following which you can place breakpoints in the XSLT file, which will be hit when the Workflow is run.
For a step-by-step guide, please see the XSLT Debugging article.
Input File
Required
The name of the XML file for processing.
Log File
Optional
The file to write any messages generated by the XSLT to. You can generate messages by using the xsl:message element in your XSLT. If you don't provide a log file, messages will still be written as debug messages to the logs in Zynk (if debug logging is enabled).
Output File
Required
The name of the resulting processed file.
Parameters
Optional
A collection of parameters to be passed into the XSLT for processing. This is typically used for user defined data such as Company Name and Address when using a common XSLT file such as an Invoice.xslt.
XSLT File
Required
The name of the XSLT file to use for processing.
Note
You can use the XSLT functions that are embedded into Zynk Worfklow and XSLT Builder. For more information, see XSLT Functions
Note
If you have the Xslt Builder extension installed, when you click 'Edit' on the Zynk Object form, the Xslt Builder application will launch with your Input File, XSLT File & Output File loaded.
Zynk Settings
Examples
A sample input file is shown below, which is to be converted to another XML format.
<?xml version="1.0"?>
<Company xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<StockTransactions>
<StockTransaction>
<UniqueId>1</UniqueId>
<StockTransactionType>AdjustmentIn</StockTransactionType>
<StockCode>BOARD001</StockCode>
<StockTransactionDate>2006-12-31T00:00:00</StockTransactionDate>
<Reference>STK TAKE</Reference>
<Details>Whiteboard - Drywipe (900 x 1200)</Details>
<Qty>2</Qty>
<CostPrice>15</CostPrice>
<SalesPrice>0</SalesPrice>
<StockTransactionNumber>1</StockTransactionNumber>
</StockTransaction>
</StockTransactions>
</Company>
A sample XSLT file is shown below, which will be used to transform the input file.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<Rows>
<xsl:for-each select="Company/StockTransactions/StockTransaction">
<xsl:call-template name="ProcessRow" />
</xsl:for-each>
</Rows>
</xsl:template>
<xsl:template name="ProcessRow">
<Row>
<Code><xsl:value-of select="StockCode" /></Code>
<Type><xsl:value-of select="StockTransactionType" /></Type>
<Quantity><xsl:value-of select="Qty" /></Quantity>
<Cost><xsl:value-of select="CostPrice" /></Cost>
</Row>
</xsl:template>
</xsl:stylesheet>
The output file is shown below:
<?xml version="1.0" encoding="utf-8"?>
<Rows>
<Row>
<Code>BOARD001</Code>
<Type>AdjustmentIn</Type>
<Quantity>2</Quantity>
<Cost>15</Cost>
</Row>
</Rows>