Creating the simple links
Now, when both source and target models are ready, we can continue.
We’ll start with the “simple links” – very, well, primitive 🙂 technique, which “explains” to the translator how to create the target document using the source data. Usually, the simple links are used in very simple cases – when the target structure is similar to the source.
Our example is pretty obvious – the data from Line Item ID, Quantity, Unit Price and Exp. Date from the source document go into appropriate fields of the target one. Both structures are almost the same – repeatable records of the same type. So, the simplest solution here is to use the simple links.
To create the simple rules, open the map, select the first field for linking – LineItemID, leftclick on it and holding the button move the pointer to the target LineItemID (drag and drop). You’ll see a blue line connecting both elements (see below). This line means that the data from the source’s LineItemID will go to the target’s LineItemID.
I don’t use any specific tool to test and debug XSLT files. In 90%+ cases the problem is with the XPath and I need to find the exact place where it becomes wrong. So, I use the “count()” function and (sometimes) xsl:comment, like this:
-<xsl:value-of select="count(aaa/bbb/ccc[@ddd = 'eee'])"/>
If I see something like
in the output, it’s clear that the problem with the XPath condition in the brackets.
Now we need to create the source and target structures – the translator will use them for parsing the input and generating the output documents.
I’ll show you how to describe the source structure and you’ll be able to create the target yourself. Let’s start:
- Select the “Document” element on the left (source) side.
- In the top menu select Model->Insert Item->Below
- On the “DMI Attribute” tab change the following parameters:
- Name = LIN
- Access Type = LineFeedDelimRecord. So, now it’s not a group but a record.
- Min/Max = 1/100. They are the minimum and maximum of repetitions.
- Match Value = LIN. It’s a very important parameter – the translator uses it to recognize the LIN records in the source document.