An assignment may fail with a selectionFailure
fault that can be caused by attempting to select a nonexistent element. In this recipe, we will show how to deal with missing elements in an assign so that we avoid the selectionFailure
fault.
Open an assignment that causes selectionFailure
faults when an element is not present in the input. It is possible that the source element might actually be an optional element in the input document, and the XML element marker being in square brackets will indicate this.
selectionFailure
fault and select the ignoreMissingFromData menu item. This will cause the assignment to be ignored if the source element does not exist:When the ignoreMissingFromData
attribute is set on a copy
statement in Assign, it causes that copy
statement to be skipped if the from
query were to cause a selectionFailure
fault.
The ignoreMissingFromData
attribute also works with all other Assign subelements, such as insertAfter
, insertBefore
, copyList
, and append
.
The MiscMappings
project in the code samples has a sample BPEL process called MappingBPELProcess.bpel
demonstrating this.