Node Functions
Overview
This article explains how to implement node functions in your mapping files when running them in Zynk Workflow.
- Namespace urn:NodeFunctions
- Available Since Zynk Workflow 2.1.4
XSLT
Declaration
To use node functions, you need to add the namespace declaration to your XSLT file:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:NodeFunctions="urn:NodeFunctions"
exclude-result-prefixes="NodeFunctions">
<!-- transformation -->
</xsl:stylesheet>
Functions
- Select
XPathNodeIterator context, string xpath
Example
Input
<?xml version="1.0" encoding="utf-8"?>
<Company>
<Products>
<Product>
<Sku>ABC</Sku>
<Supplier>Bob</Supplier>
<Priority>2</Priority>
</Product>
<Product>
<Sku>ABC</Sku>
<Supplier>Jon</Supplier>
<Priority>3</Priority>
</Product>
<Product>
<Sku>ABC</Sku>
<Supplier>Sam</Supplier>
<Priority>1</Priority>
</Product>
<Product>
<Sku>ZXY</Sku>
<Supplier>Sam</Supplier>
<Priority>1</Priority>
</Product>
<Product>
<Sku>123</Sku>
<Supplier>Bob</Supplier>
<Priority>2</Priority>
</Product>
<Product>
<Sku>123</Sku>
<Supplier>Sam</Supplier>
<Priority>1</Priority>
</Product>
<Product>
<Sku>123</Sku>
<Supplier>Jon</Supplier>
<Priority>3</Priority>
</Product>
</Products>
</Company>
XSLT
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:NodeFunctions="urn:NodeFunctions"
exclude-result-prefixes="NodeFunctions">
<xsl:output indent="yes"/>
<xsl:template match="/Company">
<SampleOutput>
<xsl:variable name="DynamicXPath">Products/Product[Priority=1]</xsl:variable>
<xsl:for-each select="NodeFunctions:Select(., $DynamicXPath)">
<Priority><xsl:value-of select="concat('[', Priority, '] ', Sku)" /></Priority>
</xsl:for-each>
</SampleOutput>
</xsl:template>
</xsl:stylesheet>
Output
<?xml version="1.0" encoding="utf-8"?>
<SampleOutput>
<Priority>[1] ABC</Priority>
<Priority>[1] ZXY</Priority>
<Priority>[1] 123</Priority>
</SampleOutput>