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 » ASBITSTREAM for XMLNSC

Post new topic  Reply to topic
 ASBITSTREAM for XMLNSC « View previous topic :: View next topic » 
Author Message
newtobroker
PostPosted: Sat Feb 06, 2010 2:26 pm    Post subject: ASBITSTREAM for XMLNSC Reply with quote

Novice

Joined: 04 Feb 2010
Posts: 23

Hi,

I have an XML in string format as below
Code:

<o:Test xmlns:o="http://abcd.com/service/testing"><o:Name>Carol</o:Name><o:Addr>Addr123</o:Addr></o:Test>


I have to attach this XML to the Envelope Tag which is

Code:

<Envelope>
<ID>A123</ID>
<Company>ABC</Company>
</Envelope>


So the output should finally look like

Code:

<Envelope>
<ID>A123</ID>
<Company>ABC</Company>
<o:Test xmlns:o="http://abcd.com/service/testing"><o:Name>Carol</o:Name><o:Addr>Addr123</o:Addr></o:Test>
</Envelope>


Im using XMLNSC parser in my code.

I tried the below way

Code:


--- Environment.Variables.TestXML contains the TestXML   
       SET OutputRoot.XMLNSC.Envelope.(XMLNSC.AsisElementContent)Orch = Environment.Variables.TestXML;       
                      
               DECLARE blobOrcMsg BLOB;            
              
               -- Converting the retrieved Message Content to bitstream for parsing with XML Parser.
               SET blobOrcMsg = ASBITSTREAM(OutputRoot.XMLNSC.Envelope.Orch ENCODING InputRoot.Properties.Encoding
                                 CCSID InputRoot.Properties.CodedCharSetId SET '' TYPE '' FORMAT '' OPTIONS FolderBitStream);       
              
                SET blobOrcMsg = SUBSTRING(blobOrcMsg FROM 7 FOR ((LENGTH(blobOrcMsg) - 13)));
              
               SET OutputRoot.XMLNSC.RPEnvelope.Orch = NULL;

               CREATE LASTCHILD OF OutputRoot.XMLNSC.Envelope  DOMAIN 'XMLNSC'
                           PARSE (blobOrcMsg, InputRoot.Properties.Encoding, InputRoot.Properties.CodedCharSetId,
                           '', '', 'XMLNSC');
                          
               -- Pointing Reference variables to required elements/tags
               DECLARE RefEnvIFXMsg REFERENCE TO OutputRoot.XMLNSC.Envelope.XMLNSC.Orch;
               Detach RefEnvIFXMsg;
               SET OutputRoot.XMLNSC.Envelope.XMLNSC = NULL;
               ATTACH RefEnvIFXMsg TO OutputRoot.XMLNSC.Envelope AS LASTCHILD;     




But I'm getting an error at

Code:

 SET blobOrcMsg = ASBITSTREAM(OutputRoot.XMLNSC.Envelope.Orch ENCODING InputRoot.Properties.Encoding
                                 CCSID InputRoot.Properties.CodedCharSetId SET '' TYPE '' FORMAT '' OPTIONS FolderBitStream);       


The Error is

Code:

<Text>XML Writing Errors have occurred</Text>
- <ParserException>
  <File>/build/S610P/src/MTI/MTIforBroker/GenXmlParser4/ImbXMLNSCWriter.cpp</File>
  <Line>229</Line>
  <Function>ImbXMLNSCWriter::writeBuffer</Function>
  <Type />
  <Name />
  <Label />
  <Catalog>BIPv610</Catalog>
  <Severity>3</Severity>
  <Number>5907</Number>
  <Text>Invalid target for folder bitstream</Text>
- <Insert>
  <Type>5</Type>
  <Text>Orch</Text>
  </Insert>
- <Insert>
  <Type>2</Type>
  <Text>50333184</Text>
  </Insert>
- <Insert>
  <Type>5</Type>
  <Text><o:Test xmlns:o="http://abcd.com/service/testing"><o:Name>Carol</o:Name><o:Addr>Addr123</o:Addr></o:Test></Text>
  </Insert>



What can be going wrong here ? This code was working when it was XML, now i changed to XMLNSC and it breaks.
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Feb 08, 2010 4:41 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Please can you post the entire error message. The exception list is not very useful on its own.
You can get the full text from Windows Event Viewer, or by taking a user trace if you're not using Windows.
Back to top
View user's profile Send private message
newtobroker
PostPosted: Wed Feb 10, 2010 12:51 pm    Post subject: Reply with quote

Novice

Joined: 04 Feb 2010
Posts: 23

Hi Kimbert,

The broker is on z/os so i dont know how to get you the dump of the trace. Anyhow in my trace, i can see that the env variable is populated with the xml, but its giving the error while attaching it to XMLNSC.

In short the question is how to attach an XML that has a namespace to another XML that doesnt have a namespace and using XMLNSC parser?

Input XML1
Code:

<o:Test xmlns:o="http://abcd.com/service/testing"><o:Name>Carol</o:Name><o:Addr>Addr123</o:Addr></o:Test>


Input XML2
Code:

<Envelope>
<ID>A123</ID>
<Company>ABC</Company>
</Envelope>


The final output should look like
Code:

<Envelope>
<ID>A123</ID>
<Company>ABC</Company>
<o:Test xmlns:o="http://abcd.com/service/testing"><o:Name>Carol</o:Name><o:Addr>Addr123</o:Addr></o:Test>
</Envelope>


Thank,
c*
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Feb 10, 2010 3:40 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

I think this is your requirement:
- there is an XML subtree stored as a CHARACTER field in Environment.XML.TestXML.
- You want to add it as the last child of OutputRoot.XMLNSC.Envelope.

I suggest this:
Code:
DECLARE testXMLasBLOB BLOB CAST Environment.XML.testXML AS BLOB CCSID 1208;
CREATE LASTCHILD OF OutputRoot.XMLNSC.Envelope PARSE testXMLasBLOB CCSID 1208;
Normally you need a DOMAIN clause when using CREATE...PARSE, but I think in this case it will inherit the domain from InputRoot.XMLNSC.Envelope. mgk is welcome to correct me on that.

btw, I don't recommend the use of XMLNSC.AsIsElementContent. The docs make clear that it should only be used if nothing else will do the job.
Back to top
View user's profile Send private message
newtobroker
PostPosted: Wed Feb 10, 2010 8:08 pm    Post subject: Reply with quote

Novice

Joined: 04 Feb 2010
Posts: 23

Kimbert, this is cool.. it worked.. Thanks !!
I'm not using XMLNSC.AsIsElementContent.
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Feb 11, 2010 7:23 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

This should also work, and is even simpler:
Code:
CREATE LASTCHILD OF OutputRoot.XMLNSC.Envelope PARSE Environment.XML.testXML CCSID 1208;

I didn't realize that CREATE...PARSE can take a CHARACTER or BIT field instead of a BLOB.
Back to top
View user's profile Send private message
newtobroker
PostPosted: Thu Feb 11, 2010 6:10 pm    Post subject: Reply with quote

Novice

Joined: 04 Feb 2010
Posts: 23

Kimbert,

One thing that i noticed today is that there is an XMLNSC tag getting added extra to the xml. The output now looks like

Code:

<Envelope>
<ID>A123</ID>
<Company>ABC</Company>
<XMLNSC>
<o:Test xmlns:o="http://abcd.com/service/testing"><o:Name>Carol</o:Name><o:Addr>Addr123</o:Addr></o:Test>
</XMLNSC>
</Envelope>


whereas it should be something like below
Code:

<Envelope>
<ID>A123</ID>
<Company>ABC</Company>
<o:Test xmlns:o="http://abcd.com/service/testing"><o:Name>Carol</o:Name><o:Addr>Addr123</o:Addr></o:Test>
</Envelope>


How to remove this extra XMLNSC ?

Thanks,
C*
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Feb 12, 2010 12:34 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Like this:
Code:
CREATE LASTCHILD OF OutputRoot.XMLNSC.Envelope PARSE Environment.XML.testXML CCSID 1208 OPTIONS FolderBitStream;
Back to top
View user's profile Send private message
newtobroker
PostPosted: Fri Feb 12, 2010 11:10 pm    Post subject: Reply with quote

Novice

Joined: 04 Feb 2010
Posts: 23

Kimbert,

Thanks, I will try this option and let you know. Meanwhile im enjoying htis forum. This site has great SME's.

Thanks
C*
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ASBITSTREAM for XMLNSC
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.