I don't think XUpdate is the best way. I believe XUpdate only enables you to
make updates within an existing document (I may be wrong about this; that's the
only way I've used it myself).
Here's what I normally do:
Collection coll; // I assume you know how to obtain this
Resource res = coll.createResource("filename.xml", "XMLResource");
res.setContent(xmlAsString);
coll.storeResource(plugins);
coll.close();
Hope this helps!
Mario
-----Original Message-----
From: R. Mark Volkmann [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 05, 2005 8:32 AM
To: [email protected]
Subject: RE: XUpdate to add a document to a collection
Quoting Ф ���� <[EMAIL PROTECTED]>:
> If you use xindice 1.0, you'd try it with xindice 1.1!
I'm using 1.1b4 and it doesn't work. Has anyone else been able to add documents
to a collection from Java? If so, can you send me an example?
> >From: "R. Mark Volkmann" <[EMAIL PROTECTED]>
> >Reply-To: [email protected]
> >To: [email protected]
> >Subject: XUpdate to add a document to a collection
> >Date: Tue, 4 Jan 2005 10:47:11 -0600
> >
> >I need to add a document to a collection from a Java application. I'm
> trying to
> >do this using the XUpdate API. Is this the best way?
> >
> >Here is the xupdate string I'm passing to my XUpdateQueryService update
> method.
> >
> ><xu:modifications version="1.0" xmlns:xu="http://www.xmldb.org/xupdate">
> > <xu:insert-after select="/services/service[1]">
> > <xu:element name="service">
> > <xu:attribute name="name">foo</xu:attribute>
> > <description>bar</description>
> > </xu:element>
> > </xu:insert-after>
> ></xu:modifications>
> >
> >It fails with the following stack trace.
> >
> >org.xmldb.api.base.XMLDBException: org.apache.xmlrpc.XmlRpcException:
> Error
> >Compiling XPath Expression: null
> > at
>
>org.apache.xindice.client.xmldb.xmlrpc.CollectionImpl.runRemoteCommand(CollectionImpl.java:119)
>
> > at
>
>org.apache.xindice.client.xmldb.xmlrpc.CollectionImpl.query(CollectionImpl.java:515)
>
> > at
>
>org.apache.xindice.client.xmldb.XindiceCollection.query(XindiceCollection.java:259)
>
> > at
>
>org.apache.xindice.client.xmldb.services.QueryService.query(QueryService.java:90)
>
> > at
>
>org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.update(XUpdateQueryServiceImpl.java:81)
>
> >
> >Any suggestions would be greatly appreciated!
> >
> >--
> >R. Mark Volkmann
> >Partner, Object Computing, Inc.
>
> _________________________________________________________________
> �������������ĵ����ʼ�ϵͳ�� MSN Hotmail�� http://www.hotmail.com
>
>
--
R. Mark Volkmann
Partner, Object Computing, Inc.