How to use XPath.executeWithEvent

How to use XPath.executeWithEvent

book

Article ID: KB0094582

calendar_today

Updated On:

Products Versions
TIBCO BusinessEvents Enterprise Edition -
Not Applicable -

Description

Resolution:
The only different between execute and executeWithEvent is the input. The executeWithEvent require a event as the input. The xml of that event looks like below:
    &ltns0:NewEvent xmlns:ns0="www.tibco.com/be/ontology/NewEvent" Id="2">&ltpayload>&ltns0:root>&ltAAA>&ltCCC&gtInput for CCC</CCC></AAA>&ltBBB>&ltDDD&gtInput for DDD</DDD></BBB></ns0:root></payload></ns0:NewEvent>
    The sub-elements under payload are the schema which you specified in the payload tab of that event. I think the reason why you didn’t get the correct the result is that you didn’t provide the correct namespace and prefix. You can use xpath ‘/*’ to get the all elements in that event. And then you can get the correct namespace and prefix.
    For example, please check below code.
    
    String xpath = "/*";
    NewEvent event = Event.createEvent(…);
    String prefixes = "ns0=www.tibco.com/be/ontology/NewEvent";
    String result = XPath.executeWithEvent(xpath, event, prefixes);
    System.debugOut("result = " + result);

    If you want to get the root element, you need to use String xpath = "//ns0:root";. Please note that the root element of that event is the ns0:Event, not the ns0:root. So please make sure you use the correct xpath and namespace.

Issue/Introduction

How to use XPath.executeWithEvent