[jdom-interest] getAttribute(String nameOfAttribute)

Jaap.Botman at nl.abnamro.com Jaap.Botman at nl.abnamro.com
Thu Aug 31 07:40:01 PDT 2000


I have downloaded the sources from Brett McLaughlins article 'Make classes
from XML data'
(http://www-4.ibm.com/software/developer/library/data-binding2/index.html?dwzone=xml)

I can properly compile it using JDK1.2 and the Build 4 of JDOM on Windows NT.
However, if I run it with the example Schema document I get
NoSuchAttributeException's on 'getAttribute(nameOfAttribute)' statements
although the attribute is there.
For example:

type = complexType.getAttribute("name").getValue();

results in a NoSuchAttributeException

But if I replace this code by the following, 'type' will be assigned the proper
value:

String type = null;
List l = complexType.getAttributes();
for (Iterator i = l.iterator(); i.hasNext(); )
{
               Attribute attr = (Attribute)i.next();
     if (attr.getName().equals("name"))
                          type = attr.getValue();
}

After I made similar adjustments to all the occurences of 'getAttribute(
nameOfAttribute)' the resulting Java app works
fine and produces the expected result.

Is this problem known by anyone?

regards, Jaap Botman





More information about the jdom-interest mailing list