3sgrMath Samples - 3sgr/DatacapOS GitHub Wiki

Datacap

Please review the following xPath articles before using proceeding with this section: See this link for xPath intro and this example for more details on how to use it. Here you can find overall xPath specification.
Note: Operations below are only performed with page (aka batch) xml and exclude pages.

Count

ProcessFormula("<some_expression> Count(<xPath)")
Sample:
ProcessFormula("@B.TotalPages = Count("//B/D/P")") // <- returns always True

Parameters: String variable formatted in accordance with xPath specification. Counts elements of the runtime DCO. Use following <xPath> Count() parameters:

Count Parameter Description
.//P Counts all pages in Batch (All levels)
//B/D/P Counts all pages in Batch (within documents)
//B/D/P/V[@n='TYPE' and text()='Main_Page'] Counts all pages in Batch of type Main_Page
//B/D/P/V[@n='STATUS' and text()='1'] Counts all pages in Batch with Status 1
//B/D/P[V[@n='STATUS' and text()='1'] and V[@n='TYPE' and text() ='Main_Page']] Counts all pages in Batch of type Main_Page and status 1

Sum

ProcessFormula("<some_expression> Sum(<xPath>)") <br/>
Sample:
ProcessFormula("0 == sum(//B/D/P/V[@n='STATUS']/text())") // <- returns True or False

Parameters: String variable formatted in accordance with xPath specification.

Sum Parameter Description
//B/D/P/V[@n='STATUS']/text() Can be used as quick validation test that returns false if Sum of all statuses IS NOT equals 0 for all pages on the document level(ignoring batch level pages).
.//V[@n='STATUS']/text() Sum all statuses of all nodes in a batch

SumASCII

Function specifically designed to summarize values of all nodes of the same type. A good example could be sum of all line item totals in the invoice processing or sum of all different taxes on a bill, invoice or receipt.

ProcessFormula("<some_expression> SumASCII(<xPath>)") <br/>
Sample:
ProcessFormula("@B.TotalInvoices = SumASCII("//B/D/P/F[@id='Invoice_Total']")) // <- returns sum of all InvoiceTotal Fields

Parameters: String variable formatted in accordance with xPath specification.

Sum Parameter Description
//B/D/P/F[@id='Invoice_Total'] This Can be used to calculate total amount from all invoices in the current batch .
<some_more_samples> <description>

Algebra

Trigonometry

GUI XPath Tester

You can find a good sample here that also can be used to test all xPath expressions (including Sum and Count, but excluding SumASCII, as it is Datacap-specific)

⚠️ **GitHub.com Fallback** ⚠️