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 » Java Node - Creating new message. No attributes set

Post new topic  Reply to topic
 Java Node - Creating new message. No attributes set « View previous topic :: View next topic » 
Author Message
jimc
PostPosted: Tue Mar 11, 2008 2:47 am    Post subject: Java Node - Creating new message. No attributes set Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Tue Mar 11, 2008 3:17 am    Post subject: Reply with quote

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
View user's profile Send private message
jimc
PostPosted: Tue Mar 11, 2008 5:14 am    Post subject: re Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Tue Mar 11, 2008 5:18 am    Post subject: Re: re Reply with quote

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
View user's profile Send private message
kimbert
PostPosted: Tue Mar 11, 2008 2:46 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

XMLNS and XMLNSC are different parsers, and they use different field type constants to indicate attributes, comments, processing instructions etc.
For XMLNS, MbElement.TYPE_NAME_VALUE is indeed equivalent to XML.Attribute. The docs which suggest using this technique were probably written pre-v6.0, when XML and XMLNS were the only XML domains available.

Anyway, the answers you need are here: http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/topic/com.ibm.etools.mft.doc/ad21074_.htm
and here: http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/topic/com.ibm.etools.mft.doc/ac76040_.htm
along with quite a lot of other useful info.
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 » Java Node - Creating new message. No attributes set
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.