| 1 |
Patch created by git with "-U0" to discard context lines. |
| 2 |
|
| 3 |
diff --git a/libexslt/functions.c b/libexslt/functions.c |
| 4 |
index 8d35a7ae..a54ee70c 100644 |
| 5 |
--- a/libexslt/functions.c |
| 6 |
+++ b/libexslt/functions.c |
| 7 |
@@ -620,2 +620,7 @@ exsltFuncResultComp (xsltStylesheetPtr style, xmlNodePtr inst, |
| 8 |
- if (IS_XSLT_ELEM(test) && |
| 9 |
- IS_XSLT_NAME(test, "stylesheet")) { |
| 10 |
+ if (/* Traversal has reached the top-level document without |
| 11 |
+ * finding a func:function ancestor. */ |
| 12 |
+ (test != NULL && test->type == XML_DOCUMENT_NODE) || |
| 13 |
+ /* Traversal reached a stylesheet-namespace node, |
| 14 |
+ * and has left the function namespace. */ |
| 15 |
+ (IS_XSLT_ELEM(test) && |
| 16 |
+ IS_XSLT_NAME(test, "stylesheet"))) { |
| 17 |
diff --git a/libxslt/functions.c b/libxslt/functions.c |
| 18 |
index 72a58dc4..11ec039f 100644 |
| 19 |
--- a/libxslt/functions.c |
| 20 |
+++ b/libxslt/functions.c |
| 21 |
@@ -36,0 +37 @@ |
| 22 |
+#include "transformInternals.h" |
| 23 |
@@ -128 +129,14 @@ xsltDocumentFunctionLoadDocument(xmlXPathParserContextPtr ctxt, |
| 24 |
- doc = tctxt->style->doc; |
| 25 |
+ doc = xmlCopyDoc(tctxt->style->doc, 1); |
| 26 |
+ if (doc == NULL) { |
| 27 |
+ xsltTransformError(tctxt, NULL, NULL, |
| 28 |
+ "document() : failed to copy style doc\n"); |
| 29 |
+ goto out_fragment; |
| 30 |
+ } |
| 31 |
+ xsltCleanupSourceDoc(doc); /* Remove psvi fields. */ |
| 32 |
+ idoc = xsltNewDocument(tctxt, doc); |
| 33 |
+ if (idoc == NULL) { |
| 34 |
+ xsltTransformError(tctxt, NULL, NULL, |
| 35 |
+ "document() : failed to create xsltDocument\n"); |
| 36 |
+ xmlFreeDoc(doc); |
| 37 |
+ goto out_fragment; |
| 38 |
+ } |
| 39 |
diff --git a/libxslt/transform.c b/libxslt/transform.c |
| 40 |
index 54ef821b..38c2dce6 100644 |
| 41 |
--- a/libxslt/transform.c |
| 42 |
+++ b/libxslt/transform.c |
| 43 |
@@ -45,0 +46 @@ |
| 44 |
+#include "transformInternals.h" |
| 45 |
@@ -5760 +5761 @@ xsltCountKeys(xsltTransformContextPtr ctxt) |
| 46 |
-static void |
| 47 |
+void |
| 48 |
diff --git a/libxslt/transformInternals.h b/libxslt/transformInternals.h |
| 49 |
new file mode 100644 |
| 50 |
index 00000000..d0f42823 |
| 51 |
--- /dev/null |
| 52 |
+++ b/libxslt/transformInternals.h |
| 53 |
@@ -0,0 +1,9 @@ |
| 54 |
+/* |
| 55 |
+ * Summary: set of internal interfaces for the XSLT engine transformation part. |
| 56 |
+ * |
| 57 |
+ * Copy: See Copyright for the status of this software. |
| 58 |
+ * |
| 59 |
+ * Author: David Kilzer <[email protected]> |
| 60 |
+ */ |
| 61 |
+ |
| 62 |
+void xsltCleanupSourceDoc(xmlDocPtr doc); |