Renaming of documents
Wednesday, 20 April 2011 · 8 messages · last reply 18 May 2011
TK
Thomas Kaltofen20 Apr 2011 17:13 #
Hi,
why is it not possible to rename a document in a database with an update XQuery? Thanks for helping out!
Regards,
Thomas
MS
Michael Seiferle20 Apr 2011 18:21 #
Hi Thomas,
this is due to the specification - renaming documents inside collections or databases is out of scope: XQuery Update does not allow modifications outside the root node - and this is where actual document node, that contains the document name, resides.
I am sorry that at the moment we can not provide a command that does this for you. You could however delete and re-add that document.
Hope this helps for the moment.
Grüße aus Konstanz
Michael
Quoted text · Thomas Kaltofen · 10 lines
Am 20.04.2011 um 17:13 schrieb Thomas Kaltofen: > Hi, > why is it not possible to rename a document in a database with an update XQuery? Thanks for helping out! > > Regards, > Thomas > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
TK
Thomas Kaltofen21 Apr 2011 12:54 #
Hi Michael,
thank you for the quick response. Is it planned to add a rename-document-command in the future? Deleting and re-adding is not really an option, because I cannot perform these two operations in one transaction.
Actually I was looking for this functionality because I have a big problem with an insert query which corrupts the whole database. I can easily reproduce the problem with the following steps, so I think it is a bug in BaseX:
1. Create database 'db'
2. Insert a document called 'doca' into 'db': ADD as 'doca' <...complex XML data...>
3. Insert a document called 'docb' into 'db': ADD as 'docb' <...complex XML data...>
4. Perform the following XQuery: insert node collection('db/docb')/somenode after collection('db/doca')/someothernode
The XQuery returns an error "[XQST0054] Circular variable definition?", although the query contains no variables. However, the query still adds parts of docb into doca and after the query the database is corrupt. With corrupt I mean that the GUI returns either an OutOfBounds exception or a StackOverflow exception or a NotExpected exception when re-opening the database. Which exception is thrown is random. With simple XML data in doca and docb (e.g. <a><b>test</b></a>) the steps work properly, however with my XML dataset it does not work. I can supply a sample dataset so you can reproduce the problem, but I would prefer to not post my dataset to the mailing list if possible.
Thanks for your help!
Grüße aus Österreich,
Thomas
Quoted text · Michael Seiferle · 24 lines
-----Original Message----- From: Michael Seiferle [mailto:michael.seiferle at uni-konstanz.de] Sent: Wednesday, April 20, 2011 6:22 PM To: thomas at kaltofen.at; Thomas Kaltofen Cc: basex-talk at mailman.uni-konstanz.de Subject: Re: [basex-talk] Renaming of documents Hi Thomas, this is due to the specification - renaming documents inside collections or databases is out of scope: XQuery Update does not allow modifications outside the root node - and this is where actual document node, that contains the document name, resides. I am sorry that at the moment we can not provide a command that does this for you. You could however delete and re-add that document. Hope this helps for the moment. Grüße aus Konstanz Michael Am 20.04.2011 um 17:13 schrieb Thomas Kaltofen: > Hi, > why is it not possible to rename a document in a database with an update XQuery? Thanks for helping out! > > Regards, > Thomas > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
LW
Leo Wörteler21 Apr 2011 13:49 #
Hi Thomas,
Quoted text · Thomas Kaltofen · 3 lines
Am 21.04.2011 12:54, schrieb Thomas Kaltofen: > The XQuery returns an error "[XQST0054] Circular variable definition?", > although the query contains no variables.
I think that's the standard error message for stack overflow errors, it should probably be reworded to say that more clearly.
Quoted text · Thomas Kaltofen · 6 lines
> However, the query still adds parts of docb into doca and after the > query the database is corrupt. > [...] > With simple XML data in doca and docb > (e.g. <a><b>test</b></a>) the steps work properly, however with my XML > dataset it does not work.
That definitely sounds like a stack overflow in the middle of an update, which is a Bad Thing (TM)... I'll definitely look into that ASAP. A workaround until it's fixed would be to increase the JVM's stack size with *java -Xss1m*.
Quoted text · Thomas Kaltofen · 2 lines
> I can supply a sample dataset so you can reproduce the problem, but I > would prefer to not post my dataset to the mailing list if possible.
Sample data would greatly simplify the debugging process. You can send it to support at basex.org, we will keep it confidential.
Danke schonmal und Grüße zurück vom Bodensee,
Leo
LW
Leo Wörteler21 Apr 2011 16:36 #
Hi Thomas,
I could reproduce the bug and we'll fix it soon. Your query however looks a bit strange to me:
Quoted text · Leo Wörteler · 3 lines
Am 21.04.2011 14:31, schrieb Thomas Kaltofen: > insert node collection('db/docb')/rootB > after collection('db/doca')/rootA
Your collection looks something like this:
Quoted text · Leo Wörteler · 9 lines
> collection(db) > | > |-- document(doca) > | | > | `-- <rootA .../> > | > `-- document(docb) > | > `-- <rootB .../>
Your query doesn't create a new document node (as XQuery Update doesn't operate on document level) but inserts the <rootB .../> element directly into the first document, which then has two(!) root elements:
Quoted text · Leo Wörteler · 8 lines
> collection(db) > | > |-- document(doca) > | | > | |-- <rootA .../> > | | > | `-- <rootB .../> > [...]
That's allowed in XQuery Update, but isn't valid XML any more and I can't think of a scenario where it's actually desirable.
Is that what you wanted to do? If not, could you explain in more detail what you intended?
Cheers Leo
TK
Thomas Kaltofen21 Apr 2011 17:43 #
Hi Leo,
good to hear that you could reproduce the bug and that you can fix it. It is true that this query is strange and produces an invalid XML structure with two root nodes. My intention was to have several versions of one document underneath the same document node and to be honest I was seeing the document node as the "real" root node. But the example can be easily fixed by adding the other document underneath the root node 'rootA' instead of the same level as the root node. What problems could evolve from having several root nodes in one document in BaseX apart from the XML structure not being valid anymore?
Thanks for your support!
Best regards,
Thomas
Quoted text · Leo Wörteler · 33 lines
-----Original Message----- From: Leo Wörteler [mailto:lw at basex.org] Sent: Thursday, April 21, 2011 4:37 PM To: thomas at kaltofen.at; Thomas Kaltofen Cc: basex-talk Subject: Re: [basex-talk] Renaming of documents Hi Thomas, I could reproduce the bug and we'll fix it soon. Your query however looks a bit strange to me: Am 21.04.2011 14:31, schrieb Thomas Kaltofen: > insert node collection('db/docb')/rootB > after collection('db/doca')/rootA Your collection looks something like this: > collection(db) > | > |-- document(doca) > | | > | `-- <rootA .../> > | > `-- document(docb) > | > `-- <rootB .../> Your query doesn't create a new document node (as XQuery Update doesn't operate on document level) but inserts the <rootB .../> element directly into the first document, which then has two(!) root elements: > collection(db) > | > |-- document(doca) > | | > | |-- <rootA .../> > | | > | `-- <rootB .../> > [...] That's allowed in XQuery Update, but isn't valid XML any more and I can't think of a scenario where it's actually desirable. Is that what you wanted to do? If not, could you explain in more detail what you intended? Cheers Leo
TK
Hi,
I just wanted to ask if the bug I described was fixed in version 6.6.2, because I just tried it with the new version and I still get the same error message and a corruption of the database. Thank you for your support!
Best regards,
Thomas
Quoted text · Leo Wörteler · 38 lines
-----Original Message----- From: Leo Wörteler [mailto:lw at basex.org] Sent: Thursday, April 21, 2011 4:37 PM To: thomas at kaltofen.at; Thomas Kaltofen Cc: basex-talk Subject: Re: [basex-talk] Renaming of documents Hi Thomas, I could reproduce the bug and we'll fix it soon. Your query however looks a bit strange to me: Am 21.04.2011 14:31, schrieb Thomas Kaltofen: > insert node collection('db/docb')/rootB > after collection('db/doca')/rootA Your collection looks something like this: > collection(db) > | > |-- document(doca) > | | > | `-- <rootA .../> > | > `-- document(docb) > | > `-- <rootB .../> Your query doesn't create a new document node (as XQuery Update doesn't operate on document level) but inserts the <rootB .../> element directly into the first document, which then has two(!) root elements: > collection(db) > | > |-- document(doca) > | | > | |-- <rootA .../> > | | > | `-- <rootB .../> > [...] That's allowed in XQuery Update, but isn't valid XML any more and I can't think of a scenario where it's actually desirable. Is that what you wanted to do? If not, could you explain in more detail what you intended? Cheers Leo
CG
Christian Grün18 May 2011 15:52 #
Dear Thomas,
seems this issue will take some more time to fix; I've added it to our issue tracker:
https://github.com/BaseXdb/basex/issues/96
Best,
Christian
___________________________
2011/5/17 Thomas Kaltofen <Thomas.Kaltofen at risc.uni-linz.ac.at>:
Quoted text · Thomas Kaltofen · 60 lines
> Hi, > > I just wanted to ask if the bug I described was fixed in version 6.6.2, because I just tried it with the new version and I still get the same error message and a corruption of the database. Thank you for your support! > > Best regards, > Thomas > > -----Original Message----- > From: Leo Wörteler [mailto:lw at basex.org] > Sent: Thursday, April 21, 2011 4:37 PM > To: thomas at kaltofen.at; Thomas Kaltofen > Cc: basex-talk > Subject: Re: [basex-talk] Renaming of documents > > Hi Thomas, > > I could reproduce the bug and we'll fix it soon. Your query however > looks a bit strange to me: > > Am 21.04.2011 14:31, schrieb Thomas Kaltofen: >> insert node collection('db/docb')/rootB >> after collection('db/doca')/rootA > > Your collection looks something like this: > >> collection(db) >> | >> |-- document(doca) >> | | >> | `-- <rootA .../> >> | >> `-- document(docb) >> | >> `-- <rootB .../> > > Your query doesn't create a new document node (as XQuery Update doesn't > operate on document level) but inserts the <rootB .../> element directly > into the first document, which then has two(!) root elements: > >> collection(db) >> | >> |-- document(doca) >> | | >> | |-- <rootA .../> >> | | >> | `-- <rootB .../> >> [...] > > That's allowed in XQuery Update, but isn't valid XML any more and I > can't think of a scenario where it's actually desirable. > > Is that what you wanted to do? If not, could you explain in more detail > what you intended? > > Cheers Leo > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
Written for BaseX 6.6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery