Websphere Message Broker: Accessing XML elements in ESQL

Neha Raje

Websphere Message Broker: File in File out example. I have an XML file with repeating element structure. How can I access and modify value of a particular element in ESQL. I worte following code..

CREATE PROCEDURE CopyEntireMessage() BEGIN
     --SET OutputRoot = InputRoot;
      DECLARE I INTEGER 1;
      DECLARE J INTEGER;
      SET J = CARDINALITY(OutputRoot.*[]);
      WHILE I < J DO
         SET OutputRoot = InputRoot;
         SET OutputRoot.XMLNS.person.student[I].name = 'XYZ';
         SET I = I + 1;
      END WHILE;
 END;

But its not working. Picking up the file from input folder but i cannot see anything in Output folder. But if I comment

SET OutputRoot.XMLNS.student[I].name = 'XYZ';

then file is available in output folder as it is without any change.

My XML file is as below

<person>
 <student>
   <name>ABC</name>
   <age>20</age>
   <address>city1</address>
 </student>
 <student>
   <name>PQR</name>
   <age>20</age>
   <address>city2</address>
 </student>
</person>

can anybody help me on this?

Dave

This compute module should do what you need, tested at 9001 on linux:

CREATE COMPUTE MODULE FileInputOutput_Compute
    CREATE FUNCTION Main() RETURNS BOOLEAN
    BEGIN
        -- CALL CopyMessageHeaders();
        CALL CopyEntireMessage();

        FOR source AS OutputRoot.XMLNSC.person.student[] DO
            SET source.name = 'XYZ';
        END FOR;


        RETURN TRUE;
    END;

    CREATE PROCEDURE CopyMessageHeaders() BEGIN
        DECLARE I INTEGER 1;
        DECLARE J INTEGER;
        SET J = CARDINALITY(InputRoot.*[]);
        WHILE I < J DO
            SET OutputRoot.*[I] = InputRoot.*[I];
            SET I = I + 1;
        END WHILE;
    END;

    CREATE PROCEDURE CopyEntireMessage() BEGIN
        SET OutputRoot = InputRoot;
    END;
END MODULE;

A couple of notes, firstly it is not good practice to redefine the auto-generated procedures, if you need to reuse functionality which sets every field in a message then it would be wise to create a new procedure to do this.

XMLNS is also deprecated so use XMLNSC instead, it is higher performance and has all the same capabilities as XMLNS which is retained only to support legacy applications.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Websphere Message Broker and Websphere Transformation Extender Installation

From Dev

Changing IBM WebSphere Message Broker node properties

From Dev

Java - sending a message to WebSphere message broker and its altering my message

From Dev

WebSphere® Message Broker - DataFlowEngine Process - Failed to allocate memory

From Dev

Accessing children elements of XML

From Dev

XML accessing elements

From Dev

How to create xml in esql

From Dev

Parsing XML with Python - accessing elements

From Dev

I cannot enable basic HTTP authentication in a SOAPInput node (Websphere Message Broker)

From Dev

Including the input message in the output message ESQL

From Dev

Accessing Sibling Elements in XML DOM using Perl?

From Dev

Accessing child XML elements with XPATH in Python

From Dev

Accessing child XML elements in Python lxml

From Dev

Redis as a message broker

From Dev

Service Broker message flow

From Dev

Suggestion for message broker

From Dev

Message queue and Message broker differences

From Dev

Accessing nested elements while iterating an XML LINQ query?

From Dev

Service Broker message time to live

From Dev

Android Client for WebSocket Message Broker

From Dev

Json Rest Service in Message Broker

From Dev

JMS Broker receives the message as null

From Dev

Unable to set messge ids for jms message while using citrus frame work to execute xml test case that puts message in Websphere MQ

From Dev

How to find/reference XML element in unknown SOAP tree structure in ESQL

From Dev

Deliver message from a local broker to a disconected central broker

From Dev

Accessing elements inside elements with XQuery

From Dev

Accessing elements using $$ or elements in webdriverio

From Dev

Accessing joined elements

From Dev

Accessing elements in the shadow DOM

Related Related

  1. 1

    Websphere Message Broker and Websphere Transformation Extender Installation

  2. 2

    Changing IBM WebSphere Message Broker node properties

  3. 3

    Java - sending a message to WebSphere message broker and its altering my message

  4. 4

    WebSphere® Message Broker - DataFlowEngine Process - Failed to allocate memory

  5. 5

    Accessing children elements of XML

  6. 6

    XML accessing elements

  7. 7

    How to create xml in esql

  8. 8

    Parsing XML with Python - accessing elements

  9. 9

    I cannot enable basic HTTP authentication in a SOAPInput node (Websphere Message Broker)

  10. 10

    Including the input message in the output message ESQL

  11. 11

    Accessing Sibling Elements in XML DOM using Perl?

  12. 12

    Accessing child XML elements with XPATH in Python

  13. 13

    Accessing child XML elements in Python lxml

  14. 14

    Redis as a message broker

  15. 15

    Service Broker message flow

  16. 16

    Suggestion for message broker

  17. 17

    Message queue and Message broker differences

  18. 18

    Accessing nested elements while iterating an XML LINQ query?

  19. 19

    Service Broker message time to live

  20. 20

    Android Client for WebSocket Message Broker

  21. 21

    Json Rest Service in Message Broker

  22. 22

    JMS Broker receives the message as null

  23. 23

    Unable to set messge ids for jms message while using citrus frame work to execute xml test case that puts message in Websphere MQ

  24. 24

    How to find/reference XML element in unknown SOAP tree structure in ESQL

  25. 25

    Deliver message from a local broker to a disconected central broker

  26. 26

    Accessing elements inside elements with XQuery

  27. 27

    Accessing elements using $$ or elements in webdriverio

  28. 28

    Accessing joined elements

  29. 29

    Accessing elements in the shadow DOM

HotTag

Archive