<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="MSHTML 5.00.3103.1000" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>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.</FONT></DIV>
<DIV><FONT face=Arial size=2> For example if I have the following XML in my
test.xml</FONT></DIV>
<DIV><FONT face=Arial size=2><xa:myroot xa:myattr1="attr" xa:myattr2="attr2"
<FONT size=2>xmlns:xa="http://xaware.com/xas/ns1"></FONT></FONT></DIV>
<DIV><FONT face=Arial size=2>... Other child elements</FONT></DIV>
<DIV><FONT face=Arial size=2></xa:myroot></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Now if I do this</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Namespace
xaNamespace=Namespace.getNamespace("xa","http://xaware.com/xas/ns1")
;</FONT></DIV>
<DIV><FONT face=Arial size=2>Document bDoc =
builder.build("test.xml");</FONT></DIV>
<DIV><FONT face=Arial size=2>Element root = bDoc.getRootElement();<BR>Attribute
attr = root.getAttribute("myattr1",xaNamespace); // This fails</FONT></DIV>
<DIV><FONT face=Arial size=2>Attribute attr2 =root.getAttribute("myattr1")
; // Succeeds</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Why is "myattr1" behaving as if it has no namespace
associated with it?</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>..Rohit</FONT></DIV></BODY></HTML>