Author |
Message
|
aks |
Posted: Tue Apr 29, 2003 8:43 pm Post subject: Storing XML into a copybook field |
|
|
Voyager
Joined: 19 Jul 2002 Posts: 84
|
I've searched this forum for how to flatten an XML tree to convert it to a string. All I have found is to cast to bitstream, store in a database and then retrieve.
I need to convert part of my input XML to a string to store in a COBOL copybook field. (The dtd and copybook has been imported into separate messagesets in the MRM)
Can this be done easily?
Thanks
Alan |
|
Back to top |
|
 |
EgilsJ.Rubenis |
Posted: Wed Apr 30, 2003 3:19 am Post subject: |
|
|
Acolyte
Joined: 18 Nov 2002 Posts: 63 Location: Germany, Alfeld
|
Hi Alan,
i have a similair process. Incoming Data is XML, outgoing is Copybookstructure. I used a compute node for the mapping.
You could do the mapping by drag and drop (you have to choose the message sets for in/out in the compute node) or by entering the names like
SET "OutputRoot"."MRM"."STRUCTURENAME"."PROGRAMM" = "InputBody"."XML_TREE_1"."XML_TREE_2"."PROGRAMM"; |
|
Back to top |
|
 |
aks |
Posted: Wed Apr 30, 2003 4:40 am Post subject: |
|
|
Voyager
Joined: 19 Jul 2002 Posts: 84
|
I was probably unclear in my request. Yes, we convert XML to copybook format all the time, but in this instance I want to convert part of the XML tree into a string, keeping all the tag names with end tags etc (flattened out so to speak) and assign this XML string to a copybook field.
Thanks
Alan |
|
Back to top |
|
 |
drajib |
Posted: Wed Apr 30, 2003 5:25 am Post subject: |
|
|
 Apprentice
Joined: 25 Mar 2003 Posts: 42 Location: India
|
Hi Alan,
Just a thought -
Create a TDS message
MSG (Variable length delimited with <CR><LF>)
- XMLTreeFlattened (String without specifying length)
Use a RCD node to modify the XML input to MRM specifying MSG as the message.
SUBSTR from MSG.XMLTreeFlattened for the required output
Hope it works,
Rajib. |
|
Back to top |
|
 |
RamVijayawada |
Posted: Wed Apr 30, 2003 7:09 am Post subject: |
|
|
Novice
Joined: 22 Apr 2003 Posts: 15
|
Whatz the problem in casting as BITSTREAM and taking a substring for the BITSTREAM..... All you need is part of the message.. u can get by substring .... I hope i'm talking what u want . don't I |
|
Back to top |
|
 |
aks |
Posted: Wed Apr 30, 2003 7:04 pm Post subject: |
|
|
Voyager
Joined: 19 Jul 2002 Posts: 84
|
Thanks for all the replies.
I'm seeing some success by casting as BITSTREAM but am getting another problem now.
For example, I start with the XML
<A>
<B>
<C>
<D>1</D>
<D/>2</D>
<D>3</D>
</C>
</B>
</A>
I want to store <C> and all child nodes in the copybook field as a string,
thus it would like like '<C><D>1</D><D/>2</D><D>3</D></C>'
The code I used was this:
DECLARE cRef REFERENCE TO InputRoot.XML."A"."B"."C";
SET <some copybook field> = CAST(BITSTREAM(cRef) AS CHARACTER CCSID 1208);
What is getting stored is the whole tree, ie '<A><B><C><D>1</D><D/>2</D><D>3</D></C></B></A>'
This is a start, but I only want the C and D nodes
What am I doing wrong?
Thanks
Alan |
|
Back to top |
|
 |
warrenpage |
Posted: Wed Apr 30, 2003 9:02 pm Post subject: |
|
|
Acolyte
Joined: 19 Feb 2002 Posts: 56 Location: Australia
|
If you have CSD3 or CSD4
You should use ASBITSTREAM function instead of BITSTREAM
DECLARE cRef REFERENCE TO InputRoot.XML."A"."B"."C";
SET <some copybook field> = CAST(ASBITSTREAM(cRef) AS CHARACTER CCSID 1208);
or just
SET <some copybook field> = CAST(ASBITSTREAM(InputRoot.XML.A.B.C) AS CHARACTER CCSID 1208);
The BITSTREAM function takes the original inputmsgs where as ASBITSTREAM starts at the node specified. |
|
Back to top |
|
 |
aks |
Posted: Wed Apr 30, 2003 10:21 pm Post subject: |
|
|
Voyager
Joined: 19 Jul 2002 Posts: 84
|
Thanks Warren.
It's close to working, but using ASBITSTREAM as in your example, I get an exception:
ParserException BIP5136E: Invalid Wire Format Identifier ''.
I suspect it is because I am using MRM XML, ie, I have imported a DTD and refer to elements as InputRoot.MRM.Policy, where Policy is a child of the root element of the DTD.
My input to the ASBITSREAM is an MRM reference further down the tree.
Is there any options to specify? |
|
Back to top |
|
 |
|