|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Java Node - Creating new message. No attributes set |
« View previous topic :: View next topic » |
Author |
Message
|
jimc |
Posted: Tue Mar 11, 2008 2:47 am Post subject: Java Node - Creating new message. No attributes set |
|
|
Newbie
Joined: 11 Mar 2008 Posts: 3
|
Hi, I am trying to create a new message using Java Node.
Code doesn't seem to set Attributes - just creates it as new tag.
Code snippet:
MbElement root = outMessage.getRootElement();
MbElement outBody = root.createElementAsLastChild(MbXMLNSC.PARSER_NAME);
MbElement document = outBody.createElementAsLastChild(MbElement.TYPE_NAME,"document",null);
MbElement chapter = document.createElementAsFirstChild(MbElement.TYPE_NAME,"Chapter",null);
MbElement title = chapter.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"Title","new chapter");
XML Created is:-
<document><Chapter/><Title>new chapter</Title></document>
XML wanted:-
<document><Chapter title="new chapter"></Chapter></document>
Any help appreciated
Thanks
Jim |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Mar 11, 2008 3:17 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Hi, this is not an MQ Workflow question, apparently.
It seems it's a Message Broker Question.
Mods - please move.
You need to do the Java equivalent of
Code: |
set OutputRoot.XMLNSC.document.chapter.(XMLNSC.Attribute)title = ;new chapter'; |
This is done by setting the parser specific type on your MbElement. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
jimc |
Posted: Tue Mar 11, 2008 5:14 am Post subject: re |
|
|
Newbie
Joined: 11 Mar 2008 Posts: 3
|
IBM sites imply doing the following piece of code below - but this just creates a new tag for me rather than attribute.
Most examples seem to transform the input message rather than create message from scratch.
MbElement title = chapter.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"Title","new chapter"); |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Mar 11, 2008 5:18 am Post subject: Re: re |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
jimc wrote: |
IBM sites imply doing the following piece of code below -
MbElement title = chapter.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"Title","new chapter"); |
That is necessary, but not sufficient. As you say, it creates the MbElement, but as an XMLNSC.Element rather than an XMLNSC.Attribute.
You need to also set the parser specific type. I'd recommend a review of the MbElement class definition to further understand what I'm telling. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
kimbert |
Posted: Tue Mar 11, 2008 2:46 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
|
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
|
|
|
|