Author |
Message
|
oli |
Posted: Mon Feb 04, 2008 1:41 am Post subject: How to distinguish Attributes from other NameValue elements |
|
|
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 |
|
 |
kimbert |
Posted: Mon Feb 04, 2008 5:08 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
|
Back to top |
|
 |
oli |
Posted: Mon Feb 04, 2008 8:09 am Post subject: |
|
|
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 |
|
 |
jefflowrey |
Posted: Mon Feb 04, 2008 8:21 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
kimbert |
Posted: Mon Feb 04, 2008 8:25 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
|
Back to top |
|
 |
oli |
Posted: Mon Feb 04, 2008 8:58 am Post subject: |
|
|
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 |
|
 |
oli |
Posted: Tue Feb 05, 2008 3:57 am Post subject: |
|
|
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 |
|
 |
kimbert |
Posted: Tue Feb 05, 2008 7:43 am Post subject: |
|
|
 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 |
|
 |
|