Advanced XML rule example: Select node X based on node Y (or on attribute a)
This kind of rule may be necessary if the XPath to the expected node is not unique in the XML for the invoices (that is, there are multiple nodes with the same XPath in the XML file).
This example uses a Svefaktura invoice. We want to find the correct value for the Kofax ReadSoft Invoices field PaymentReferenceNumber. The expected path of this field in the Svefaktura XML invoice standard is /Invoice/cac:PaymentMeans/cac:PayeeFinancialAccount/cac:PaymentInstructionID. In our sample invoices, there are several instances of this XPath in the file. The one with the GGSISESS attribute is the correct one. Click the thumbnail to see an example:
To create an advanced rule that looks at a different node to find the correct value
- Select the PaymentReferenceNumber field under the Fields category on the Fields tab of the XML Mapper (on the right.side of the window).
Click the button to the right of the value:
if no rule has been defined, or
if there is already an existing rule for the field.
- In the XML node selection section of the Advanced rules toward the top of the Field mapping rules tab that is displayed on the left of the window, expand the Invoice node.
Navigate to and select the node that is closest to
PaymentinstructionID node but common
to all instances. (In this case, the closest common node is
Invoice/cac:PaymentMeans in the
- Click Select.
In the XML node selected to work with box, expand
cac:PaymentMeans and navigate to and
select the sub-node that contains the element that distinguishes the
PaymentMeans sections from each
other. In this case, that is:
- In the Settings for new condition section of the dialog, select Based on value.
- Select the correct attribute in the drop-down list under Value to compare with (GGSISSESS in this case).
Add. The corresponding
condition is added to the
Conditions to work with box:
- Click Extract and review the image to check the results. If you need to modify the rule, you need to click it in the Rules applied to map this field box, click Del to delete it, make the changes needed to fix the rule, and click Add again to add the modified rule. If you need to modify a condition, the process is the same (and if a rule is based on it, the rule is also deleted if you delete the condition).
- Consider if the change(s) should apply to all invoices or only those for the current XML invoice definition. Click Save XML definitionto save the change for the current XML invoice definition only (that is, the current supplier). Click Save XML profile if you want the rule to apply to all XML invoices that match the XML invoice profile regardless of the XML invoice definition.
Other examples of advanced XML rules: