changed priority of template patterns starting with '//' from 0.0 to 0.5
authorWilliam M. Brack <wbrack@src.gnome.org>
Fri, 23 Jan 2004 10:51:45 +0000 (10:51 +0000)
committerWilliam M. Brack <wbrack@src.gnome.org>
Fri, 23 Jan 2004 10:51:45 +0000 (10:51 +0000)
* libxslt/pattern.c: changed priority of template patterns
  starting with '//' from 0.0 to 0.5 (Bug 131705)

ChangeLog
libxslt/pattern.c

index a8a7df1..0fd6115 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Jan 23 18:52:22 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/pattern.c: changed priority of template patterns
+         starting with '//' from 0.0 to 0.5 (Bug 131705)
+
 Thu Jan 22 18:42:03 CET 2004 Daniel Veillard <daniel@veillard.com>
 
        * libxslt/xslt.c: applied patch from Stefan Kost to fix
index 1914caa..7e2ed99 100644 (file)
@@ -1643,6 +1643,7 @@ xsltCompileLocationPathPattern(xsltParserContextPtr ctxt) {
         */
        NEXT;
        NEXT;
+       ctxt->comp->priority = 0.5;     /* '//' means not 0 priority */
        xsltCompileRelativePathPattern(ctxt, NULL);
     } else if (CUR == '/') {
        /*
@@ -1784,6 +1785,11 @@ xsltCompilePattern(const xmlChar *pattern, xmlDocPtr doc,
                         "xsltCompilePattern : parsing '%s'\n",
                         element->pattern);
 #endif
+       /*
+        Preset default priority to be zero.
+        This may be changed by xsltCompileLocationPathPattern.
+        */
+       element->priority = 0;
        xsltCompileLocationPathPattern(ctxt);
        if (ctxt->error) {
            xsltTransformError(NULL, style, node,
@@ -1801,42 +1807,36 @@ xsltCompilePattern(const xmlChar *pattern, xmlDocPtr doc,
        /*
         * Set-up the priority
         */
-       if (((element->steps[0].op == XSLT_OP_ELEM) ||
-            (element->steps[0].op == XSLT_OP_ATTR)) &&
-           (element->steps[0].value != NULL) &&
-           (element->steps[1].op == XSLT_OP_END)) {
-           element->priority = 0;
-#if 0
-       } else if ((element->steps[0].op == XSLT_OP_ROOT) &&
-                  (element->steps[1].op == XSLT_OP_END)) {
-           element->priority = 0;
-#endif
-       } else if ((element->steps[0].op == XSLT_OP_PI) &&
-                  (element->steps[0].value != NULL) &&
-                  (element->steps[1].op == XSLT_OP_END)) {
-           element->priority = 0;
-       } else if ((element->steps[0].op == XSLT_OP_ATTR) &&
-                  (element->steps[0].value2 != NULL) &&
-                  (element->steps[1].op == XSLT_OP_END)) {
-           element->priority = -0.25;
-       } else if ((element->steps[0].op == XSLT_OP_NS) &&
-                  (element->steps[0].value != NULL) &&
-                  (element->steps[1].op == XSLT_OP_END)) {
-           element->priority = -0.25;
-       } else if ((element->steps[0].op == XSLT_OP_ATTR) &&
-                  (element->steps[0].value == NULL) &&
-                  (element->steps[0].value2 == NULL) &&
-                  (element->steps[1].op == XSLT_OP_END)) {
-           element->priority = -0.5;
-       } else if (((element->steps[0].op == XSLT_OP_PI) ||
-                   (element->steps[0].op == XSLT_OP_TEXT) ||
-                   (element->steps[0].op == XSLT_OP_ALL) ||
-                   (element->steps[0].op == XSLT_OP_NODE) ||
-                   (element->steps[0].op == XSLT_OP_COMMENT)) &&
-                  (element->steps[1].op == XSLT_OP_END)) {
-           element->priority = -0.5;
-       } else {
-           element->priority = 0.5;
+       if (element->priority == 0) {   /* if not yet determined */
+           if (((element->steps[0].op == XSLT_OP_ELEM) ||
+                (element->steps[0].op == XSLT_OP_ATTR) ||
+                (element->steps[0].op == XSLT_OP_PI)) &&
+               (element->steps[0].value != NULL) &&
+               (element->steps[1].op == XSLT_OP_END)) {
+               ;       /* previously preset */
+           } else if ((element->steps[0].op == XSLT_OP_ATTR) &&
+                      (element->steps[0].value2 != NULL) &&
+                      (element->steps[1].op == XSLT_OP_END)) {
+                       element->priority = -0.25;
+           } else if ((element->steps[0].op == XSLT_OP_NS) &&
+                      (element->steps[0].value != NULL) &&
+                      (element->steps[1].op == XSLT_OP_END)) {
+                       element->priority = -0.25;
+           } else if ((element->steps[0].op == XSLT_OP_ATTR) &&
+                      (element->steps[0].value == NULL) &&
+                      (element->steps[0].value2 == NULL) &&
+                      (element->steps[1].op == XSLT_OP_END)) {
+                       element->priority = -0.5;
+           } else if (((element->steps[0].op == XSLT_OP_PI) ||
+                      (element->steps[0].op == XSLT_OP_TEXT) ||
+                      (element->steps[0].op == XSLT_OP_ALL) ||
+                      (element->steps[0].op == XSLT_OP_NODE) ||
+                      (element->steps[0].op == XSLT_OP_COMMENT)) &&
+                      (element->steps[1].op == XSLT_OP_END)) {
+                       element->priority = -0.5;
+           } else {
+               element->priority = 0.5;
+           }
        }
 #ifdef WITH_XSLT_DEBUG_PATTERN
        xsltGenericDebug(xsltGenericDebugContext,