Writing Copy Rules
The Assign activity assigns values to variables. Each assignment is called a copy rule. Copy rules are added to the Assign to specify which data will be copied into which variable. A variable can be assigned with a value from another variable, with a literal value, or with an XPath expression.
To add a copy rule
- Select the Assign activity from the BPEL Editor.
-
In the Properties view, click the Add Copy Rule icon from the toolbar.
The Copy Rule dialog box displays, and you can now build the copy rules you need to perform simple data manipulation and transformation.
You can create multiple copy rules from the Copy Rule dialog box, using the available toolbar. The asterisk denotes a copy rule that has been modified.
-
Select either Variable, Fixed Value, or `Expression from the From drop down list, depending on what type of value you are assigning.
In the Copy Rule Editor (available when you select Expression in the drop down list) you can cycle through the variables, XPath functions, and XPath operations available to you, by pressing Ctl+Space. Type the dollar sign ($) in the editor to display a list of variables.
Each copy rule for an Assign activity has a From part, which specifies the source data, and a To part, which specifies a variable or element part as the destination for the data.
-
Complete the To section of the Copy Rule form to specify a variable or element part in the reply message.
Optional attributes
See section 8.4.2. Replacement Logic of Copy Operations in the BPEL specification for more detailed information on optional attributes.
The Ignore Missing Source Data attribute specifies whether missing From-side data is ignored
-
If this attribute is not enabled (the default), then the regular bpel:selectionFailure fault occurs if optional data of the selected item is missing in the From side. That is if, at runtime, the left side of a copy rule (From) refers to XML components that are absent from the XML document or fragment that it is being assigned from. Typically this happens when components have been marked as optional in the XML schema.
Enable this option when you know that components have been marked as optional and you want to avoid selection failures. See Initializing Variables for information on initialization options.
-
Check Ignore Missing Source Data to ignore any missing From data and to avoid an error if the source variable is missing optional data. When doing an assign from a From to a To, any missing From data will be ignored. The To side for the rule is not evaluated and nothing changes in the target variable.
Keep Source Element Name replaces the element at the destination with a copy of the entire element at the source, including children and attribute properties. This attribute supports XSD substitution groups and choice.
-
If Keep Source Element Name is disabled, then the resulting value for element-based variable in the destination (To side) has its original namespace and local name properties. This is the default.
- If Keep Source Element Name is enabled, then the resulting value for the element-based variable in the destination uses the name of the element-based variable in the source (FROM side).
More Information