Process XML message content

1
0
-1

"I am evaluating if Bonita can be used in our organisation and I have created as tests already a few interesting examples. Last thing for me to understand is how to work with (import / show / manipulate content) XML messages containing for instance order info. I have found the description of how to define data type = XML etc. for variables but I am still searching for a description about how to get the xml data (via parse?) available for a simple human activity in Bonita like viewing the xml message content. Perhaps you have a kind of description available? Thanks in advance for your help."

1 answer

1
+1
-1
This one is the BEST answer!

Hi,

The easiest way to read XML from wherever you need in Bonita using a groovy function.BonitaXML.evaluateXPathOnVariable

For example : I have created a Bonita XML variable based on an example xsd from W3C

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com">
<xs:element name="note">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="to" type="xs:string"/>
      <xs:element name="from" type="xs:string"/>
      <xs:element name="heading" type="xs:string"/>
      <xs:element name="body" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>
</xs:schema>

My bonita variable is named 'note' and initialized with the following constant :

<?xml version="1.0"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

From any spot of my process or screen I can use the groovy function to retrieve nodes content like this one with XPath language :

BonitaXML.evaluateXPathOnVariable(note,"/note/heading/text()")

-> returns 'Reminder' HIWH Olivier

Comments

Submitted by RVermeulen on Mon, 04/28/2014 - 17:57

Indeed Oliver that is working. Thanks very much.

Notifications