Bug #2365
closedUnexpected result when executing an XQuery update
100%
Description
I think that the result of the next XQuery Update transformation is wrong.
test.xq
xquery version "3.0";
declare variable $toInsert as node()+ :=
<container>TO-INSERT<to-insert/></container>;
insert nodes $toInsert//node()
as first into doc('insert.xml')//a
insert.xml
<?xml version="1.0" encoding="UTF-8"?>
<a>text</a>
I suppose the correct result should be:
<a>TO-INSERT<to-insert/>text</a>
but is:
<?xml version="1.0" encoding="UTF-8"?>
<a>TO-INSERTtext<to-insert/>
</a>
However, if the input XML document is:
<?xml version="1.0" encoding="UTF-8"?>
<a><child>text</child></a>
then the result is the expected one:
<?xml version="1.0" encoding="UTF-8"?>
<a>TO-INSERT<to-insert/><child>text</child></a>
Updated by Michael Kay over 9 years ago
- Category set to XQuery Update
- Assignee set to Michael Kay
- Priority changed from Low to Normal
Not doing well on this so far. My first attempt to reproduce it under 9.6 fails
java.lang.ClassCastException: net.sf.saxon.s9api.XdmEmptySequence cannot be cast to net.sf.saxon.s9api.XdmItem
at net.sf.saxon.s9api.XQueryEvaluator.getContextItem(XQueryEvaluator.java:157)
at net.sf.saxon.Query.runUpdate(Query.java:944)
at net.sf.saxon.Query.doQuery(Query.java:437)
at net.sf.saxon.Query.main(Query.java:111)
and under 9.7 I get
Error on line 7 of test.xq:
XUDY0027: An empty sequence is not allowed as the value of second operand of insert expression
Havne't actually done much with XQuery Update for a while now...
Updated by Michael Kay over 9 years ago
- Status changed from New to Resolved
The primary bug is exactly this test case: when doing "insert first", and the existing content is a single text node, and the new content is a sequence of more than one node STARTING with a text node, the existing text is merged with that first text node to be inserted. The test should be that the sequence to be inserted ENDS with a text node. The converse case, for "insert last" is also wrong in the other direction.
While running this I hit a couple of secondary problems trying to run an XQuery Update from the command line when there is no context item (that is, no -s option). I'm patching these at the same time.
Fixed in the 9.6 and 9.7 branches.
Updated by O'Neil Delpratt over 9 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Found in version changed from 9.6.0.5 to 9.6
- Fixed in version set to 9.6.0.6
Bug fix applied in the Saxon 9.6.0.6 maintenance release
Updated by O'Neil Delpratt about 9 years ago
- Sprint/Milestone set to 9.6.0.6
- Applies to branch 9.6 added
- Fix Committed on Branch 9.6 added
- Fixed in Maintenance Release 9.6.0.6 added
Please register to edit this issue