Author |
Message
|
mq one |
Posted: Sun Aug 15, 2004 6:30 pm Post subject: String to XML |
|
|
Newbie
Joined: 14 Apr 2004 Posts: 6
|
I know we had a lot of topics with ASBITSTREAM and I expect that is what I have to use. My problem is, that I have a String with contains valid XML and I want to take this string and move it to a position, if possible in the Environment tree, as XML.
Sample my string looks like
<txt><grp>g1</grp><grp>g2</grp></txt>
my Environment
<Environment><Data><msg>m1</msg><msg>m2</msg></Environment>
and I want to achieve this <Environment><Data><msg>m1</msg><msg>m2</msg><txt><grp>g1</grp><grp>g2</grp></txt></Environment>
I can't use the RCD node and if possible the preferred option is one compute node. I am using WMQI v2.1 CSD5
Thanks for any help  |
|
Back to top |
|
 |
JT |
Posted: Sun Aug 15, 2004 8:16 pm Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
Take a look at the CREATE statement. Details can be found in the ESQL Reference manual.
For example:
Code: |
CREATE LASTCHILD OF Environment.Data DOMAIN('XML') PARSE(ASBITSTREAM(MyXMLString),InputRoot.MQMD.Encoding,InputRoot.MQMD.CodedCharSetId) |
|
|
Back to top |
|
 |
mq one |
Posted: Mon Aug 16, 2004 8:55 pm Post subject: |
|
|
Newbie
Joined: 14 Apr 2004 Posts: 6
|
If I try this I get in the trace the following The result was 'X''' and the tree is empty.
Regards |
|
Back to top |
|
 |
aks |
Posted: Mon Aug 16, 2004 9:32 pm Post subject: |
|
|
Voyager
Joined: 19 Jul 2002 Posts: 84
|
I had a requirement some time ago to insert XML (that was stored as a string in a field on a mainframe COBOL application) in a designated position in an XML tree. The code was a follows (the tempChar variable has the XML as a string, and tempRef is just a temporary reference variable):
MOVE tempRef TO policyRefO."Insured";
DECLARE tempBlob BLOB CAST(tempChar AS BLOB CCSID 1208);
CREATE LASTCHILD OF tempRef.temp DOMAIN('XML') PARSE(tempBlob, MQENC_INTEGER_NORMAL, 1208);
SET tempRef = tempRef.temp.XML."Insured";
SET tempRef.temp = NULL;
This may work for you:
DECLARE tempBlob BLOB CAST('<txt><grp>g1</grp><grp>g2</grp></txt>' AS BLOB CCSID 1208);
CREATE LASTCHILD OF Environment.Data DOMAIN('XML') PARSE (tempBlob, MQENC_INTEGER_NORMAL, 1208);
Regards
Alan |
|
Back to top |
|
 |
mq one |
Posted: Tue Aug 17, 2004 1:53 am Post subject: |
|
|
Newbie
Joined: 14 Apr 2004 Posts: 6
|
The result is also an empty field!!  |
|
Back to top |
|
 |
aks |
Posted: Tue Aug 17, 2004 4:12 pm Post subject: |
|
|
Voyager
Joined: 19 Jul 2002 Posts: 84
|
Strange - it seems to work for me. The code above produced the following (Enviornment) trace directly after the compute node:
(
(0x01000000):Data = (
(0x01000010):XML = (
(0x01000000):txt = (
(0x01000000):grp = (
(0x02000000): = 'g1'
)
(0x01000000):grp = (
(0x02000000): = 'g2'
)
)
)
)
)
I haven't started with your first piece of XML (ie appending the 2nd xml string), but adding the 2nd XML as a string to the Environment tree works OK. I also added the line
SET OutputRoot.XML = Environment.Data;
to the flow and saw the xml message on the output queue:
<XML>
<txt>
<grp>g1</grp>
<grp>g2</grp>
</txt>
</XML>
Alan |
|
Back to top |
|
 |
mq one |
Posted: Tue Aug 17, 2004 7:39 pm Post subject: |
|
|
Newbie
Joined: 14 Apr 2004 Posts: 6
|
Alan,
Thanks, it works nicely!! No idea, why I had those problems  |
|
Back to top |
|
 |
|