#include <libxml/xmlerror.h>
#include <libxml/parserInternals.h>
#include <libxml/xpathInternals.h>
+#include <libxml/xpath.h>
#include "xslt.h"
#include "xsltInternals.h"
#include "xsltutils.h"
const xmlChar *nameURI);
/************************************************************************
- * *
- * Type functions *
- * *
+ * *
+ * Type functions *
+ * *
************************************************************************/
/**
if (keyt->nameURI != NULL)
xmlFree(keyt->nameURI);
if (keyt->keys != NULL)
- xmlHashFree(keyt->keys,
+ xmlHashFree(keyt->keys,
(xmlHashDeallocator) xmlXPathFreeNodeSet);
memset(keyt, -1, sizeof(xsltKeyTable));
xmlFree(keyt);
}
/************************************************************************
- * *
- * The interpreter for the precompiled patterns *
- * *
+ * *
+ * The interpreter for the precompiled patterns *
+ * *
************************************************************************/
end = skipPredicate(match, end);
if (end <= 0) {
xsltTransformError(NULL, style, inst,
- "key pattern is malformed: %s",
- key->match);
+ "xsl:key : 'match' pattern is malformed: %s",
+ key->match);
if (style != NULL) style->errors++;
goto error;
}
}
if (current == end) {
xsltTransformError(NULL, style, inst,
- "key pattern is empty\n");
+ "xsl:key : 'match' pattern is empty\n");
if (style != NULL) style->errors++;
goto error;
}
}
current = end;
}
+ if (pattern == NULL) {
+ xsltTransformError(NULL, style, inst,
+ "xsl:key : 'match' pattern is empty\n");
+ if (style != NULL) style->errors++;
+ goto error;
+ }
#ifdef WITH_XSLT_DEBUG_KEYS
xsltGenericDebug(xsltGenericDebugContext,
" resulting pattern %s\n", pattern);
* Maybe a search for "$", if it occurs outside of quotation
* marks, could be sufficient.
*/
+#ifdef XML_XPATH_NOVAR
+ key->comp = xsltXPathCompileFlags(style, pattern, XML_XPATH_NOVAR);
+#else
key->comp = xsltXPathCompile(style, pattern);
+#endif
if (key->comp == NULL) {
xsltTransformError(NULL, style, inst,
- "xsl:key : XPath pattern compilation failed '%s'\n",
+ "xsl:key : 'match' pattern compilation failed '%s'\n",
pattern);
if (style != NULL) style->errors++;
}
+#ifdef XML_XPATH_NOVAR
+ key->usecomp = xsltXPathCompileFlags(style, use, XML_XPATH_NOVAR);
+#else
key->usecomp = xsltXPathCompile(style, use);
+#endif
if (key->usecomp == NULL) {
xsltTransformError(NULL, style, inst,
- "xsl:key : XPath pattern compilation failed '%s'\n",
+ "xsl:key : 'use' expression compilation failed '%s'\n",
use);
if (style != NULL) style->errors++;
}