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 add a namespace prefix in XMLNSC in JavaCompute?

Post new topic  Reply to topic
 How to add a namespace prefix in XMLNSC in JavaCompute? « View previous topic :: View next topic » 
Author Message
issac
PostPosted: Sat Jun 04, 2011 7:16 pm    Post subject: How to add a namespace prefix in XMLNSC in JavaCompute? Reply with quote

Disciple

Joined: 02 Oct 2008
Posts: 158
Location: Shanghai

Hello,

I try to get this:

<vas:entryArrayM xmlnsc="...." xmlns:vas="http://futurehost.com/vas"><entry><...

I'm using this code:
Code:
MbElement outRoot = outMsg.getRootElement();
         outRoot.createElementAsFirstChild(MbXMLNSC.XML_DECLARATION);
         outRoot.createElementAsFirstChild(MbXMLNSC.ATTRIBUTE, "version", "1.0");
         outRoot.createElementAsFirstChild(MbXMLNSC.ATTRIBUTE, "encoding", "utf-8");
         outRoot.createElementAsFirstChild(MbXMLNSC.ATTRIBUTE, "standalone", "yes");
         MbElement outBody = outRoot.createElementAsLastChild("XMLNSC");
         MbElement entryArrayE = outBody.createElementAsLastChild(MbElement.TYPE_NAME, "entryArrayM", null);
         entryArrayE.createElementAsLastChild(MbXMLNSC.NAMESPACE_DECLARATION, "vas", "http://futurehost.com/vas");
         entryArrayE.setNamespace("http://futurehost.com/vas");


And I get:

<NS1:entryArrayM xmlns:NS1="http://futurehost.com/vas" vas="http://futurehost.com/vas"><entry>

Where did that NS1 come from? How to set the prefix in XMLNSC domain? Thanks!
_________________
Bazinga!
Back to top
View user's profile Send private message
jlaisbett
PostPosted: Sat Jun 04, 2011 9:23 pm    Post subject: Reply with quote

Apprentice

Joined: 27 Nov 2009
Posts: 39

You aren't far off, you just need to add a namespace of xmlns to your namespace declaration:

Code:
MbElement entryArrayE = outBody.createElementAsLastChild(MbElement.TYPE_NAME, "entryArrayM", null);
MbElement vasDecl = entryArrayE.createElementAsLastChild(MbXMLNSC.NAMESPACE_DECLARATION, "vas", "http://futurehost.com/vas");
vasDecl.setNamespace("xmlns");
entryArrayE.setNamespace("http://futurehost.com/vas");
Back to top
View user's profile Send private message
issac
PostPosted: Sun Jun 05, 2011 3:39 pm    Post subject: Reply with quote

Disciple

Joined: 02 Oct 2008
Posts: 158
Location: Shanghai

Thanks ! But now it outputs:

<NS1:entryArrayM xmlns:NS1="http://futurehost.com/vas" NS1:vas="http://futurehost.com/vas"><entr

There's still a mysterious NS1.
_________________
Bazinga!
Back to top
View user's profile Send private message
issac
PostPosted: Sun Jun 05, 2011 3:41 pm    Post subject: Aha, my bad Reply with quote

Disciple

Joined: 02 Oct 2008
Posts: 158
Location: Shanghai

I input it wrong. Your reply is ABSOLUTELY CORRECT! Thanks very much!
_________________
Bazinga!
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 » How to add a namespace prefix in XMLNSC in JavaCompute?
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.