Dear Travis,
it's true, unfortunately XQuery Update does not allow to add document nodes to collections/databases. One of the reasons is that the document node gets lost by the update, i.e. if your document looks as follows..
test.xml: <xml/>
..the following two expressions will do the same:
– insert node doc('test.xml') into … – insert node <xml/> into …
If you want to stick with XQJ and XQuery (Update), the easiest approach is to define one document root and add all new documents as children:
– insert node <xml>new document</xml> into /root
As other users had similar requests to yours, we are interested in your own suggestions how you would like to see this issue fixed (e.g., by adding some XQuery functions like basex:add("...") and basex:delete("...")).
Hope this helps, Christian
On Mon, Mar 1, 2010 at 6:35 AM, Travis Webb tjwebb@vt.edu wrote:
Everyone, Here's my situation: I'm using XQJ. I have an xml document stored as a java string, and I want to store this into an xquery collection. I see no way to do this without using the BaseX-specific libraries. I've looked everywhere, and the only thing I've found that's close is MonetDB's add-doc() function, but that takes a url as an argument, not a string. I want to do something like: insert node $document into collection("test"). Obviously this doesn't work because collections are sequences. Any info is appreciated. -tjw
___________________________
Christian Gruen Universitaet Konstanz Department of Computer & Information Science D-78457 Konstanz, Germany Tel: +49 (0)7531/88-4449, Fax: +49 (0)7531/88-3577 http://www.inf.uni-konstanz.de/~gruen