john, i have done collection.store(resource) and it is status quo. not sure on which object i must be calling the other method you mentioned - setContent().
thanks, -nani -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 27, 2002 4:44 PM To: [EMAIL PROTECTED] Subject: RE: NullPointerException: appendChild() Hi Nani, I think you need to call setContent (or the DOM equivalent) and then collection.store(resource). Or did you do that already? John > -----Original Message----- > From: Jayaram Narayana [mailto:[EMAIL PROTECTED] > Sent: mercredi, 27. mars 2002 12:10 > To: [EMAIL PROTECTED] > Subject: RE: NullPointerException: appendChild() > > > hey john, > > yes, i got the exact same thought as you did and tried the following > (fragment): > > : > : > Database database = (Database) c.newInstance(); > DatabaseManager.registerDatabase(database); > col = > DatabaseManager.getCollection("xmldb:xindice:///db/misc"); > XMLResource xmlResource = (XMLResource) > col.getResource("test"); > Node node = xmlResource.getContentAsDOM(); > Document doc = node.getOwnerDocument(); > Element el = doc.createElement("newchild"); > node.appendChild((Node) el); > NodeList nl = node.getChildNodes(); > > for (int i = 0; i < nl.getLength(); i++) > System.out.println("Node " + i + ": " + > nl.item(i).getNodeName()); > > : > : > > here's the output i get: > > Node 0: parent > Node 1: newchild > > which means we were right. however, when i retrieve the > document thru the > console admin, i cannot see "newchild" > > now what could be wrong? is there some commit i need to do on > the database? > > thanks, > -nani > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Wednesday, March 27, 2002 4:12 PM > To: [EMAIL PROTECTED] > Subject: RE: NullPointerException: appendChild() > > > Hi Nani, > > I don't know if this is relevant, but cloneNode returns a > copy with a parent > value of null. Since nodes added to other node structures > need to have the > same parent, this might be your problem. Try using > getOwnerDocument() to get > the parent, then create a new element to append. > > John > > > -----Original Message----- > > From: Jayaram Narayana [mailto:[EMAIL PROTECTED] > > Sent: mercredi, 27. mars 2002 11:11 > > To: 'Xindice Dev. Group' > > Subject: NullPointerException: appendChild() > > > > > > hi! > > > > when i try to run this code against the xml given below i get > > the following > > exception: > > > > Has Children: true > > Exception in thread "main" java.lang.NullPointerException > > at > > org.apache.xindice.xml.dom.ContainerNodeImpl.appendChild(Unkno > > wn Source) > > > > the code fragment is: > > : > > : > > Database database = (Database) c.newInstance(); > > DatabaseManager.registerDatabase(database); > > col = > > DatabaseManager.getCollection("xmldb:xindice:///db/misc"); > > XMLResource xmlResource = (XMLResource) > > col.getResource("test"); > > Node node = xmlResource.getContentAsDOM(); > > System.out.println("Has Children: " + > node.hasChildNodes()); > > Node newNode = node.cloneNode(true); > > node.appendChild(newNode); > > : > > : > > > > the xml file is: > > > > <?xml version="1.0"?> > > <parent> > > <child id="123">Text goes here</child> > > </parent> > > > > i am not able to figure out what i am doing wrong. any help > > will be greatly > > appreciated. > > > > thanks in advance, > > -nani > > > > > >
