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 » Namespace in XML Message Body

Post new topic  Reply to topic
 Namespace in XML Message Body « View previous topic :: View next topic » 
Author Message
shwe
PostPosted: Wed Jun 26, 2013 5:35 am    Post subject: Namespace in XML Message Body Reply with quote

Novice

Joined: 28 Dec 2012
Posts: 13

Hi,

I have to generate an XML file in the below format

<?xml version="1.0" encoding="UTF-8" ?>
<IR001A
xsi:schemaLocation="http://apisit.hr/b28/inst/ed/2011/ir001a instIr001a.xsd" xmlns="http://apisit.hr/b28/inst/ed/2011/ir001a" xmlns:ct="http://apisit.hr/b28/inst/ed/2011/complexTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Envelope>
<Header>
<FlowOfGoods>1</FlowOfGoods>
<PSI>
<ct:PSIId>
<ct:PSICountryCode>HR</ct:PSICountryCode>
<ct:PSIId>
</PSI>
</Header>
</IR001A>
<Envelope>

I am able to get the headers right, but problem is while generating the message body with namespace.

This is my ESQL code

DECLARE ct NAMESPACE 'http://apisit.hr/b28/inst/ed/2011/complexTypes';

SET OutputRoot.XMLNSC.IR001A.(XMLNSC.Attribute)"xsi:schemaLocation" value ='http://apisit.hr/b28/inst/ed/2011/ir001a instIr001a.xsd';

SET OutputRoot.XMLNSC.IR001A.(XMLNSC.Attribute)"xmlnsc:ct" value = ct;
SET OutputRoot.XMLNSC.IR001A.(XMLNSC.Attribute)"xmlns:xsi" value = 'http://www.w3.org/2001/XMLSchema-instance';
SET OutputRoot.XMLNSC.IR001A.(XMLNSC.Attribute)"xmlnsc" value = 'http://apisit.hr/b28/inst/ed/2011/ir001a';

SET outRef.IR001A.Envelope.Header.FlowOfGoods = 'A';

SET outRef.IR001A.Envelope.Header.PSI.ct:"PSIId".ct:"PSICountryCode" ='SK987';

This is generating output as

<?xml version="1.0" encoding="UTF-8"?>
<IR001A xsi:schemaLocation="http://apisit.hr/b28/inst/ed/2011/ir001a instIr001a.xsd" xmlnsc:ct="http://apisit.hr/b28/inst/ed/2011/complexTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlnsc="http://apisit.hr/b28/inst/ed/2011/ir001a">
<Envelope>
<Header>
<FlowOfGoods>A</FlowOfGoods>
<PSI>
<NS1:PSIId xmlns:NS1="http://apisit.hr/b28/inst/ed/2011/complexTypes">
<NS1:PSICountryCode>SK987</NS1:PSICountryCode>
</NS1:PSIId>
</PSI>
</Header>
</Envelope>
</IR001A>

How do I get rid of NS1 and namespace and get ct instead in the message body?
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Jun 26, 2013 5:41 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

  1. Why do you want to? Is it strictly necessary? Are you really really really sure?
  2. You need to add the necessary parts of the logical message tree to describe the "xmlns:ct="http://apisit.hr/b28/inst/ed/2011/complexTypes" " data
Back to top
View user's profile Send private message
shwe
PostPosted: Wed Jun 26, 2013 5:48 am    Post subject: Reply with quote

Novice

Joined: 28 Dec 2012
Posts: 13

1) This is the requirement from client, so it is a necessary

2) Can you please tell me what are the necessary parts that needs to be added?
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Jun 26, 2013 5:49 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Search for 'XMLNSC namespace declaration' in the info center. It is described in detail, with examples.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Jun 26, 2013 6:09 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

shwe wrote:
1) This is the requirement from client, so it is a necessary

Have you had a conversation with them about why they made it a requirement?
Back to top
View user's profile Send private message
vishnurajnr
PostPosted: Wed Jun 26, 2013 6:30 am    Post subject: Reply with quote

Centurion

Joined: 08 Aug 2011
Posts: 134
Location: Trivandrum

if you use
Code:
OutputRoot.XMLNS
Instead of
Code:
OutputRoot.XMLNSC
it will fix your issue.

But I think its not a recommended style.
_________________
-------
A man is great by deeds, not by birth...!
Back to top
View user's profile Send private message Visit poster's website
Vitor
PostPosted: Wed Jun 26, 2013 6:31 am    Post subject: Reply with quote

Grand High Poobah

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

vishnurajnr wrote:
if you use
Code:
OutputRoot.XMLNS
Instead of
Code:
OutputRoot.XMLNSC
it will fix your issue.


How?

vishnurajnr wrote:
But I think its not a recommended style.


Very not recommended.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Jun 26, 2013 6:33 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Vitor wrote:
vishnurajnr wrote:
But I think its not a recommended style.


Very not recommended.

especially when it's not a terribly meaningful issue and there's also direct, clear, easily findable examples of how to "fix" it without doing anything drastic.

Please don't use XMLNS parser.
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Jun 26, 2013 6:34 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

@vishnurajnr: That advice is 100% incorrect. I have no idea why you think that using the XMLNS parser will make any difference. It will not.
Back to top
View user's profile Send private message
vishnurajnr
PostPosted: Wed Jun 26, 2013 7:22 am    Post subject: Reply with quote

Centurion

Joined: 08 Aug 2011
Posts: 134
Location: Trivandrum

Sorry, if I overlook into the Post.

I think the OP's Code is missing the NameSpace setting.

Code:
SET OutputRoot.XMLNSC.IR001A.(XMLNSC.NamespaceDecl)xmlns:ct  = ct;

_________________
-------
A man is great by deeds, not by birth...!
Back to top
View user's profile Send private message Visit poster's website
kimbert
PostPosted: Wed Jun 26, 2013 7:25 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

No, that's still incorrect. Thanks for trying
Back to top
View user's profile Send private message
vishnurajnr
PostPosted: Wed Jun 26, 2013 7:34 am    Post subject: Reply with quote

Centurion

Joined: 08 Aug 2011
Posts: 134
Location: Trivandrum

Have tried the OP's code except the above change:
Code:
DECLARE ct NAMESPACE 'http://apisit.hr/b28/inst/ed/2011/complexTypes';

SET OutputRoot.XMLNSC.IR001A.(XMLNSC.Attribute)"xsi:schemaLocation" value ='http://apisit.hr/b28/inst/ed/2011/ir001a instIr001a.xsd';
[b]SET OutputRoot.XMLNSC.IR001A.(XMLNSC.NamespaceDecl)xmlns:ct  = ct;[/b]
SET OutputRoot.XMLNSC.IR001A.(XMLNSC.Attribute)"xmlns:xsi" value = 'http://www.w3.org/2001/XMLSchema-instance';
SET OutputRoot.XMLNSC.IR001A.(XMLNSC.Attribute)"xmlnsc" value = 'http://apisit.hr/b28/inst/ed/2011/ir001a';

DECLARE outRef REFERENCE    TO OutputRoot.XMLNSC;      
SET outRef.IR001A.Envelope.Header.FlowOfGoods = 'A';
SET outRef.IR001A.Envelope.Header.PSI.ct:"PSIId".ct:"PSICountryCode" ='SK987';


It produce the Output as :
Code:
<IR001A xsi:schemaLocation="http://apisit.hr/b28/inst/ed/2011/ir001a instIr001a.xsd" xmlns:ct="http://apisit.hr/b28/inst/ed/2011/complexTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlnsc="http://apisit.hr/b28/inst/ed/2011/ir001a">
 <Envelope>
  <Header>
   <FlowOfGoods>A</FlowOfGoods>
   <PSI>
    <ct:PSIId>
     <ct:PSICountryCode>SK987</ct:PSICountryCode>
    </ct:PSIId>
   </PSI>
  </Header>
 </Envelope>
</IR001A>


So How..??


_________________
-------
A man is great by deeds, not by birth...!
Back to top
View user's profile Send private message Visit poster's website
kimbert
PostPosted: Wed Jun 26, 2013 7:41 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

You're right. I read your line of code as
Code:
SET OutputRoot.XMLNSC.IR001A.(XMLNSC.NamespaceDecl)xmlns:ct  = "ct";
Sorry for the false alarm.
Back to top
View user's profile Send private message
shwe
PostPosted: Wed Jun 26, 2013 11:08 pm    Post subject: Reply with quote

Novice

Joined: 28 Dec 2012
Posts: 13

Thanks all for the reply.

I got the solution as per vishnurajnr's advice, by declaring the Nameapce rightly.
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 » Namespace in XML Message Body
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.