Hi Wouter: I went figured that i can delete the whole entry for sid=781111 and then insert a new record of student with a new sid.
i tried the following: String xupd1 = "<xu:modifications version= \"1.0 \" " + "xmlns:xu= \"http://www.xmldb.org/xupdate\"> " + "<xu:remove select= \"//students/[EMAIL PROTECTED]'781111']\"> </xu:remove >" + "</xu:modifications >"; String xupd = "<xu:modifications version= \"1.0 \" " + "xmlns:xu= \"http://www.xmldb.org/xupdate\"> " + "<xu:append select= \"//students\">"+ "<student sid='781164'>"+ " <name>Laxma R Dendi</name>"+ " <degree>MS</degree>" + " <major>Comuter Science</major>"+ "</student> </xu:append>"+ "</xu:modifications >"; this works. but is there any other simple of doing it. thanks for your reply. sincerely laxma --- Wouter de Vaal <[EMAIL PROTECTED]> wrote: > It's your XUpdate expression. The query > /students/[EMAIL PROTECTED] = '781111'] > gives the following xml: > > <student sid="781111"> > <name>Laxma R Dendi</name> > <degree>M.S</degree> > <major>Computer Science</major> > </student> > > But xupdate:update can only update leafnodes and in > the above xml, student > is not a leaf-node. > You could try a combination of xupdate:insert-after > and xupdate:remove > statements. > > However if you are trying to change the attribute > sid you should probably do > a combination of removing > the attribute and adding a new one. Check out the > following link on examples > how to do this > > http://www.xmldatabases.org/projects/XUpdate-UseCases/ > > > Wouter > > > _____ > > From: Laxma Reddy Dendi > [mailto:[EMAIL PROTECTED] > Sent: Monday, July 19, 2004 10:39 PM > To: xindice-users@xml.apache.org > Subject: Error executing XUpdate Query > > > Hi All, > I am getting error while trying to execute > xupdate query: > > i am trying the following code: > > import org.xmldb.api.base.*; > import org.xmldb.api.modules.*; > import org.xmldb.api.*; > public class StudentsXupdate { > public static void main(String[] args) throws > Exception { > Collection col = null; > try { > String driver = > "org.apache.xindice.client.xmldb.DatabaseImpl"; > Class c = Class.forName(driver); > Database database = (Database) > c.newInstance(); > DatabaseManager.registerDatabase(database); > col = > DatabaseManager.getCollection("xmldb:xindice://localhost:8080/db/studentsdb" > ); > String xupd = "<xupdate:modifications > version=\"1.0\"" + " > xmlns:xupdate=\"http://www.xmldb.org/xupdate\">"; > xupd+=" <xupdate:update > select=\"/students/[EMAIL PROTECTED] = > '781111']\">" ; > xupd+= "781114" + " </xupdate:update>" + > "</xupdate:modifications>"; > > XUpdateQueryService service = > (XUpdateQueryService) > col.getService("XUpdateQueryService", > "1.0"); > long num=service.update(xupd); > System.out.println("number is: "+num); > } > catch (XMLDBException e) { > System.err.println("XML:DB Exception > occurred " + e.errorCode); > } > finally { > if (col != null) { col.close();} > } > } > } > > here is my document: > C:\>xindice rd -c > xmldb:xindice://localhost:8080/db/studentsdb -n > students > trying to register database > <?xml version="1.0"?> > <students> > <student sid="781111"> > <name>Laxma R Dendi</name> > <degree>M.S</degree> > <major>Computer Science</major> > </student> > <student sid="999999"> > <name>Guest</name> > <degree>M.S</degree> > <major>Computer Science</major> > </student> > </students> > > > i am getting the following error: > > C:\>java StudentsXupdate > trying to register database > org.xmldb.api.base.XMLDBException: > org.apache.xmlrpc.XmlRpcException: Error > exec > uting XUpdate query > at > org.apache.xindice.client.xmldb.xmlrpc.CollectionImpl.runRemoteComman > d(CollectionImpl.java:119) > at > org.apache.xindice.client.xmldb.xmlrpc.CollectionImpl.query(Collectio > nImpl.java:515) > at > org.apache.xindice.client.xmldb.XindiceCollection.query(XindiceCollec > tion.java:259) > at > org.apache.xindice.client.xmldb.services.QueryService.query(QueryServ > ice.java:90) > at > org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.upda > te(XUpdateQueryServiceImpl.java:81) > at > StudentsXupdate.main(StudentsXupdate.java:25) > XML:DB Exception occurred 1 > > thanks in advance. > > sincerely > Laxma > > > > > _____ > > Do you Yahoo!? > Vote for the > <http://advision.webevents.yahoo.com/yahoo/votelifeengine/> > stars of Yahoo!'s next ad campaign! > > __________________________________ Do you Yahoo!? Vote for the stars of Yahoo!'s next ad campaign! http://advision.webevents.yahoo.com/yahoo/votelifeengine/