[libxslt] Forwards-compatible processing of unknown top level elements
- From: Daniel Veillard <veillard src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxslt] Forwards-compatible processing of unknown top level elements
- Date: Thu, 16 Aug 2012 08:22:50 +0000 (UTC)
commit faeaa3146cab124628785c4b536ba0b824292f8d
Author: Nick Wellnhofer <wellnhofer aevum de>
Date: Wed Aug 15 22:40:05 2012 +0200
Forwards-compatible processing of unknown top level elements
Bug #677901
libxslt/xslt.c | 14 ++++++--------
libxslt/xsltInternals.h | 4 ++++
tests/docs/bug-175.xml | 1 +
tests/general/bug-175.err | 6 ++++++
tests/general/bug-175.out | 8 ++++++++
tests/general/bug-175.xsl | 30 ++++++++++++++++++++++++++++++
6 files changed, 55 insertions(+), 8 deletions(-)
---
diff --git a/libxslt/xslt.c b/libxslt/xslt.c
index 2bc8af5..bd14092 100644
--- a/libxslt/xslt.c
+++ b/libxslt/xslt.c
@@ -758,6 +758,7 @@ xsltNewStylesheet(void) {
ret->extrasNr = 0;
ret->internalized = 1;
ret->literal_result = 0;
+ ret->forwards_compatible = 0;
ret->dict = xmlDictCreate();
#ifdef WITH_XSLT_DEBUG
xsltGenericDebug(xsltGenericDebugContext,
@@ -6068,8 +6069,10 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) {
(!xmlStrEqual(prop, (const xmlChar *)"1.1"))) {
xsltTransformError(NULL, style, top,
"xsl:version: only 1.0 features are supported\n");
- /* TODO set up compatibility when not XSLT 1.0 */
- if (style != NULL) style->warnings++;
+ if (style != NULL) {
+ style->forwards_compatible = 1;
+ style->warnings++;
+ }
}
xmlFree(prop);
}
@@ -6163,12 +6166,7 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) {
} else if (IS_XSLT_NAME(cur, "namespace-alias")) {
xsltNamespaceAlias(style, cur);
} else {
- /*
- * BUG TODO: The version of the *doc* is irrelevant for
- * the forwards-compatible mode.
- */
- if ((style != NULL) && (style->doc->version != NULL) &&
- (!strncmp((const char *) style->doc->version, "1.0", 3))) {
+ if ((style != NULL) && (style->forwards_compatible == 0)) {
xsltTransformError(NULL, style, cur,
"xsltParseStylesheetTop: unknown %s element\n",
cur->name);
diff --git a/libxslt/xsltInternals.h b/libxslt/xsltInternals.h
index afb2a2c..5be59bc 100644
--- a/libxslt/xsltInternals.h
+++ b/libxslt/xsltInternals.h
@@ -1635,6 +1635,10 @@ struct _xsltStylesheet {
xsltPrincipalStylesheetDataPtr principalData;
#endif
+ /*
+ * Forwards-compatible processing
+ */
+ int forwards_compatible;
};
typedef struct _xsltTransformCache xsltTransformCache;
diff --git a/tests/docs/bug-175.xml b/tests/docs/bug-175.xml
new file mode 100644
index 0000000..69d62f2
--- /dev/null
+++ b/tests/docs/bug-175.xml
@@ -0,0 +1 @@
+<doc/>
diff --git a/tests/general/bug-175.err b/tests/general/bug-175.err
new file mode 100644
index 0000000..70cddd5
--- /dev/null
+++ b/tests/general/bug-175.err
@@ -0,0 +1,6 @@
+compilation error: file ./bug-175.xsl line 28 element function
+xsltStylePreCompute: unknown xsl:function
+compilation error: file ./bug-175.xsl line 5 element transform
+xsl:version: only 1.0 features are supported
+compilation error: file ./bug-175.xsl line 28 element function
+xsltParseStylesheetTop: ignoring unknown function element
diff --git a/tests/general/bug-175.out b/tests/general/bug-175.out
new file mode 100644
index 0000000..e9cf403
--- /dev/null
+++ b/tests/general/bug-175.out
@@ -0,0 +1,8 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<title>xsl:function</title>
+</head>
+<body><p><tt>xsl:function</tt> not supported, but properly handled (ignored)</p></body>
+</html>
diff --git a/tests/general/bug-175.xsl b/tests/general/bug-175.xsl
new file mode 100644
index 0000000..f25e4c9
--- /dev/null
+++ b/tests/general/bug-175.xsl
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:test="#test"
+ exclude-result-prefixes="test"
+ version="2.0">
+ <xsl:output method="html" encoding="iso-8859-1" version="4.0"
+ doctype-public="-//W3C//DTD HTML 4.01//EN"
+ indent="yes"/>
+
+ <xsl:template match="/">
+ <html>
+ <head>
+ <title>xsl:function</title>
+ </head>
+ <body>
+ <xsl:choose>
+ <xsl:when test="function-available('test:test')">
+ <p>Result: <xsl:value-of select="test:test()"/></p>
+ </xsl:when>
+ <xsl:otherwise>
+ <p><tt>xsl:function</tt> not supported, but properly handled (ignored)</p>
+ </xsl:otherwise>
+ </xsl:choose>
+ </body>
+ </html>
+ </xsl:template>
+
+ <xsl:function name="test:test">YES</xsl:function>
+
+</xsl:transform>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]