[bugfix] fn:transform: Conversion and treeIndex problems#5882
Merged
Conversation
Member
|
I recognize that under some conditions there is not a "DocumentNode"; I need to recall the context, it is some time ago. |
Also adds support for using maps and arrays as parameters in a XSLT transformation.
0e23845 to
c6e4557
Compare
c6e4557 to
1ca1ea5
Compare
Contributor
|
results against 6.4.0 <testsuites>
<testsuite package="http://exist-db.org/xquery/test/function_transform" timestamp="2026-02-17T12:55:05.283Z" tests="3" failures="0" errors="3" pending="0" time="PT0.006S">
<testcase name="memtree-second-child" class="testTransform:memtree-second-child">
<error type="java:java.lang.NullPointerException" message=""/>
</testcase>
<testcase name="stored-doc-with-attributes" class="testTransform:stored-doc-with-attributes">
<error type="java:java.lang.ClassCastException" message="class org.exist.dom.persistent.NodeProxy cannot be cast to class org.w3c.dom.Node (org.exist.dom.persistent.NodeProxy is in unnamed module of loader 'app'; org.w3c.dom.Node is in module java.xml of loader 'bootstrap')"/>
</testcase>
<testcase name="stylesheet-params-map-array" class="testTransform:stylesheet-params-map-array">
<error type="err:XPTY0004" message="It is a type error if, during the static analysis phase, an expression is found to have a static type that is not appropriate for the context in which the expression occurs, or during the dynamic evaluation phase, the dynamic type of a value does not match a required type as specified by the matching rules in 2.5.4 SequenceType Matching. Item [ x, y, z ] of type array(*) could not be converted to an eXist XdmValue"/>
</testcase>
</testsuite>
</testsuites>if ci is green this is ready from my view |
- update .gitignore
1ca1ea5 to
3851900
Compare
Contributor
duncdrum
approved these changes
Feb 17, 2026
dizzzz
approved these changes
Feb 17, 2026
line-o
added a commit
that referenced
this pull request
Feb 23, 2026
Port of #5882: "[bugfix] fn:transform: Conversion and treeIndex problems"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This is a retry for #5680 which was botched after I changed my develop-6.x.x branch.
The
fn:transformfunction sometimes producedNullPointerExceptions. This happened for documents containing nodes of typeorg.exist.dom.memtree.ElementImpland other subtypes oforg.exist.dom.memtree.NodeImpl.The function
org.exist.xquery.functions.fn.transform.Convert.ToSaxon.ofNode(Node)usesorg.exist.xquery.functions.fn.transform.TreeUtils.treeIndex(Node)to get a 'path' (as a list of indexes) of theNodein its containing document. This 'path' is used to find the node in a newly built document that is suitable for use by Saxon.Using the 'path' that the
treeIndexfunction produces assumes that it starts at the document node.However, some nodes do not have a containing document. Specifically, in
org.exist.dom.memtree.NodeImpl.getParentNode():In this case, the 'path' returned by
treeIndexdoes not contain the index (0) for the root node, andorg.exist.xquery.functions.fn.transform.TreeUtils.xdmNodeAtIndex(XdmNode, List<Integer>)will returnnullwhen a node is expected.The proposed fix tests for this case. Going up the ancestor chain, when a node that is not a document node and that does not have a parent is found, the index 0 for this root element is inserted in the 'path'.
The PR also adds support for using maps and arrays as parameters in a XSLT transformation.
Testing
The
NullPointerExceptionhappened in a rather complicated XQuery with documents composed from several sources.I have not yet been able to make a simple test case.