[xslt] xsl:template without name and match attributes should not be allowed
- From: Nikolai Weibull <now disu se>
- To: Gnome XSLT <xslt gnome org>
- Subject: [xslt] xsl:template without name and match attributes should not be allowed
- Date: Wed, 12 Jun 2019 22:49:15 +0200
Hi!
It seems that libxslt allows for an xsl:template to be created without name or match attribute. This isn’t
allowed by the standard and sometimes my colleagues forget and then wonder why things don’t work :-).
A simple check in xsltAddTemplate would suffice, for example,
diff --git a/libxslt/pattern.c b/libxslt/pattern.c
index 32de1b48..597b6b44 100644
--- a/libxslt/pattern.c
+++ b/libxslt/pattern.c
@@ -2131,8 +2131,15 @@ xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur,
xmlHashAddEntry2(style->namedTemplates, cur->name, cur->nameURI, cur);
}
- if (cur->match == NULL)
+ if (cur->match == NULL) {
+ if (cur->name == NULL) {
+ xsltTransformError(NULL, style, cur->elem,
+ "xsl:template: need to specify match or name attribute\n");
+ style->errors++;
+ return(-1);
+ }
return(0);
+ }
priority = cur->priority;
pat = xsltCompilePatternInternal(cur->match, style->doc, cur->elem,
but I couldn’t quite figure out the structure of the tests directory, so I didn’t write a test for this. Any
help in this area would be appreciated.
Nikolai
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]