- tests/general/bug-8-.out: fixed in libxml xpath
authorDaniel Veillard <veillard@src.gnome.org>
Mon, 30 Apr 2001 20:34:11 +0000 (20:34 +0000)
committerDaniel Veillard <veillard@src.gnome.org>
Mon, 30 Apr 2001 20:34:11 +0000 (20:34 +0000)
- libxslt/templates.[ch] libxslt/pattern.c: fixed an namespace
  problem in predicates within a pattern. Spotted another
  potential namespace problem
Daniel

ChangeLog
libxslt/pattern.c
libxslt/templates.c
libxslt/templates.h
tests/general/bug-8-.out

index fb4bed5..b161a53 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon Apr 30 22:31:59 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/general/bug-8-.out: fixed in libxml xpath
+       * libxslt/templates.[ch] libxslt/pattern.c: fixed an namespace
+         problem in predicates within a pattern. Spotted another
+         potential namespace problem
+
 Mon Apr 30 19:29:34 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
 
        * libxslt/preproc.c libxslt/xslt.c libxslt/xsltInternals.h
index 5eaba15..94fe45c 100644 (file)
@@ -86,6 +86,8 @@ struct _xsltCompMatch {
     /* TODO fix the statically allocated size steps[] */
     int nbStep;
     int maxStep;
+    xmlNsPtr *nsList;          /* the namespaces in scope */
+    int nsNr;                  /* the number of namespaces in scope */
     xsltStepOp steps[20];        /* ops for computation */
 };
 
@@ -125,6 +127,8 @@ xsltNewCompMatch(void) {
     }
     memset(cur, 0, sizeof(xsltCompMatch));
     cur->maxStep = 20;
+    cur->nsNr = 0;
+    cur->nsList = NULL;
     return(cur);
 }
 
@@ -145,6 +149,8 @@ xsltFreeCompMatch(xsltCompMatchPtr comp) {
        xmlFree((xmlChar *)comp->mode);
     if (comp->modeURI != NULL)
        xmlFree((xmlChar *)comp->modeURI);
+    if (comp->nsList != NULL)
+       xmlFree(comp->nsList);
     for (i = 0;i < comp->nbStep;i++) {
        op = &comp->steps[i];
        if (op->value != NULL)
@@ -668,7 +674,18 @@ xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp,
                    if (step->comp == NULL)
                        goto wrong_index;
                }
-               if (!xsltEvalXPathPredicate(ctxt, step->comp))
+               if (comp->nsList == NULL) {
+                   int j = 0;
+
+                   comp->nsList = xmlGetNsList(node->doc, node);
+                   if (comp->nsList != NULL) {
+                       while (comp->nsList[j] != NULL)
+                           j++;
+                   }
+                   comp->nsNr = j;
+               }
+               if (!xsltEvalXPathPredicate(ctxt, step->comp, comp->nsList,
+                                           comp->nsNr))
                    goto wrong_index;
 
                if (pos != 0) {
index ea9aa2d..9299436 100644 (file)
@@ -42,6 +42,8 @@
  * xsltEvalXPathPredicate:
  * @ctxt:  the XSLT transformation context
  * @comp:  the XPath compiled expression
+ * @nsList:  the namespaces in scope
+ * @int nsNr:  the number of namespaces in scope
  *
  * Process the expression using XPath and evaluate the result as
  * an XPath predicate
  * Returns 1 is the predicate was true, 0 otherwise
  */
 int
-xsltEvalXPathPredicate(xsltTransformContextPtr ctxt,
-                      xmlXPathCompExprPtr comp) {
+xsltEvalXPathPredicate(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp,
+                      xmlNsPtr *nsList, int nsNr) {
     int ret, position;
     xmlXPathObjectPtr res;
 
     position = ctxt->xpathCtxt->proximityPosition;
     ctxt->xpathCtxt->node = ctxt->node;
-    /* TODO: do we need to propagate the namespaces here ? */
-    ctxt->xpathCtxt->namespaces = NULL;
-    ctxt->xpathCtxt->nsNr = 0;
+    ctxt->xpathCtxt->namespaces = nsList;
+    ctxt->xpathCtxt->nsNr = nsNr;
     res = xmlXPathCompiledEval(comp, ctxt->xpathCtxt);
     ctxt->xpathCtxt->proximityPosition = position;
     if (res != NULL) {
index 02637c5..847e6da 100644 (file)
@@ -18,7 +18,9 @@ extern "C" {
 #endif
 
 int            xsltEvalXPathPredicate          (xsltTransformContextPtr ctxt,
-                                                xmlXPathCompExprPtr comp);
+                                                xmlXPathCompExprPtr comp,
+                                                xmlNsPtr *nsList,
+                                                int nsNr);
 xmlChar *      xsltEvalTemplateString          (xsltTransformContextPtr ctxt,
                                                 xmlNodePtr node,
                                                 xmlNodePtr parent);
@@ -31,8 +33,11 @@ xmlChar *    xsltEvalStaticAttrValueTemplate (xsltStylesheetPtr style,
                                                 const xmlChar *name,
                                                 const xmlChar *ns,
                                                 int *found);
+
+/* TODO: this is obviously broken ... the namespaces should be passed too ! */
 xmlChar *      xsltEvalXPathString             (xsltTransformContextPtr ctxt,
                                                 xmlXPathCompExprPtr comp);
+
 xmlNodePtr *   xsltTemplateProcess             (xsltTransformContextPtr ctxt,
                                                 xmlNodePtr node);
 xmlAttrPtr     xsltAttrListTemplateProcess     (xsltTransformContextPtr ctxt,
index 9f6689b..cdf2066 100644 (file)
@@ -1,3 +1,3 @@
 <?xml version="1.0"?>
 
-    Big 
+    Big Success