[jdom-interest] getAttribute(String nameOfAttribute)
brett.mclaughlin at lutris.com
Thu Aug 31 15:35:05 PDT 2000
Jaap.Botman at nl.abnamro.com wrote:
> I have downloaded the sources from Brett McLaughlins article 'Make classes
> from XML data'
> 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
> 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?
That article was written about two months ago, and as you found out,
some things have changed in JDOM since then. The new article, Part 3,
should be out any day now, and it includes an updated code base that
works with the latest JDOM from CVS. Sorry about the confusion ;-)
> regards, Jaap Botman
> To control your jdom-interest membership:
Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc.
1200 Pacific Avenue, Suite 300
Santa Cruz, CA 95060 USA
More information about the jdom-interest