Thanks Andy,
I was hoping to avoid having to pass the doc, but it is a much better
solution although I'll have to work out why JBuilder didn't set the
"required" libraries in order as I set in the Project properties. Oh well,
thats another mailing list.
Cheers,
Anthony Ikeda
----- Original Message -----
From: "Andy Clark" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 28, 2001 5:27 PM
Subject: Re: returning a node (I can't find a solution anywhere!)
> Anthony Ikeda wrote:
> > I know this may be a basic question, but I've tried every possible
> > option I can think of. Simply put, all I'm trying to do, is add a
>
> Then you need to think harder! ;) Just kidding. This problem
> happens all of the time. There are a few problems that I see:
>
> > public class headache{
> > public Element toXML(){
> > .....
> > return Element;
> > }
> > }
> >
> > DocumentImpl doc = new DocumentImpl();
> > Element root = doc.createElement("root");
> >
> > headache h = new headache();
> > Element e = headache.toXML();
> > root.appendChild(e);
>
> 1) You're getting a WRONG_DOCUMENT_ERR because any node appended
> to a document must have been created using the same document
> factory. Therefore, your "headache#toXML" method must use
> the same document instance. Why don't you change the
> prototype to pass in the document, like so:
>
> public Element toXML(Document factory);
>
> > This returns the same. If I try to use importNode(node,true) on the
> > calling class side:
> >
> > rott.appendChild(doc.importNode(headache.toXML(),true));
> >
> > I get:
> >
> > Context log: path="" Error in qResults service() : null
> > java.lang.NoSuchMethodError
> >
> > at
> > org.apache.xerces.dom.DocumentImpl.importNode(DocumentImpl.java:888)
>
> Classpath problem. You are picking up the DOM Level 1 interfaces
> before the DOM Level 2 interfaces (which added importNode). Once
> this is fixed, the importNode should work but I wouldn't
> recommend it because this creates a copy of the imported node.
> Very wasteful.
>
> --
> Andy Clark * IBM, TRL - Japan * [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]