Bug #6489
closedGizmo issue with prefix, precede, suffix, and follow commands
0%
Description
I'm new to Gizmo, and I am seeing unexpected behavior with the prefix
, precede
, suffix
, and follow
commands. I have attached ZIP-files with the files that I mention below.
Reproduction steps for issue 1¶
-
Set SAXON_CP environment variable to the Saxon-HE 12.5 jar file path, followed by a path separator, followed by the jline-2.14.6.jar file path.
-
java -cp "%SAXON_CP%" net.sf.saxon.Gizmo -q:script.txt
Contents of script.txt:¶
load source.xml
prefix /article/info with /article/abstract
save result-of-prefix.xml
load source.xml
precede /article/info/author with /article/abstract
save result-of-precede.xml
load source.xml
suffix /article/info with /article/abstract
save result-of-suffix.xml
load source.xml
follow /article/info/author with /article/abstract
save result-of-follow.xml
Contents of source.xml:¶
<?xml version="1.0" encoding="UTF-8"?>
<article>
<info>
<author/>
</info>
<abstract/>
</article>
Expected results:¶
All four generated files should have one <author/>
element, the original <abstract/>
element near the end, and one newly inserted <abstract/>
element inside <info>
.
Actual results:¶
- The result-of-prefix.xml and result-of-precede.xml files each have two
<author/>
elements, as shown in the code block below. - The result-of-suffix.xml and result-of-follow.xml files are as expected.
Contents of result-of-prefix.xml:¶
<?xml version="1.0" encoding="UTF-8"?><article>
<info><abstract/>
<author/>
</info>
<abstract/>
<author/>
</article>
Reproduction steps for issue 2¶
When I tried the follow
and suffix
commands in a document having six siblings within a top-level element, I didn't understand those commands' behaviors, either. Elements are disappearing, but the documentation only mentions the insertion of content (not replacement or deletion).
java -cp "%SAXON_CP%" net.sf.saxon.Gizmo
Saxon Gizmo 12.5
/>load six-siblings.xml
/>show
<root>
<a/>
<b/>
<c/>
<d/>
<e/>
<f/>
</root>
/>follow /root/a with /root/e
/>show
<root>
<a/>
<e/>
<f/>
</root>
/>load six-siblings.xml
/>follow //a with //e
/>show
<root>
<a/>
<e/>
<f/>
</root>
/>load six-siblings.xml
/>suffix /root/a with /root/e
/>show
<root>
<a>
<e/>
</a>
<b/>
<c/>
<d/>
<e/>
</root>
/>load six-siblings.xml
/>suffix //a with //e
/>show
<root>
<a>
<e/>
</a>
<b/>
<c/>
<d/>
<e/>
</root>
/>quit now
Files
Updated by Michael Kay 4 months ago
Thanks for reporting it.
A long while since I have looked at the XQuery Update supporting code that Gizmo is built on.
What seems to be happening is that it fails to make a copy of the node being inserted. So when you do prefix A with B
, it is not only doing an in-situ modification of A to have a new first child, it is also updating the following-sibling of B to adjust it to its new position. It should be copying B first so that the original B is unaffected.
Updated by Michael Kay 4 months ago
Current state: fixed on the 12.x branch. Getting different problems on the 13.x branch, due to refactoring of the XPath parser/tokenizer perhaps.
Generally we need an improved test framework for Gizmo. Its interactive nature makes it tricky.
Updated by Michael Kay 4 months ago
- Category set to Gizmo
- Status changed from New to Resolved
- Assignee set to Michael Kay
- Priority changed from Low to Normal
- Applies to branch 12, trunk added
- Fix Committed on Branch 12, trunk added
- Platforms Java added
Fixed on the 12.x and 13.x branches.
Please register to edit this issue