Template.001014: Invalid element [idxx] 'Repeat' expression evaluated to 0 nodes:
If you want to avoid such warnings, then you can consider to add a condition to test if there are any nodes for the repeat like below:
Change this:
And add a condition either like this:
The boolean() function returns true() if there is at least one node with that path. This is the most efficient test.
The alternative (less efficient way) is to count the number of nodes and compare that with zero like below:
You can then inside of the Repeat loop refer to the DocumentNo inside each Document node with an Xpath like this in a text element:
Please note, that both DocumentNo and ./DocumentNo will work in the rendered result, but the result view will also show the data of the first node, if you specify ./Document as above.
This will retrieve the values ‘1004', '1001' and '1003'.
You do not need to include all the XML nodes with the same name/path in a repeat loop. You can also subset the nodes for the repeat e.g. based on attributes and/or the subtree of each of the nodes.
If we e.g. consider this XML file:
<persons>
<chairman gender="female">
<name>Maggie Frederiksen</name>
</chairman>
<person gender="female">
<name>The Little Mermaid</name>
</person>
<person gender="male">
<name>Mr. Andersson</name>
</person>
<person gender="male">
<name>Mr. Nilsson</name>
</person>
<person gender="female">
<name>Mercedes Hansen</name>
</person>
<person gender="female">
<name>Lada Jaskagidaj</name>
</person>
<person gender="N/A">
<name>Abcd Jensen</name>
</person>
</persons>
Then we can e.g. define a repeat loop, that lists the name of all female persons (a gender attribute that is female) with this repeat loop:
We can also condition the subset on the contents of the subset of the current node. We can e.g. list all persons that has the text 'sen' somewhere in the name node like so:
We can also condition a node set on the name of the nodes. If we e.g. have list of multiple nodes named "Adress" followed by a number (in sequence) like this:
Then we can build a repeat loop to go all of these "Address" nodes like so:
/Root/Document/*[contains(name(),'Adress')]
If we want to print out the contents of all the Adress nodes the full setup can look like this:
Where * selects any sub-node of the Document node and the name() function returns the name of the current node. The contains function is described here.
<Root>
<CompanyInfo></CompanyInfo>
<Greeting>HELLO WORLD</Greeting>
<Barcode>www.interformng.com</Barcode>
<Document Company="Herring Marine Research">
<Contact_person>Martin Merman</Contact_person>
<Date>20-09-2011</Date>
<DocumentNo>1004</DocumentNo>
<Adress1>Seaweed Street 14</Adress1>
<Adress2>9000 Battleaxe</Adress2>
<Country>DK-Denmark</Country>
<Reference>PMK</Reference>
<Intro></Intro>
<Paragraphs></Paragraphs>
<DetailLine SEQ="1">
<Product>Interword400</Product>
<Model>510</Model>
<i-Group>i300</i-Group>
<SN>44A2971</SN>
<LicenseCode>81 20 01 3A</LicenseCode>
</DetailLine>
<DetailLine SEQ="2"></DetailLine>
</Document>
<Document Company="Florence Flowers">
</Document>
</Root>
Preceding-sibling. We can do a repeat of all detail lines and use XPath functions, preceding-sibling or following-subling to count the number of nodes before or after the current node (with the same unique selection).
Distinct-values. We can use the Xpath function, distinct-values to generate a list of all unique values, count this number and iterate across each of these unique values
/Root/Document/*[starts-with(name(),'Adress')]
In a transformation you cannot use a variable to keep track of the current node number, so if you e.g. within a repeat wants to calculate the current node number, then you can consider this expression:
count(preceding-sibling::*) + 1
This is e.g. relevant in a transformation, where you cannot use a variable to keep track of this node number - especially if you want to verify the current line node number in a repeat for the line nodes of a spooled file.
As of January 13, 2025, we are excited to announce that our new Help Center is in the final stages of development. While the Knowledge Base is already accessible, our current JIRA system will continue to manage support tickets during this transition period. For assistance with InterForm Output Management Software, please refer to the Support for InterForm Output Management Software.
We appreciate your patience and understanding as we work to enhance your support experience. If you have any questions or encounter any issues, please do not hesitate to reach out via the existing support channels.
Best regards,
The InterForm Support Team