Christian,
Try the following:
"create db db <a/>;xquery insert node "text" before /a;optimize"
This gives me the error reported below. I ran it from the GUI, though I'm guessing that shouldn't make a difference. It appears as though the difference is in the insertion of text content (as opposed to node content). Though I now see three possible problems (or not) based on your example and its success:
- A NullPointerException during optimize after inserting text content before the root element of a document. - The ability to insert text content before the root element of a document (should this be allowed?) - The ability to insert a second node before the root element of a document (should this be allowed?)
Dave
-----Original Message----- From: Christian GrĂ¼n [mailto:christian.gruen@gmail.com] Sent: Tuesday, December 20, 2011 4:34 PM To: Dave Glick Cc: BaseX Subject: Re: [basex-talk] Possible Optimization Bug (Or Maybe Document Insertion Bug)
Dave,
thanks for the valuable observation and the hints what could be the reason. I didn't manage to reproduce the problem, though. This is what I tried:
basex -c "create db db <a/>;xquery insert node <b/> before /a;optimize"
Do you have a little example that leads to the discussed problem? Next, I'll also be glad to look at one of the documents with text before the root node that is erroneously accepted by our parser.
Thanks! Christian ___________________________
On Tue, Dec 20, 2011 at 6:32 PM, Dave Glick dglick@dracorp.com wrote:
Hello,
I seem to have stumbled on a bug (or at least I think I have). Do the following:
- Create a simple database with a single document
- Insert a text node before the start of the document root ("insert
node "test" before /root")
- Attempt to optimize the database
You will get a NullPointerException at org.basex.index.Names.index(Names.java:84). It appears as though the index is attempting to set statistics information for key id 0 (because the parent is a document), but the stats[] array only gets initialized with objects from index 1 and up.
The other possibility is that text nodes should not be allowed before or after the document root element. I'm a little hazy on what the standards say in this regard. My understanding is that the document node can have prolog content before the root and other content after. I've also seen many documents which parse correctly that have text content before the opening tag (though again, this may not be strictly standard-compliant behavior). If this is the case, then the bug is probably that the insertion update operation is allowed to succeed.
Dave
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk