diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2012-08-15 22:40:05 +0200 |
---|---|---|
committer | Daniel Veillard <veillard@redhat.com> | 2012-08-16 16:21:13 +0800 |
commit | faeaa3146cab124628785c4b536ba0b824292f8d (patch) | |
tree | ee3e3a3b3a417a217557d010b8cfe1b71183ba2c | |
parent | abb7c65980c7da450f0447dcc6a1821eef99d473 (diff) | |
download | libxslt-faeaa3146cab124628785c4b536ba0b824292f8d.tar.gz libxslt-faeaa3146cab124628785c4b536ba0b824292f8d.tar.bz2 libxslt-faeaa3146cab124628785c4b536ba0b824292f8d.zip |
Forwards-compatible processing of unknown top level elements
Bug #677901
-rw-r--r-- | libxslt/xslt.c | 14 | ||||
-rw-r--r-- | libxslt/xsltInternals.h | 4 | ||||
-rw-r--r-- | tests/docs/bug-175.xml | 1 | ||||
-rw-r--r-- | tests/general/bug-175.err | 6 | ||||
-rw-r--r-- | tests/general/bug-175.out | 8 | ||||
-rw-r--r-- | tests/general/bug-175.xsl | 30 |
6 files changed, 55 insertions, 8 deletions
diff --git a/libxslt/xslt.c b/libxslt/xslt.c index 2bc8af59..bd14092b 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 afb2a2c4..5be59bcc 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 00000000..69d62f2c --- /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 00000000..70cddd5b --- /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 00000000..e9cf403b --- /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 00000000..f25e4c94 --- /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> |