If you want to output the sum of all detail lines of a document, then the best solution is to output a sum, that is included in the input file, but if that sum is not included, then you can either create a repeat loop in the designer and sum up the values in a variable, but you can also simply use the Xpath sum function like to:
sum(/Root/DetailLine/Amount)
If you want to know how many nodes there are in an input XML file, then you can use the XPath function, count. The count function simply counts the number of nodes with the specified path. This function counts the number of detail lines in an XML file:
count(/Root/Document/DetailLine)
If you want to verify, if a node is empty, then you can use this comparison: (MyNode=''), but this only returns true, if the node, MyNode actually exists and is empty. If you use the same comparison for a node, that does not exist, then this comparison is false (unlike in InterFormNG1, which use XPath version 1). For comparisons like that there is in a "Checking if a node is not blank" topic.
So if you want to insert a condition, that can verify if the node exists, then you need to use another condition.
count(MyNode)>0
boolean(MyNode)
In regards to performance the test boolean(MyNode) is faster, but perhaps not that clear for a new user.
So if you in InterFormNG2 wants to insert a condition to verify if the node, MyNode is either blank (null) or does not exist, then you could use this condition to combine them:
MyNode='' or boolean(MyNode)=false()
MyNode='' or not (boolean(MyNode))
An alternative is to consider the ng:compare function.
The most simple way is to do a string compare i.e. convert the contents of the node into a string and then compare the result. In this way you could substitute the condition MyNode!='' with the condition string(MyNode)!=''. This works by converting the node selection (which can be no nodes, one node or multiple nodes) into a string and the compare the string with an empty string. Please note, that the string function is a standard XPath function, that must be written in lower case.
Other solutions could be to use two tests to verify, that the node actually exists and also that the value of the node is not empty/null. You can do that with this condition:
Mynode!=''
boolean(MyNode)
another expression to do the same is:
Mynode!=''
count(MyNode)>0
An alternative is to consider the ng:compare function.
The most simple way is to do a string compare i.e. convert the contents of the node into a string and then compare the result. In this way you could substitute the condition MyNode!='' with the condition string(MyNode)=''. This works by converting the node selection (which can be no nodes, one node or multiple nodes) into a string and the compare the string with an empty string. Please note, that the string function is a standard XPath function, that must be written in lower case.
Other alternatives are here:
If you really want to test, if the node does not contains data, then you should use a condition like this:
MyNode=''
not(boolean(MyNode))
Mynode=''
or count(MyNode)=0
You can refer to examples in the sections: "Verify if a node exists" and "Verify if a node is not blank" for other examples how to test on the contents of a node, while being able to handle non-existing nodes. An alternative is to consider the ng:compare function.
If you consider this sample 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><?xml version="1.0" encoding="UTF-8"?>
Here the gender is defined as an attribute of the chairman and person nodes.
In the designer the attributes in XML files are shown with a preceding @-sign as below:
If you want to refer to the gender of the chairman, then you can in the designer simply drag the attribute to the result to map it.
The Text element will look like this:
If you want to count all the male persons, then you can that like this:
count(/persons/person[@gender='male'])
/Root/nmspc:myNode
Where nmspc is the name of the namespace.
If you want to make this work no matter what the namespace is called, then you can replace the namespace with an asterix like so:
/Root/*:myNode
You can use a local-name notation, if there are multiple namespaces with the same node:
/Root/*[local-name() = 'myNode']
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