Discussion:
[xquery-talk] Update bug?
Leo Studer
2015-10-06 16:23:32 UTC
Permalink
Hello

I am using Oxygen 17.0 with Saxon EE 9.6.0.5 as the xQuery Update processor.

I want to move an attribute one level deeper.

In the example I want to move att="att” from <a> to <b>

<?xml version="1.0" encoding="UTF-8"?>
<a att="att">
<b/>
</a>

Here my code:

delete node doc("xml.xml")//@att,
insert node doc("xml.xml")//@att into doc("xml.xml")//b

Each of these two statements work correctly alone but when I try both together I get java.lang.NullPointerException.

Can anyone explain what happens here?

Thanks in advance
Leo
Joseph Bryan
2015-10-06 16:54:40 UTC
Permalink
Hi Leo,

Try reversing the order of your statements, first inserting the node as a
child of <b/> before deleting it.

Also, you probably don't want to be using // in your selectors, which means
the descendant-or-self axis. With that XPath expression, any @att at any
level of the document would be copied and then deleted. Instead, use exact
paths with a single /, which is the child axis.

insert node doc("xml.xml")/a/@att into doc("xml.xml")/a/b,
delete node doc("xml.xml")/a/@att

Thanks.

-jb
Post by Leo Studer
Hello
I am using Oxygen 17.0 with Saxon EE 9.6.0.5 as the xQuery Update processor.
I want to move an attribute one level deeper.
In the example I want to move att="att” from <a> to <b>
<?xml version="1.0" encoding="UTF-8"?>
<a att="att">
<b/>
</a>
Each of these two statements work correctly alone but when I try both
together I get java.lang.NullPointerException.
Can anyone explain what happens here?
Thanks in advance
Leo
_______________________________________________
http://x-query.com/mailman/listinfo/talk
Ghislain Fourny
2015-10-07 08:13:41 UTC
Permalink
Hi Leo, Joseph,

Actually, the semantics of the XQuery Update Facility is based on
snapshots, which means that the order of the expressions is irrelevant in
terms of updates. Each expression is evaluated against the original
document, gathering a set of updates known as a PUL, and the updates are
only applied at the very end.

Even with the delete coming first, the insert still should see the
to-be-deleted node. Even if you swap the two expressions, the engine may
still evaluate the second expression first under the hood, or even in
parallel, and you won't see any difference. Commas have a monoid
(concatenation) semantics when used with items, but no elapse-of-time
semantics.

The XQuery Update Facility , like XQuery was very cleanly designed as a
declarative language :-)

I hope it's useful.

Kind regards,
Ghislain
Post by Joseph Bryan
Hi Leo,
Try reversing the order of your statements, first inserting the node as a
child of <b/> before deleting it.
Also, you probably don't want to be using // in your selectors, which
any level of the document would be copied and then deleted. Instead, use
exact paths with a single /, which is the child axis.
Thanks.
-jb
Post by Leo Studer
Hello
I am using Oxygen 17.0 with Saxon EE 9.6.0.5 as the xQuery Update processor.
I want to move an attribute one level deeper.
In the example I want to move att="att” from <a> to <b>
<?xml version="1.0" encoding="UTF-8"?>
<a att="att">
<b/>
</a>
Each of these two statements work correctly alone but when I try both
together I get java.lang.NullPointerException.
Can anyone explain what happens here?
Thanks in advance
Leo
_______________________________________________
http://x-query.com/mailman/listinfo/talk
_______________________________________________
http://x-query.com/mailman/listinfo/talk
Michael Kay
2015-10-06 16:56:30 UTC
Permalink
Yes, a NullPointerException is prima facie evidence of a bug.

Please track progress on it here:

https://saxonica.plan.io/issues/2465 <https://saxonica.plan.io/issues/2465>

Michael Kay
Saxonica
Post by Leo Studer
Hello
I am using Oxygen 17.0 with Saxon EE 9.6.0.5 as the xQuery Update processor.
I want to move an attribute one level deeper.
In the example I want to move att="att” from <a> to <b>
<?xml version="1.0" encoding="UTF-8"?>
<a att="att">
<b/>
</a>
Each of these two statements work correctly alone but when I try both together I get java.lang.NullPointerException.
Can anyone explain what happens here?
Thanks in advance
Leo
_______________________________________________
http://x-query.com/mailman/listinfo/talk
Loading...