This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
XML and JSON variable support
The Business Process Profile of WSO2 Enterprise Integrator (WSO2 EI) supports XML and JSON variables, which can be read, created or updated within a BPMN process as follows:
For more information on creating a BPMN process, see Creating a BPMN Process.
Access From | Read/Query | Create/Update |
---|---|---|
Java Service Task | Yes | Yes |
Condition Expressions | Yes | No |
Script Task | Yes | Yes |
BPMN REST API | Yes | Yes |
JSON
JSON Node Object
In the Business Process Profile of WSO2 EI, JSON variables are represented by JsonNodeObject
objects. The org.wso2.carbon.bpmn.core.types.datatypes.json.api.JsonNodeObject
wraps the com.fasterxml.jackson.databind.JsonNode
object and provides functions to query and update data in JSON format.
Function | Description |
---|---|
Object jsonPath(String jsonPathStr) | This function evaluates jsonPath over JsonNodeObject and returns the evaluation result.The returned object can be one of the following:
Note: This function returns a new object representing the evaluation results and not a reference to a node. Sample Return var fname = jsonJSVar.jsonPath("$.firstName"); var exec = jsonJSVar.jsonPath("$.execInfo"); |
JsonNode unwrap() | This function unwraps and returns the wrapped JsonNode . |
A set of useful and frequently used functions that are available in JsonNode, are exposed from the JsonNodeObject to make it easier to use JSON variables. However, if other functionality that is available is required, those functions can be unwrapped and used using the org.wso2.carbon.bpmn.core.types.datatypes.json.api.JsonNodeObject.unwrap()
function. These functions are:
JsonNode findValue(String fieldName)
JsonNode findPath(String fieldName)
JsonNode findParent(String fieldName)
List<JsonNode> findValues(String fieldName, List<JsonNode> foundSoFar)
List<String> findValuesAsText(String fieldName, List<String> foundSoFar)
List<JsonNode> findParents(String fieldName, List<JsonNode> foundSoFar)
JsonNode path(String fieldName)
JsonNode path(int index)
String toString()
boolean equals(Object obj)
JsonNode get(int index)
JsonNode get(String fieldName)
boolean has(String fieldName)
boolean has(int index)
int size()
Iterator<JsonNode> elements()
Iterator<String> fieldNames()
Iterator<Map.Entry<String, JsonNode>> fields()
XML
With XML support, users can create variables with the XML data type and extract or set XML content with the help of the simple JAVA API provided in the Business Process Profile of WSO2 EI.
XML Document
XML variables are represented by the XMLDocument object org.wso2.carbon.bpmn.core.types.datatypes.xml.api.XMLDocument
which implements org.w3x.dom.Document
. It also provides a set of user friendly function to query and update XML content with XPath. The following functions are available for the XML variable type with the Business Process Profile of WSO2 EI.
| |
---|---|
Description | This function evaluates the XPath query and returns the relevant element. |
xpathStr | The XPath expression that is to be evaluated. |
Return |
|
| |
---|---|
Description | This function evaluates the XPath query and returns the specified return type. |
xpathStr | The XPath expression that is to be evaluated. |
returnType | The desired return type of the XPath evaluation. The supported return types are:
|
Return | The result of the XPath evaluation in the form of the specified return type. |
| |
---|---|
Description | This function sets, replaces or updates an object (string/element) to match the XPath provided. If a new element is added, this API will clone it and merge the new node to the target location that the XPath points to and will return the new cloned node. |
xpathStr | The XPath to the target location where the object is to be set. |
obj | The string or node object to be set. |
Return | The node gets updated if the object is string and returns a newly added node if the object is an element. |
| |
---|---|
Description | This function appends a child element to the target element. |
xpathToParent | The XPath to the parent node. |
element | The element that is to be appended. |
Return | The node either gets appended or returns a newly added node if the object is an element. |
| |
---|---|
Description | This function inserts a new child node before the specified existing node. |
xpathToTargetNode | The XPath to the target node. |
element | The element that is to be inserted. |
Return | The node gets inserted. |
| |
---|---|
Description | This function will serialize the XML object to a string. |
| |
---|---|
Description | This function creates a new element. This is a util method. |