* daniel@veillard.com
*/
-#define IN_LIBXSLT
-#include "libxslt.h"
-
-#include <string.h>
-
-#include <libxml/xmlmemory.h>
-#include <libxml/tree.h>
-#include <libxml/valid.h>
-#include <libxml/hash.h>
-#include <libxml/xmlerror.h>
-#include <libxml/parserInternals.h>
-#include <libxml/xpathInternals.h>
-#include "xslt.h"
-#include "xsltInternals.h"
-#include "xsltutils.h"
-#include "imports.h"
-#include "templates.h"
-#include "keys.h"
+#include "precomp.h"
#ifdef WITH_XSLT_DEBUG
#define WITH_XSLT_DEBUG_KEYS
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++;
}
prev->next = key;
}
key->next = NULL;
+ key = NULL;
error:
if (pattern != NULL)
xmlFree(pattern);
+ if (key != NULL)
+ xsltFreeKeyDef(key);
return(0);
}
cur = matchList->nodeTab[i];
if (! IS_XSLT_REAL_NODE(cur))
continue;
+ ctxt->node = cur;
xpctxt->node = cur;
/*
* Process the 'use' of the xsl:key.