Author |
Message
|
rajraj |
Posted: Tue Mar 28, 2006 8:07 am Post subject: Conversion of TDS to XML without using mapping node |
|
|
Novice
Joined: 28 Mar 2006 Posts: 11
|
Hi All
i want to convert a message from TDS to XML without using a mapping node.
1. i have created a TDS message set ( with $ as a delimiter and ENAME and ENO as fields in message definition file)
2. i am giving input message as 11$raj
3. i have taken a MQInput Node , Compute node and MQOutput node
what i the code i have to define in compute node to convert into XML .
plx come out with Esql code in compute node
plz come out with your suggestions
Thanks in advance |
|
Back to top |
|
 |
wschutz |
Posted: Tue Mar 28, 2006 8:45 am Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
The idea is that you would create your message set with two physical types: TDS and XML. You read in the TDS formatted message (setting the TDS format on the default for the MQ Input node) and then use a reset content descriptor to change the format to the XML format.
On the RCD node, you keep the same "message set" and "message type", just change the "Message format".
You don't need to code any esql at all. _________________ -wayne |
|
Back to top |
|
 |
rajraj |
Posted: Tue Mar 28, 2006 1:05 pm Post subject: |
|
|
Novice
Joined: 28 Mar 2006 Posts: 11
|
Hi wschutz
Thanks for ur reply
1. I have created two messages sets.
1. TDS set and XML message set.
2. i am taking TDS set in MQ input properties and XML message set in Reset node properties.
now i want to convert TDS to XML.
my flow contains
MQINPUT ----> Reset node------> MQOUTPUT node
but when i am passing message from INPUT ,the same message TDS message in show on MQOUPUT node.
MQINPUT = 11$rr
MQOUTPUT =11$rr
any help will be helpful
Thanks in advance |
|
Back to top |
|
 |
jbanoop |
Posted: Wed Mar 29, 2006 1:08 am Post subject: |
|
|
Chevalier
Joined: 17 Sep 2005 Posts: 401 Location: SC
|
From Version 5 help
The ResetContentDescriptor node does not:
Change the message content. It changes message properties to specify the way in which the bit stream is parsed next time that the parser is invoked.
Convert the message from one format to another. For example, if the incoming message has a Message Format of XML and the outgoing Message Format is CWF, the ResetContentDescriptor node does not do any reformatting. It invokes the parser to recreate the bit stream of the incoming XML message, which retains the XML tags in the message. When the message is reparsed by a subsequent node, the XML tags are invalid and the reparse fails.
Anoop |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Mar 29, 2006 5:58 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Rajraj -
This is basic use of the product. If you have a set of fields in one message, and you need them in a different message (as opposed to a different physical format of the same message), then you need to copy each field from one logical message tree to the other.
The mapping node provides a graphical tool for building the ESQL code to do this copying for you - but the end result is still ESQL code that does a bunch of "set OutputRoot.parser.messageRoot.field.fielda = InputRoot.parser.messageRoot.field1.field2.field3;" and etc.
And so, even if we wanted to (and we don't), we can't give you the ESQL you're asking for since we don't know all the fields in your input message and all the fields in your output message and which ones need to be copied from where to where. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
wschutz |
Posted: Wed Mar 29, 2006 6:45 am Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
ahh...but I've done a project before where I define the message with two physical formats (say tds and xml) and then just use the "create ... lastchild ... parse" statement to convert from one to the other without doing any "assignment" in esql or using a mapping node (If I can find the project in the mess I call a harddrive I'll try to post the esql here).
Anyways, please ignore by previous post about the RCD since that was obviously incorrect.  _________________ -wayne |
|
Back to top |
|
 |
wschutz |
Posted: Thu Mar 30, 2006 6:51 am Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
Yes, you can translate directly from TDS format to XML format without having to use a
Mapping Node or coding ESQL to move the fields individually. Here's a test of converting
a TDS string into XML: (formatted a bit for clarity)
Quote: |
$ cat simple.msg
h1,h2,h3,h4;1,2,3,4;5,6,7,8;
$ # Put the message to the input Q
$ q -f simple.msg -m WBRK_QM -o TESTIN
MQSeries Q Program by Paul Clarke [ V4.3 Build:Jun 9 2004 ]
Connecting ...connected to 'WBRK_QM '.
$ # Get the output message
q -m WBRK_QM -I TESTOUT
MQSeries Q Program by Paul Clarke [ V4.3 Build:Jun 9 2004 ]
Connecting ...connected to 'WBRK_QM
'.
<TopMostMsg>
<Table1><HD1>h1</HD1><HD2>h2</HD2><HD3>h3</HD3><HD4>h4</HD4></Table1>
<Table2>
<ITEM><ID>1</ID><LOC>2</LOC><DESC>3</DESC><BOH>4</BOH></ITEM>
<ITEM><ID>5</ID><LOC>6</LOC><DESC>7</DESC><BOH>8</BOH></ITEM>
</Table2>
</TopMostMsg>
No more messages.
|
To do this, I created one message set ("cdl") with both XML and TDS physical formats.
In the flow, I have a MQInput node (q:TESTIN) set to a default Message Domain of "BLOB", an
ESQL compute node with the following code, and an MQOuput node (Q:TESTOUT)
(and some Trace nodes for fun):
Code: |
CREATE COMPUTE MODULE myCDFcompute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE targetPtr REFERENCE TO OutputRoot;
DECLARE sourcePtr REFERENCE TO InputRoot.BLOB.BLOB;
DECLARE ccsid INTEGER;
CALL CopyMessageHeaders();
SET ccsid = InputRoot.Properties.CodedCharSetId;
CREATE LASTCHILD OF targetPtr
domain('MRM')
PARSE(sourcePtr CCSID ccsid SET 'cdl' TYPE 'TopMostMsg' FORMAT 'TDS1' ) ;
SET OutputRoot.Properties.MessageFormat = 'XML1';
RETURN TRUE;
END;
... (copymsgheader sbrtn)
END MODULE;
|
Have fun.... _________________ -wayne |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Mar 30, 2006 6:57 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Of course, this is only feasible if the logical message structure is the same in both physical formats.
If you need to regroup things or reorder or in any way restructure the logical message tree, then you have to either use ESQL, Java/C, or a Mapping node to code the translation.
The message modelling in Broker in all versions is only for describing data, it's not for describing processing. Processing is handled in message flows and accomplished by manipulating logical message trees that have been created from either self-describing data (XML, MIME) or modelled data (MRM, IDoc, etc.).
Remember your programming classes - Broker is Turing complete, so it can only do the same things that every other programming environment can do. No magic pixie dust here! _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
rajraj |
Posted: Thu Mar 30, 2006 1:59 pm Post subject: Conversion of TDS to XML without using mapping node |
|
|
Novice
Joined: 28 Mar 2006 Posts: 11
|
Hi jefflowrey
i have created two different message sets
1. TDS(source)
2.XML(target)
i am able to convert by moving fields individually.
i want to convert as you mentioned
while trying out this code
CREATE COMPUTE MODULE myCDFcompute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE targetPtr REFERENCE TO OutputRoot;
DECLARE sourcePtr REFERENCE TO InputRoot.BLOB.BLOB;
DECLARE ccsid INTEGER;
CALL CopyMessageHeaders();
SET ccsid = InputRoot.Properties.CodedCharSetId;
CREATE LASTCHILD OF targetPtr
domain('MRM')
PARSE(sourcePtr CCSID ccsid SET 'cdl' TYPE 'TopMostMsg' FORMAT 'TDS1' ) ;
SET OutputRoot.Properties.MessageFormat = 'XML1';
RETURN TRUE;
END;
... (copymsgheader sbrtn)
END MODULE;
this is the error it is giving
WBRK6_DEFAULT_BROKER.default ) ('.TDS_XML_Compute_Node_Compute.Main', '19.7') : The data type 'NULL' is not a valid data type for parameter 'BITSTREAM' of the 'CREATE' statement. This parameter should be of data type 'CHARACTER, BIT, BLOB'. The value passed was 'NULL'.
The 'BITSTREAM' parameter is not of the correct data type for this statement ( 'CREATE' ).
plz solve it |
|
Back to top |
|
 |
wschutz |
Posted: Thu Mar 30, 2006 5:01 pm Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
rajraj wrote: |
Hi jefflowrey |
I assume you mean me.
You're gettin that message because InputRoot.BLOB.BLOB is "null". Did you set the Default Message Domain on the MQInput node to
"BLOB"?
wschutz wrote: |
In the flow, I have a MQInput node (q:TESTIN) set to a default Message Domain of "BLOB", an... |
_________________ -wayne |
|
Back to top |
|
 |
JT |
Posted: Thu Mar 30, 2006 6:51 pm Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
Quote: |
CREATE COMPUTE MODULE myCDFcompute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE targetPtr REFERENCE TO OutputRoot;
DECLARE sourcePtr REFERENCE TO InputRoot.BLOB.BLOB;
DECLARE ccsid INTEGER;
CALL CopyMessageHeaders();
SET ccsid = InputRoot.Properties.CodedCharSetId;
CREATE LASTCHILD OF targetPtr
domain('MRM')
PARSE(sourcePtr CCSID ccsid SET 'cdl' TYPE 'TopMostMsg' FORMAT 'TDS1' ) ;
SET OutputRoot.Properties.MessageFormat = 'XML1';
RETURN TRUE;
END;
... (copymsgheader sbrtn)
END MODULE; |
Because you copy the message headers later in the code, rather than at the very beginning, I think you're also going to have a problem with the targetPtr reference. You're establishing a pointer to an object (re: OutputRoot) at a time when it doesn't exist, therefore targetPtr is NULL when you try to reference it in the CREATE LASTCHILD statement. |
|
Back to top |
|
 |
wschutz |
Posted: Thu Mar 30, 2006 7:05 pm Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
Are you sure? I think OutputRoot is created as soon as the node itself is....in any case, the code works wth both V5 and V6 of the broker. _________________ -wayne |
|
Back to top |
|
 |
JT |
Posted: Thu Mar 30, 2006 7:19 pm Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Mar 30, 2006 8:52 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
OutputRoot itself is created at node startup... or at least as soon as the Compute node code gets to the equivalent of new MBAssembly(...).
OutputRoot.<parser> is only created as soon as you actually do something to create it, like call CopyMessageHeaders. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|