File fe508f201efb9ea37bfbe95413b8b28251497de3.patch of Package mingw-libxslt
diff -rupN --no-dereference libxslt-v1.1.43/libexslt/functions.c libxslt-v1.1.43-new/libexslt/functions.c
--- libxslt-v1.1.43/libexslt/functions.c 2025-03-12 18:38:02.000000000 +0100
+++ libxslt-v1.1.43-new/libexslt/functions.c 2026-01-13 13:44:59.694783725 +0100
@@ -617,8 +617,13 @@ exsltFuncResultComp (xsltStylesheetPtr s
* instanciation of a func:result element.
*/
for (test = inst->parent; test != NULL; test = test->parent) {
- if (IS_XSLT_ELEM(test) &&
- IS_XSLT_NAME(test, "stylesheet")) {
+ if (/* Traversal has reached the top-level document without
+ * finding a func:function ancestor. */
+ (test != NULL && test->type == XML_DOCUMENT_NODE) ||
+ /* Traversal reached a stylesheet-namespace node,
+ * and has left the function namespace. */
+ (IS_XSLT_ELEM(test) &&
+ IS_XSLT_NAME(test, "stylesheet"))) {
xsltGenericError(xsltGenericErrorContext,
"func:result element not a descendant "
"of a func:function\n");