Please enable JavaScript to view this site.

InterFormNG Manual 2020

You can define the transformation/split via an XSLT. The stylesheet is called once for each detail branch (the exact path of the branch was defined earlier) and a detail branch (Split Xpath expression). In short the detail branch is the ‘trigger’ for the split - each branch will trigger a new XML file. The branch is transferred as a parameter with the name: “detail”, so you need to define this parameter in the stylesheet:

 

<xsl:param name="detail"/>

 

In the stylesheet you can then refer to the value of this parameter as: “$detail”. We will use this parameter to insert the detail branch when building up the structure of the new XML files.

 

 

A stylesheet could be like this:

 

<?xml version="1.0" encoding="UTF-8"?>

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

 <xsl:param name="detail"/>

 <xsl:template match="/">

         <order>

                 <xsl:copy-of select="/orders/header"/>

                 <xsl:copy-of select="/orders/footer"/>

                 <xsl:copy-of select="$detail/parent::*/customernumber"/>

                 <xsl:copy-of select="$detail"/>

         </order>

 </xsl:template>

</xsl:stylesheet>

 

The first two lines defines the stylesheet and the 3rd line defines the parameter, detail.

Lines 4-11 retrieves the header, footer and customer number from the input XML file and stores them in the new xml file(s).

 

Next the new XML file is defined by copying the complete branches and inserting them in the structure as we want.

 

Before you use xslt you make yourself familiar with the format e.g. via online introductions like:

http://www.w3schools.com/xsl/

 

Here is another helpful site if you want to try out some xslt expressions:

http://codebeautify.org/Xpath-Tester

 

It also includes a lot of Xpath tips.

 

We save the xslt as the file: split_example.xslt in the transform folder within the resource folder. We will use the xslt for advanced transforming below.