Skip to end of metadata
Go to start of metadata

WSO2 Business Process Server 3.6.0 onwards 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 FromRead/QueryCreate/Update
Java Service Task


Condition ExpressionsYesNo
Script TaskYesYes


JSON Node Object

In WSO2 BPS, 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.

Object jsonPath(String jsonPathStr)This function evaluates jsonPath over JsonNodeObject and returns the evaluation result.

The returned object can be one of the following:

  • If the result is a JSON object, it will return a com.fasterxml.jackson.databind.JsonNode.
  • If the result is a JSON array, it will return a com.fasterxml.jackson.databind.node.ArrayNode.
  • Main primitive data types (String, Integer, Byte, Character, Short, Long, Float, Double, Boolean)

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()


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 WSO2 BPS. 

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 WSO2 BPS. 


Object xPath(String xpathStr)
DescriptionThis function evaluates the XPath query and returns the relevant element.
xpathStrThe XPath expression that is to be evaluated.
  • A org.w3c.dom.NodeList is returned if there is more than one elements in the result.
  • A org.w3c.dom.Node object is returned if there is only one element in the result.


Object xPath(String xpathStr, String returnType)
DescriptionThis function evaluates the XPath query and returns the specified return type.
xpathStrThe XPath expression that is to be evaluated.

The desired return type of the XPath evaluation. The supported return types are:

    • NODE
    • STRING
    • NUMBER

The result of the XPath evaluation in the form of the specified return type.


Node set(String xPathStr, Object obj)

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.

xpathStrThe XPath to the target location where the object is to be set.
objThe string or node object to be set.

The node gets updated if the object is string and returns a newly added node if the object is an element.


Node appendChild(String xPathToParent, Element element)

This function appends a child element to the target element.

xpathToParentThe XPath to the parent node.
elementThe element that is to be appended.

The node either gets appended or returns a newly added node if the object is an element.


Node insertBefore(String xPathToTargetNode, Element element)

This function inserts a new child node before the specified existing node.

xpathToTargetNodeThe XPath to the target node.
elementThe element that is to be inserted.

The node gets inserted.


String toString()

This function will serialize the XML object to a string.


Element createNewElement(String elementStr)

This function creates a new element.

This is a util method.

  • No labels