[jdom-interest] Root element with namespace prefix
Rohit Mital
rmital at xaware.com
Thu Feb 28 14:32:30 PST 2002
I am using JDOM b7. When parsing an XML document, where the root element has a namespace prefix, any attribute in the root element with the same namespace prefix behaves as if the attribute does not have a namespace prefix.
For example if I have the following XML in my test.xml
<xa:myroot xa:myattr1="attr" xa:myattr2="attr2" xmlns:xa="http://xaware.com/xas/ns1">
... Other child elements
</xa:myroot>
Now if I do this
Namespace xaNamespace=Namespace.getNamespace("xa","http://xaware.com/xas/ns1") ;
Document bDoc = builder.build("test.xml");
Element root = bDoc.getRootElement();
Attribute attr = root.getAttribute("myattr1",xaNamespace); // This fails
Attribute attr2 =root.getAttribute("myattr1") ; // Succeeds
Why is "myattr1" behaving as if it has no namespace associated with it?
..Rohit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20020228/23549d90/attachment.htm
More information about the jdom-interest
mailing list