ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » How to put a XML file into a XML field

Post new topic  Reply to topic Goto page 1, 2  Next
 How to put a XML file into a XML field « View previous topic :: View next topic » 
Author Message
pereira.allan1992
PostPosted: Wed Oct 21, 2015 9:00 am    Post subject: How to put a XML file into a XML field Reply with quote

Novice

Joined: 21 Oct 2015
Posts: 12

Hi all,

I'm starting to learn by my own Websphere Integration Bus, and I trying to do this but no success...

I have one XML file like this:

<CSV2XMLXSD>
<record>
<employee>Nome</employee>
<tel>Telefone</tel>
</record>
</CSV2XMLXSD>

and I would like to put all this content ( including '<CSV2XMLXSD>',<record>,<employee>,<tel>,</CSV2XMLXSD>,</record>, in a field inside other XML field (string 4000))

if possible converting < to %lt/ %gt (sorry, I dont know the exactly name)

EX:


<messageData>&lt;doc_type&gt;P&lt;/doc_type&gt;&lt;order_no&gt;2201
&lt;/order_no&gt;&lt;order_type&gt;N/B&lt;/order_type&gt;&lt;order_type
_desc&gt;PrimDia&lt;/order_type_desc&gt;&lt;supplier&gt;101&lt;/supplier
&gt;&lt;qc_ind&gt;N&lt;/qc_ind&gt;&lt;not_before_date&gt;2012-01-
17T00:00:00.000-
02:00&lt;/not_before_date&gt;&lt;not_after_date&gt;2012-01-
17T00:00:00.000-02:00&lt;/not_after_date&gt;&lt;otb_eow_date&gt;2012-
01-21T00:00:00.000-
02:00&lt;/otb_eow_date&gt;&lt;earliest_ship_date&gt;2012-01-
22T00:00:00.000-
02:00&lt;/earliest_ship_date&gt;&lt;latest_ship_date&gt;2012-02-
21T00:00:00.000-
02:00&lt;/latest_ship_date&gt;&lt;terms&gt;1&lt;/terms&gt;&lt;terms_code
&gt;1&lt;/terms_code&gt;&lt;freight_terms&gt;03&lt;/freight_terms&gt;&lt;
cust_order&gt;N&lt;/cust_order&gt;&lt;payment_method&gt;WT&lt;/payme
nt_method&gt;&lt;payment_method_desc&gt;Transfer魣ia
Eletr.&lt;/payment_method_desc&gt;&lt;ship_method&gt;30&lt;/ship_meth
od&gt;&lt;ship_method_desc&gt;Caminh⭬ Sem cont騮
er&lt;/ship_method_desc&gt;&lt;status&gt;A&lt;/status&gt;&lt;exchange_r
ate&gt;1&lt;/exchange_rate&gt;&lt;bill_to_id&gt;1000&lt;/bill_to_id&gt;&lt;
po_type&gt;1&lt;/po_type&gt;&lt;po_type_desc&gt;Compra para
Revenda&lt;/po_type_desc&gt;&lt;pre_mark_ind&gt;N&lt;/pre_mark_ind&
gt;&lt;currency_code&gt;BRL&lt;/currency_code&gt;&lt;pickup_date&gt;20
12-01-17T00:00:00.000-
02:00&lt;/pickup_date&gt;&lt;PODtl&gt;&lt;item&gt;100020033&lt;/item&gt
;&lt;physical_location_type&gt;S&lt;/physical_location_type&gt;&lt;physica
l_location&gt;11002&lt;/physical_location&gt;&lt;physical_qty_ordered&gt;
10&lt;/physical_qty_ordered&gt;&lt;unit_cost&gt;500&lt;/unit_cost&gt;&lt;o
rigin_country_id&gt;BR&lt;/origin_country_id&gt;&lt;supp_pack_size&gt;1&
lt;/supp_pack_size&gt;&lt;earliest_ship_date&gt;2012-01-
22T00:00:00.000-
02:00&lt;/earliest_ship_date&gt;&lt;latest_ship_date&gt;2012-02-
21T00:00:00.000-
02:00&lt;/latest_ship_date&gt;&lt;packing_method&gt;HANG&lt;/packing_
method&gt;&lt;round_lvl&gt;C&lt;/round_lvl&gt;&lt;POVirtualDtl&gt;&lt;loca
tion_type&gt;S&lt;/location_type&gt;&lt;location&gt;11002&lt;/location&gt;
&lt;qty_ordered&gt;10&lt;/qty_ordered&gt;&lt;/POVirtualDtl&gt;&lt;est_in_
stock_date&gt;2012-01-22T00:00:00.000-
02:00&lt;/est_in_stock_date&gt;&lt;/PODtl&gt;&lt;ns1:ExtOfPODesc
xmlns:ns1=&quot;gt;&lt;ns1:start_bill_date&gt;2012-02-17T00:00:00.000-
02:00&lt;/ns1:start_bill_date&gt;&lt;ns1:bill_type&gt;P&lt;/ns1:bill_type&gt
;&lt;/ns1:ExtOfPODesc&gt;&lt;/PODesc&gt;</messageData>

Im trying using InputFile Node, Mapping and OutputFile Node, No ESQL Custom, How can i do this please?

Thank you for the attention

Regards
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Oct 21, 2015 9:21 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

You need to map a string version of the input data into the appropriate type of XML field.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
pereira.allan1992
PostPosted: Wed Oct 21, 2015 10:26 am    Post subject: Reply with quote

Novice

Joined: 21 Oct 2015
Posts: 12

Thank you for your help.

I'm trying to do this for 2 weeks, but until today nothing...

Can you explain in detail to me how can i do this? Im trying to use the cast and this command too, but i cannot find any positive result

CREATE PROCEDURE CopyEntireMessage() BEGIN
DECLARE InputMessageData BLOB;
SET InputMessageData = ASBITSTREAM(InputRoot.XMLNSC);
SET OutputRoot = InputRoot;

Using a mapping with Blob input and messageData XSD (String) output
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Oct 21, 2015 10:35 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

The asbitstream is almost right. You probably want a CCSID.

The rest of it doesn't make any sense.

Where are you tyring to assign the result of the asbitstream to the message tree?
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
pereira.allan1992
PostPosted: Wed Oct 21, 2015 11:14 am    Post subject: Reply with quote

Novice

Joined: 21 Oct 2015
Posts: 12

Currently, Im trying to find what is my CCSID...

in My Compute Node, im trying to do this

DECLARE InputMessageData BLOB;
DECLARE decoded2 blob;
SET InputMessageData = ASBITSTREAM(InputRoot.XMLNSC);
SET decoded2 = CAST(InputMessageData as blob ccsid 1208);
--INSERT INTO Database.sys.aps_iit(teste) VALUES (InputMessageData);
--CALL CopyEntireMessage();
SET OutputRoot = decoded2;

I created a output file after this ComputeNode, but the file there is no data...i Dont know why....


I tried do this:

SET InputMessageData = ASBITSTREAM(InputRoot.XMLNSC);
SET OutputRoot = InputRoot;

and this,

SET InputMessageData = ASBITSTREAM(InputRoot.XMLNSC);
SET OutputRoot =InputMessageData;

but no success...


Thank you
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Oct 21, 2015 11:23 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

As Jeff told you, you need to look up your ASBITSTREM function and include the target CCSID into it.
You have then a BLOB in a known CCSID that you can cast to CHAR...
Insert the char at the right place in your output XML tree.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Wed Oct 21, 2015 11:52 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

pereira.allan1992 wrote:

Code:

SET InputMessageData = ASBITSTREAM(InputRoot.XMLNSC);
      SET decoded2 = CAST(InputMessageData as blob ccsid  1208);



The CCSID goes on the ASBITSTREAM. The result of an ASBITSTREAM is a BLOB so you don't need to cast it.

pereira.allan1992 wrote:

Code:

CALL CopyEntireMessage();
      SET OutputRoot = decoded2;


I created a output file after this ComputeNode, but the file there is no data...i Dont know why....


The OutputRoot tree has a specific structure. If you just assign a BLOB to it, you'll corrupt it.

pereira.allan1992 wrote:

Code:


SET InputMessageData = ASBITSTREAM(InputRoot.XMLNSC);
   SET OutputRoot = InputRoot;

and this,

SET InputMessageData = ASBITSTREAM(InputRoot.XMLNSC);
   SET OutputRoot =InputMessageData;

but no success...


See my comments above.

To obtain output, you need to have your data as the last child of the OutputRoot tree and you have to assign a domain (such as XMLNSC) so broker knows how to serialize it.

So you're better off sticking with your original plan and inserting it into an XML document.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
pereira.allan1992
PostPosted: Wed Oct 21, 2015 12:17 pm    Post subject: Reply with quote

Novice

Joined: 21 Oct 2015
Posts: 12

I believe that i have to back some steps, to learn how to configure the OutputRoot tree first...

I ll try to do this, and I return with a position

Thanks!!!
Back to top
View user's profile Send private message
pereira.allan1992
PostPosted: Thu Oct 22, 2015 4:00 am    Post subject: Reply with quote

Novice

Joined: 21 Oct 2015
Posts: 12

Morning All,

Please, i tried to do this, but I keep generate a file with no data. what I doing wrong?

I just have this in my compute node, when my compute node is making a connection with a outputFile

CREATE PROCEDURE CopyEntireMessage() BEGIN
SET OutputRoot.BLOB.BLOB=CAST (ASBITSTREAM(InputRoot.XMLNSC) AS BLOB CCSID 1208);

PS: My InputFile, is with Parser Option XMLNSC (is that correct)?

"So you're better off sticking with your original plan and inserting it into an XML document."

That is exactly what i trying to do, but nothing until now =(

Thank you
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Oct 22, 2015 4:19 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

pereira.allan1992 wrote:
Code:

CREATE PROCEDURE CopyEntireMessage() BEGIN
       
      SET OutputRoot.BLOB.BLOB=CAST (ASBITSTREAM(InputRoot.XMLNSC) AS BLOB CCSID 1208);



ASBITSTREAM is already returning a BLOB so don't cast it.

As well you need to add the CCSID to the ASBITSREAM function call.

And don't use canned IBM procedures for that... have something like: (check it for correctness as it is from memory)

Code:
CREATE FUNCTION MAIN RETURNS BOOLEAN
BEGIN
   CALL CopyHeaders();
   SET OutputRoot.BLOB.BLOB = ASBITSTREAM( InputRoot.XMLNSC.<roottagname>, options, ccsid,...);
   RETURN TRUE;

And make the options be something like RootBitStream (look it up in the infocenter)...
Have fun
_________________
MQ & Broker admin


Last edited by fjb_saper on Thu Oct 22, 2015 4:38 am; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Thu Oct 22, 2015 4:22 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

pereira.allan1992 wrote:
Please, i tried to do this, but I keep generate a file with no data. what I doing wrong?


Well:

pereira.allan1992 wrote:
Code:
CREATE PROCEDURE CopyEntireMessage() BEGIN
      SET OutputRoot.BLOB.BLOB=CAST (ASBITSTREAM(InputRoot.XMLNSC) AS BLOB CCSID 1208);



You've edited the IBM supplied procedure CopyEntireMessage (never a good idea) and you're removed the line copying the InputRoot to the OutputRoot. So once again you don't have an OutputRoot with the required structure, you have a OutputRoot with nothing but your data.


pereira.allan1992 wrote:

PS: My InputFile, is with Parser Option XMLNSC (is that correct)?


That's the correct option to parse an XML document.


pereira.allan1992 wrote:
Vitor wrote:
So you're better off sticking with your original plan and inserting it into an XML document."


That is exactly what i trying to do, but nothing until now =(


That is absolutely NOT what your code does. Your code takes a BLOB value and tries to output it. There's not one line about an output XML document, containing the input or nothing.

You're now at the point in learning IIB where you need to learn how to diagnose code problems. Okay, first you need to get your code out of the IBM supplied procedure - you'll be well served thinking very clearly about why IBM supplies them and how they can help you, because they can.

Your next step (if that doesn't fix your problem) is to run a user trace and determine what happens when you run your flow. Even if it works, a user trace will be informative and interesting, and is a skill you should develop.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
pereira.allan1992
PostPosted: Thu Oct 22, 2015 4:39 am    Post subject: Reply with quote

Novice

Joined: 21 Oct 2015
Posts: 12

Vitor wrote:
"That is absolutely NOT what your code does. Your code takes a BLOB value and tries to output it. There's not one line about an output XML document, containing the input or nothing. "


I know that, but m friend can do the XML file to a CLOB field in a oracle database, so I tried do the same...but putting in a XML Field this time....

Vitor wrote:
"There's not one line about an output XML document, containing the input or nothing. "


Because I dont know the syntax, I researched, and just find how to manipulate namespaces, fields, etc...but i want the Whole File, this i cannot find anything about that...

If possible, please, send me a link with i can learn about code manipulating XMLNSC whole files...

Thank you...
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Oct 22, 2015 4:43 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Go through the product's documentation (online) http://www-01.ibm.com/software/integration/ibm-integration-bus/library/


_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Thu Oct 22, 2015 5:10 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

pereira.allan1992 wrote:
Vitor wrote:
"That is absolutely NOT what your code does. Your code takes a BLOB value and tries to output it. There's not one line about an output XML document, containing the input or nothing. "


I know that, but m friend can do the XML file to a CLOB field in a oracle database, so I tried do the same...but putting in a XML Field this time....


What?

So an Oracle database can hold an XML document as a CLOB. An F5 can distribute an XML document as IP packets and that's as relevant to this. Also your original intent as stated was:

pereira.allan1992 wrote:
I would like to put all this content ( including '<CSV2XMLXSD>',<record>,<employee>,<tel>,</CSV2XMLXSD>,</record>, in a field inside other XML field (string 4000))


There's no reference to "other XML field" in your code.

pereira.allan1992 wrote:
If possible, please, send me a link with i can learn about code manipulating XMLNSC whole files...


That's most of the product documentation. All the product does is manipulate data, XML or otherwise, as an entire file or otherwise. There's no difference syntactically between manipulating all or part of an XML document; the ASBITREAM function is an example.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
pereira.allan1992
PostPosted: Thu Oct 22, 2015 5:44 am    Post subject: Reply with quote

Novice

Joined: 21 Oct 2015
Posts: 12

"There's no reference to "other XML field" in your code."

The reference is in the mapping...

"That's most of the product documentation. All the product does is manipulate data, XML or otherwise, as an entire file or otherwise. There's no difference syntactically between manipulating all or part of an XML document; the ASBITREAM function is an example."

ASBITSTREAM returns a BLOB,

"That is absolutely NOT what your code does. Your code takes a BLOB value and tries to output it. There's not one line about an output XML document, containing the input or nothing. "

Is it to use a BLOB or Not?

I readed the documentation, but I cannot develop reading the documentation, doesn't explain with details the example, is hard to learn this way...

SET OutputRoot = InputRoot;
-- CALL CopyMessageHeaders();
-- CALL CopyEntireMessage();
DECLARE InputMessageData BLOB;
SET InputMessageData = CAST(ASBITSTREAM(InputRoot.XMLNSC) AS BLOB CCSID 1208);
--SET OutputRoot.XMLNSC.MessageData = InputMessageData;
SET OutputRoot.XMLNSC.MESSAGEDATA = InputMessageData;

returning a BLOB now, but how can i convert BLOB , I tried ENCODE64 e DECODE64, but no success indeed...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » How to put a XML file into a XML field
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.