[jdom-interest] Re: JDOM-b7 will not compile

John Muhlestein jmuhlestein at i-link.net
Thu Aug 16 10:36:49 PDT 2001


The method addChild on the Element Class has been depricated (actually
removed in b7).  Try using addContent(new Element("myelt") instead.

John

> -----Original Message-----
> From: Mark Galbreath [mailto:mgalbrea at maximgroup.com]
> Sent: Thursday, August 16, 2001 10:55 AM
> To: Matt Hunter; Mark Galbreath
> Cc: Ian Lea; jdom-interest at jdom.org
> Subject: Re: Re: [jdom-interest] Re: JDOM-b7 will not compile
> 
> 
> Thanks, Matt!
> 
> You are indeed correct, sir.  That was a pretty stupid 
> oversight on my part!  The offending lines (the line 
> following the one reported also needed to be modified) have 
> been modified and I no longer get compile errors for that 
> particular code block.
> 
> Now I'm getting compile errors in the next block.  
> Apparently, this is NOT a classpath issue, rather a syntax 
> issue.  That is the good news....
> 
> The bad news is that this example is not among those 
> available for download off the O'Reilly site (!) and it looks 
> like I'm going to have to actually RTFM the JDOM API to 
> figure it out. :-)
> 
> Here's the offending block, should any of you guys be able to 
> notice what's wrong by eyeballing it (note that this is only 
> my 3rd day teaching myself Java/XML/XSL, so be gentle :-) ):
> 
> import org.jdom.*;
> 
> [class declaration]
> [empty constructor]
> 
> public void newDocument( OutputStream out) throws IO,JDOM {
> 
> Namespace ns = Namespace.getNamespace("blah", 
"http://blah.blah.blah");
Document doc = new Document( new Element( "config", ns);

* * *
[repaired code]
* * *

doc.getRootElement()
    .addAttribute( "kernel", "2.2.14")
    .addAttribute( new Attribute( "dist", "RedHat 6.1"))
    .addChild( new Element( "gui", ns)
        .setContent( "No Window Manager Installed"))
    .addChild( new Comment( "Sound Card Config"))
    .addChild( new Element( "Sound")
        .addChild( new Comment( "Sound Blaster Card"))
        .addChild( new Element( "card")
            .addChild( new Element( "name")
                .setContent( "Sound Blaster Platinum"))));
    XMLOutputter xo = new XMLOutputter();
    xo.output( doc, out); 
}

To this, the compiler is whining (in Forte):
    setContent(java.util.List) in org.jdom.Element cannot be applied to
(java.lang.String)
.addChild( new Element( "name")

cannot resolve symbol
symbol: method addChild (org.jdom.Comment)
location: class org.jdom.Element
    .addChild( new Element( "sound")

And at the command prompt:
    package org.jdom does not exist

Isn't this fun????  I'll fax a beer to the first gearhead that solves this.

Cheers!
Mark

 
> From: Matt Hunter <xrkune at tconl.com>
> Date: 2001/08/16 Thu AM 11:57:53 EDT
> 
> If you go out to his website you should be able to get a 1st Edition
> errata page that lists the necessary code changes to make the code
> run.  I was there about 2 months ago and there were some changes to the
> example code that uses JDOM.
> 
> www.oreilly.com/catalog/javaxml/errata/javaxml.confirmed
> www.oreilly.com/catalog/javaxml/errata/javaxml.unconfirmed
> 
> The second link specifically mentions the code on page 225 

_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com



More information about the jdom-interest mailing list