|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
How to add a namespace prefix in XMLNSC in JavaCompute? |
« View previous topic :: View next topic » |
Author |
Message
|
issac |
Posted: Sat Jun 04, 2011 7:16 pm Post subject: How to add a namespace prefix in XMLNSC in JavaCompute? |
|
|
 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 |
|
 |
jlaisbett |
Posted: Sat Jun 04, 2011 9:23 pm Post subject: |
|
|
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 |
|
 |
issac |
Posted: Sun Jun 05, 2011 3:39 pm Post subject: |
|
|
 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 |
|
 |
issac |
Posted: Sun Jun 05, 2011 3:41 pm Post subject: Aha, my bad |
|
|
 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 |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|