For each of the Document nodes there may be a Header and a Footer section. Both of them are optional, but the Header is always found just before the Document and the Footer is always found just after the Document.
In the setup above we create one separate page for each Document node and inside the page we select the Header lines with this repeat:
/Root/Header[following-sibling::Document[1]/DocumentNo=$DocNo]/Line
Previously the variable, DocNo is set to the current DocumentNo value, and the repeat selects the Header Line nodes for which the following sibling (to the Header node) contains the same value for DocumentNo as the current DocNo. In the repeat expression Document[1] is specified. In that way it verifies that the first of the following Document contains the matching value.
The same principle is used for the footer: Here we compare with the first of the preceding Document nodes.
You can e.g. consider this in the designer, if you have loaded a sample file, that contains too many detail lines which can slow down the designer.
You can limit a repeat to a range of indexes (positions) like below. If you imagine this setup, which iterates across all detail lines:
Then you can change the repeat to only process Detail lines from 2 to 4 in this manner:
In XPath you can e.g. refer to data in this XML file:
If you type this in InterFormNG2 as the XPath:
/Root/Greeting
Then you will get the value of this node, which here equals "HELLO WORLD".
"HELLO WORLD"
Please note that the Xpath is case sensitive, and xpath functions are written in lower case!
Starting with a ‘/’ indicates that you are referring to the node from the root of the XML file.
You can refer to a node number in the tree.
/Root/Document[2]/Contact_person
boolean(/Root/Greeting[contains(.,'HELLO')])
If we e.g. consider an input file with multiple detail lines like below:
Then you can refer to a specific DetailLine node in e.g. a text element via the index like so:
/Root/Document/DetailLine[4]
where this refers to the 4.th DetailLine node within the Document node
Instead of the normal repeat like so:
Then you can even combine variables and index like so:
Both of these repeat loops creates the same output, so as you can see you can even use an xpath expression to set the index number. A related example is found below.