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
example.)
- 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:
cac:PaymentMeans/cac:PayeeFinancialAccount(cac:FinancialInstitutionBranch/cac:Financialnstitution/cac:ID
- 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).
-
Click
Add. The corresponding
condition is added to the
Conditions to work with box:
Value(Node[PaymentMeans/PayeeFinancialAccount/FinancialInstitutionBranch/FinancialInstitution/ID])=="GGSISESS"
- 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:
Correct a misspelled field name in connection with master data
Format an extracted XML value with XSL
Modify an extracted XML field value with XSL
Remove hyphens (-) from an extracted value
Select node X based on node Y (or on attribute a)
Select a specific node when more than one node matches after using a standard rule
Select node X if it exists and node Y if it does not
Specify a constant value for a field
Summarize data from line items as a note in summary invoices
Translate an XML value to one that Kofax ReadSoft Invoices understands