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 » NamespaceDecl

Post new topic  Reply to topic
 NamespaceDecl « View previous topic :: View next topic » 
Author Message
duffMan
PostPosted: Sun Oct 19, 2008 12:01 pm    Post subject: NamespaceDecl Reply with quote

Voyager

Joined: 03 Jun 2002
Posts: 75

Hi,

I have some ESQL like:

SET OutputRoot.XMLNSC.MyRootTag.(XMLNSC.NamespaceDecl)xmlns = 'blah';

I expected output like:

<MyRootTag xmlns='blah'>

but what I am getting is:

<MyRootTag xmlns="" xmlsns="blah">

and of course the XMLNSC parses doesn't like it...

Does anybody know where that extra xmlns attribute came from?

I'm pretty sure it's not from somewhere else in the code, because if i comment out that single line, I simply get:

<MyRootTag>
Back to top
View user's profile Send private message
mqjeff
PostPosted: Sun Oct 19, 2008 12:07 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

This is an oddity.

Code:
SET OutputRoot.XMLNSC.MyRootTag.(XMLNSC.NamespaceDecl)"xmlns":"xmlns" = 'blah';


should fix it.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sun Oct 19, 2008 1:40 pm    Post subject: Reply with quote

Grand High Poobah

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

And here I thought that the broker frowned on the use of XML keywords in a context other than as defined by w3 orgs?
You should not name a namespace "xmlns" as this is a keyword for xml namespace declarations. Are you sure you weren't supposed to name it "tns" ?

Jeff I thought that this would have been solved with :
SET OutputRoot.XMLNSC.MyRootTag.(XMLNSC.NamespaceDecl)='blah';

or am I missing something ?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
broker_new
PostPosted: Sun Oct 19, 2008 2:01 pm    Post subject: Reply with quote

Yatiri

Joined: 30 Nov 2006
Posts: 614
Location: Washington DC

Follow this example,

DECLARE mySoapNS NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
DECLARE xsd NAMESPACE 'http://staples.com/xsd';
DECLARE soap NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
DECLARE cert NAMESPACE 'http://staples.com/certify';
DECLARE JME NAMESPACE 'http://staples.com/certify/UserAdmin';

SET OutputRoot.XMLNS.mySoapNS:Envelope.(XML.NamespaceDecl)xmlns:"soap" = 'http://schemas.xmlsoap.org/soap/envelope/';
SET OutputRoot.XMLNS.mySoapNS:Envelope.(XML.NamespaceDecl)xmlns:"cert" = 'http://staples.com/certify';
SET OutputRoot.XMLNS.mySoapNS:Envelope.(XML.NamespaceDecl)xmlns:"xsd" = 'http://ibm.com/xsd';

--Default namespace
SET OutputRoot.XMLNS.mySoapNS:Envelope.soap:Body.JME:Information.(XML.NamespaceDecl)xmlns = 'http://staples.com/certify/UserAdmin';
SET OutputRoot.XMLNS.mySoapNS:Envelope.soap:Body.JME:Information.JME:UserId = '34566775';
SET OutputRoot.Properties.MessageDomain = 'XMLNS';

RETURN TRUE;
END;

Statements in Bold letters helps to build the required output.
_________________
IBM ->Let's build a smarter planet
Back to top
View user's profile Send private message
duffMan
PostPosted: Sun Oct 19, 2008 4:18 pm    Post subject: Reply with quote

Voyager

Joined: 03 Jun 2002
Posts: 75

thanks guys...


mqjeff's code gives me:
<MyRootTag xmlns:xmlns="blah">


fjp's code gives me:
<MyRootTag ="blah">

broker_new got me in the right direction:

In order to get the default ns to show up the way I wanted I had to declare the namespace and qualify each element with it... i.e.

DECLARE b NAMESPACE 'blah';

SET OutputRoot.XMLNSC.b:MyRootTag.(XMLNSC.NamespaceDecl)"xmlns" = 'blah';
SET OutputRoot.XMLNSC.b:MyRootTag.b:subtag='foo';

This gives me:

<MyRootTag xmlns="blah">
<subtag>foo</subtag>
</MyRootTag>

thank-y'all
Back to top
View user's profile Send private message
mqjeff
PostPosted: Sun Oct 19, 2008 5:10 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

duffMan wrote:
mqjeff's code gives me:
<MyRootTag xmlns:xmlns="blah">


Are you using 6.1? This may have changed in 6.1. I haven't touched this code since 6.0.2.x, and it took me several tries to get it to work the way I showed.

I guess it's "better" in 6.1, if you are successful with
Code:
SET OutputRoot.XMLNSC.b:MyRootTag.(XMLNSC.NamespaceDecl)"xmlns" = 'blah';
Back to top
View user's profile Send private message
duffMan
PostPosted: Sun Oct 19, 2008 7:48 pm    Post subject: Reply with quote

Voyager

Joined: 03 Jun 2002
Posts: 75

I'm using 6.0.2....
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sun Oct 19, 2008 10:25 pm    Post subject: Reply with quote

Grand High Poobah

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

And of course this morning I realised that you did not just want to create the namespace declaration but also set the namespace
So it would have been at least:
SET OutputRoot.XMLNSC.MyRootTag NAMESPACE = 'blah';
as you were setting the namespace after the fact.

However the solution you found is the correct one as for the default namespace you have to set it for each element in the tree in the default namespace.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
crossland
PostPosted: Thu Mar 25, 2010 7:12 am    Post subject: Reply with quote

Master

Joined: 26 Jun 2001
Posts: 248

The aim of my code is also to change the namespace of the top branch.

The code is:

Code:

SET OutputRoot.XMLNSC.ns1:resp = InputRoot.XMLNSC.ns2:resp;
SET OutputRoot.XMLNSC.ns1:resp.(XMLNSC.NamespaceDecl) = ns1;


The result is a bit odd:
<ns2:resp xmlns:ns2="namespace for ns1">

whereas you would want:
<ns1:resp xmlns:ns1="namespace for ns1">

Anyone got round this?
Back to top
View user's profile Send private message
crossland
PostPosted: Thu Mar 25, 2010 7:55 am    Post subject: Reply with quote

Master

Joined: 26 Jun 2001
Posts: 248

Changed the code as follows:

Code:


SET OutputRoot.XMLNSC.ns1:resp = InputRoot.XMLNSC.ns2:resp;
SET OutputRoot.XMLNSC.ns1:resp.(XMLNSC.NamespaceDecl)xmlns:"ns1" = ns1;


The result is a bit better:

<ns1:resp xmlns:ns2="namespace for ns2" xmlns:ns1="namespace for ns1">

Just need to get rid of the xmlns:ns2="namespace for ns2" bit.
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Mar 25, 2010 8:14 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
The aim of my code is also to change the namespace of the top branch.
Be very careful. Do you want to
a) change the namespace for the root tag only or
b) change the default namespace, and so change the namespace throughout the document.

if b), you need to walk the message tree recursively and change the namespace of every node.
Back to top
View user's profile Send private message
crossland
PostPosted: Thu Mar 25, 2010 8:23 am    Post subject: Reply with quote

Master

Joined: 26 Jun 2001
Posts: 248

Just a!

Almost there ... just need to remove the 'xmlns:ns2="namespace for ns2"' part of
<ns1:resp xmlns:ns2="namespace for ns2" xmlns:ns1="namespace for ns1">
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Mar 25, 2010 8:29 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

I expect you inherited that namespace declaration from InputRoot when you copied to OutputRoot. Just delete it from OutputRoot. The debugger or a Trace node will tell you what the field type is, so that your DELETE statement can be safe and precise
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 » NamespaceDecl
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.