Title: assign ## Name `` --- update the values of variables with new data ## Synopsis
Usage
standard-elements ( from-spec to-spec | assign-element-of-other-namespace )+ *throws* `[bpel:invalidVariables](#invalidVariables)`, `[bpel:selectionFailure](#selectionFailure)`, `[bpel:subLanguageExecutionFault](#subLanguageExecutionFault)`, `[bpel:uninitializedVariable](#uninitializedVariable)`, `[bpel:mismatchedAssignmentFailure](#mismatchedAssignmentFailure)`, `[bpel:uninitializedPartnerRole](#uninitializedPartnerRole)` ## Description The `` activity can be used to copy data from one variable to another, as well as to construct and insert new data using expressions. The `` activity can also be used to copy endpoint references to and from partnerLinks. Each `` is made up of any number of `` entries which are each made up of a "to-spec" (lvalue), and a from-spec (rvalue). - `ignoreMissingFromData` - (optional) Should the `[bpel:selectionFailure](#selectionFailure)` standard fault be suppressed? - `yes` - suppress standard faults - `no` - (default) do not suppress standard faults
The `ignoreMissingFromData` element has been implemented in ODE 1.3+ (i.e., it is coming soon). See [ODE-141](http://issues.apache.org/jira/browse/ODE-141) for issue tracking.
- `validate` - (optional) validate modified variables? - `yes` - the `` activity validates all the variables being modified by the activity. If the validation fails the `[bpel:invalidVariables#invalidVariables]` fault is thrown. - `no` - (default) do not validate the modified variables
ODE currently disregards the value of this attribute --- validation is never performed.
- `` - defines a lvalue, rvalue pair. - `keepSrcElementName` - (optional) should the element name of the destination (as selected by the to-spec) be replaced by the elementname of the source (as selected by the from-spec)? - `yes` - element names are replaced - `no` - (default) element names are not replaced - `` - specifies the rvalue (see [here](#variants)) - `` - specifies the lvalue (see [here](#variants)) - `` - a container for assignment extensions. If the element contained within the extensionAssignOperation elements not recognized by ODE and is not subject to a mustUnderstand="yes" requirement from an extension declaration then the element will be ignored.
Since version 2.0 ODE fully supports `extensionAssingOperation` functionality.
### From/To-Spec Variants The activity copies a type-compatible value from the source ("from-spec") to the destination ("to-spec"), using the element. The from-spec must be one of the following variants: ? queryContent expression literal value
The `` from-spec variant is not part of the WS-BPEL 2.0 specification. It is a non-standard ODE extension.
The to-spec must be one of the following variants: ? queryContent expression
The `` to-spec variant is not part of the WS-BPEL 2.0 specification. It is a non-standard ODE extension.
A to-spec must return an lvalue. If a to-spec does not return an lvalue then a `bpel:[selectionFailure](selectionfailure.html)` will be thrown. In the context of XPath, an lvalue is a node-list containing a single node from a variable or a partnerLink identified by the to-spec (e.g. the XPath expression `concat("foo""bar")` is not an lvalue).
XPaths used as lvalues must begin with an XPath VariableReference.
Assignment is an atomic operation; that is, either all `` s succeed, or no changes are made.
In ODE, each `` is atomic.
#### Variable Variant Selects value stored in a BPEL variable. ? queryContent - `variable` - (required) name of the variable. - `part` - (optional) if the type of this variable is a WSDL messageType this attribute may be used to provide the name of a part within that variable. This attriubte must not be used When the variable is defined using XML Schema types (simple or complex) or element - `` element may be used to select a value from the source or target variable or message part. The computed value of the query must be one of the following: ** a single XML node, for example an attribute or an element ** text (i.e. a text node, CDATA section, string-valuedXPath-expression, etc...) #### PartnerLink Variant Allows manipulation of the endpoint references associated with partnerLinks. - `partnerLink` - name of partnerLink - `role` - the role or "side" of the partnerLink ** `myRole` - the endpoint reference of the process ** {partnerRole}} - the partner's endpoint reference For from-specs, the `role` attribute must be specified, while for the to-spec, the assignment is only possible to the partnerRole, hence there is no need to specify the role. Therefore, the to-spec can only refer to a `` of which the declaration specifies the partnerRole attribute. The type of the value referenced by partnerLink-style from/to-specs is always a `` element. An attempt during process execution to read a partner link before its partnerRole EPR is initialized results in the `[bpel:uninitializedPartnerRole](#uninitializedpartnerrole.html)` standard fault. Partner roles of partner links are read when they are referenced in an `<[invoke]>` or the `` part of a `` in an `<[assign]>` activity. #### Property Variant Allows data manipulation using properties. The property value generated by the from-spec is generated in the same manner as the value returned by the `bpel:[getVariableProperty]()` function. - `variable` - name of the variable referenced - `property` - name of the property to apply to the variable #### Expression Variant In the Expression Variant, an expression language (typically XPath), is used to calculate a value. expression - `expressionLanguage` - (optional) identifies the expression language - _expression_ - the expression; syntax is determined by the expression language. The computed value of the expression must be one of the following: * a single XML node, for example an attribute or an element * text (i.e. a text node, CDATA section, string-valuedXPath-expression, etc...) #### Literal Variant The Literal Variant allows a literal value to be given as the rvalue. literal value - _literal value_ - value to be assigned The type of the literal value may be optionally indicated inline with the value by using XML Schema's instance type mechanism (`xsi:type`). The literal content must be either a single element or text. An empty `` element is equivalent to an empty text node. #### Empty Variant The empty variant exist for extensibility purposes; it is not supported by ODE. #### Variable Extension Variant (non-standard extension) The variable extension variants are non-standard extensions implemented by ODE to allow manipulation of protocol-specific properties from within a BPEL process. - `variable` - message variable to read - `extension` - qualified name of the extension The variable referenced by this variant _must_ be message-typed. The following extensions are supported:
Extension NamespaceNameDescription
urn:ode.apache.org/axis2-il/headers/inWhen using the AXIS2 integration layer, this extension returns the headers that were received with the message but that did not map to any message parts in the portType. The return value will be a wrapper element(with the same name as the extension) containing the SOAP header elements.
urn:ode.apache.org/axis2-il/headers/outWhen using the AXIS2 integration layer, this extension holds the headers that should be sent with the mesage but are not mapped to any message parts in the portType. The rvalue should be a wrapper element (with the same name as the extension) containing the SOAP header elements to be sent.
The use of this feature is not encouraged. Processes using this feature will not be compatible with WS-BPEL 2.0 conformant systems.
#### Insert Variant ({color:red}non-standard extension{color}) See [copy with insert attribute](copy-with-insert-attribute.html) ### Faults {anchor:invalidVariables} - `bpel:[invalidVariables](invalidvariables.html)` - A modified variable does not conform to its schema and the `validate` flag was set to `yes`.
ODE does not perform schema type validation, hence this fault is never thrown.
{anchor:selectionFaulure} - `bpel:[selectionFailure](selectionfailure.html)` - The node(s) selected by a from/to-spec is (are) invalid. This includes cases when the to-spec returns a node that is not an lvalue, when multiple nodes are selected, or when no node is selected. {anchor:subLanguageExecutionFault} - `bpel:[subLanguageExecutionFault](sublanguageexecutionfault.html)` - Evaluating the expression (in the expression variant), or the query (in the variable variant) generated an error. For example, if a divide-by-zero is attempted. {anchor:uninitializedVariable} - `bpel:[uninitializedVariable](uninitializedvariable.html)` - The variable referenced in the from-spec has not been initialized. {anchor:mismatchedAssignmentFailure} - `bpel:[mismatchedAssignmentFailure](mismatchedassignmentfailure.html)` - The nodes selected by the to-spec and from-spec are not compatible. This could occur if for example an attempt was made to assign a text node to an element variable, or an element variable was assigned to a message variable. ### Examples The following assigns a childless element `bar` in namespace `http://example.com` to an element-typed variable `myFooBarElemVar`: The following assigns the string "FooBar" to a string-typed variable `myStringVar`: The following assigns the string "" (i.e. the empty string) to a string-typed variable `myStringVar`:
The following illustrates copying one variable (`c1`) to another (`c2`) as well as copying a variable part (`address` part of variable `c1`) to a variable of compatible element type (`c3`): $c1.address