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 distinguish Attributes from other NameValue elements

Post new topic  Reply to topic
 How to distinguish Attributes from other NameValue elements « View previous topic :: View next topic » 
Author Message
oli
PostPosted: Mon Feb 04, 2008 1:41 am    Post subject: How to distinguish Attributes from other NameValue elements Reply with quote

Acolyte

Joined: 14 Jul 2006
Posts: 68
Location: Germany

Hi all,

in a java plug-in node I need to distinguish a XML attribute from other XML NameValue elements, i.e. I have to distingiush

<mytag name="value"></mytag>

and

<mytag><name>value</name></mytag>.

In both cases the MbElement.getType() returns MbElement.TYPE_NAME_VALUE for the element "name".

Does anybody know how to do this???

Thanks,

Oli
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Feb 04, 2008 5:08 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

You need getSpecificType(), not getType().
http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/topic/com.ibm.etools.mft.doc/com/ibm/broker/plugin/MbElement.html#getSpecificType()
Back to top
View user's profile Send private message
oli
PostPosted: Mon Feb 04, 2008 8:09 am    Post subject: Reply with quote

Acolyte

Joined: 14 Jul 2006
Posts: 68
Location: Germany

Hi kimbert,

I already found this method and I found out that the value returned by getSpecificType() for a XML attribute differs from the value returned for other NameValue elements. Unfortunately I can't find any documentation how the value can be interpreted. A constant like MbElement.TYPE_NAME_VALUE seems not to exist and the only thing I can do is to check whether the value returned by getSpecificType() is equal to MbElement.TYPE_NAME_VALUE or not.

Thanks,

Oli
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Feb 04, 2008 8:21 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/index.jsp?topic=/com.ibm.etools.mft.doc/ac26040_.htm

http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/index.jsp?topic=/com.ibm.etools.mft.doc/com/ibm/broker/plugin/MbXMLNSC.html

http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/index.jsp?topic=/com.ibm.etools.mft.doc/com/ibm/broker/plugin/MbXMLNS.html
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Feb 04, 2008 8:25 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
I already found this method
Then you should have said so in your original post.

Quote:
I can't find any documentation how the value can be interpreted
Go to here: http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/topic/com.ibm.etools.mft.doc/com/ibm/broker/plugin/package-overview.html
and follow the link to MbXML. All of the constants listed for the XML parser apply equally to the XMLNS parser ( but not to the XMLNSC parser, which uses a different set of constants ).
Back to top
View user's profile Send private message
oli
PostPosted: Mon Feb 04, 2008 8:58 am    Post subject: Reply with quote

Acolyte

Joined: 14 Jul 2006
Posts: 68
Location: Germany

Thanks for your help. I hope that I can get my problems solved with this Information
Back to top
View user's profile Send private message
oli
PostPosted: Tue Feb 05, 2008 3:57 am    Post subject: Reply with quote

Acolyte

Joined: 14 Jul 2006
Posts: 68
Location: Germany

Hi again,

after doing some analysis I still have questions and don't understand how to determine if a MbElement is a XML attribute.
I have the following XML message:

Code:
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<Data>
 <Application name="App1">
  <Customer>
   <Name>Jim</Name>
  </Customer>
 </Application>
</Data>


My Java Plug-in node doesn't know what the message domain is. The Java Plug-in node now calls
Code:
aMbMessageAssembly.getMessage().evaluateXPath("/Data/Application")

which returns the Application element. The first child of this element is the attribute.

And now I'm at the point where I must determine if this child is a XML attribute or not and for me it's not clear how to do this. For me the only possibility seems to be to do the following:

Check if the specific type of the element is MbXMLNSC.ATTRIBUTE. If so then we have an attribute. If not check the specific type with respect to the parser and do something like that:
Code:
if (theElement.getType() == MbElement.TYPE_NAME_VALUE) {
    String elemParser = theMbElement.getParserClassName(); (that returns for example 'xmlns' in lowercases)
    if (elemParser.equalsIgnoreCase(MbXMLNS.PARSER_NAME) || elemParser.equalsIgnoreCase(MbXML.PARSER_NAME)) {
        // We have an attribute
    }
}


Is this the way the API is used or is there any other way to determine if an MbElement is an attribute?

Thanks,

Oli
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Feb 05, 2008 7:43 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Check the parser class name first. Until you know that, you cannot make any assumptions about the meaning of the field type.
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 distinguish Attributes from other NameValue elements
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.