Subject: | Returning documents from XPath extension functions |
Date: | Fri, 6 Dec 2019 16:24:17 +0100 |
To: | bug-XML-LibXSLT [...] rt.cpan.org |
From: | Nick Wellnhofer <wellnhofer [...] aevum.de> |
The code in LibXSLT__function which handles XPath extension functions wraps
returned nodes in another document for memory management reasons. If one of
the returned nodes happens to be a document node, the document will be wrapped
inside another document. This violates libxml2's assumption that document
nodes can only be at the root of a tree and can lead to issues like
https://gitlab.gnome.org/GNOME/libxml2/issues/132
The cleanest solution is to copy the document's children to the RVT and return
the RVT in the result node list.