That part is not very fun:
authorDaniel Veillard <veillard@src.gnome.org>
Tue, 23 Jan 2001 16:27:12 +0000 (16:27 +0000)
committerDaniel Veillard <veillard@src.gnome.org>
Tue, 23 Jan 2001 16:27:12 +0000 (16:27 +0000)
- tests/Makefile.am: cleanup
- libxslt/pattern.c: should support most of the patterns now
  except ID/Key and maybe some namespace checks when having
  a default namespace
- TODO: updated
Daniel

ChangeLog
TODO
libxslt/pattern.c
tests/Makefile.am

index 5b1cf50..4e2d2f6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Tue Jan 23 17:24:26 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/Makefile.am: cleanup
+       * libxslt/pattern.c: should support most of the patterns now
+         except ID/Key and maybe some namespace checks when having
+         a default namespace
+       * TODO: updated
+
 Tue Jan 23 14:58:32 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
 
        * Makefile.am libxslt.spec.in tests/REC1/Makefile.am
diff --git a/TODO b/TODO
index 45f38dd..33d6b2b 100644 (file)
--- a/TODO
+++ b/TODO
@@ -7,7 +7,6 @@ Design:
   - should transforms for a given stylesheet be thread clean,
     or can a stylesheet be enriched with document specific
     informations and cleaned up later ?
-    => currently stylesheet manipulation is not reentrant.
   - seems that saving back XSLT stylesheet from a compiled form might
     be a bit ugly ...
     
@@ -26,11 +25,12 @@ ID and Key support:
 
 Pattern tester:
   -> try to optimize for ID scan and tests.
+  -> also put fast lookup for "text()", "comment()", "node()"
+     based patterns lists.
 
 Pattern scanner:
   -> add error checks on all returns
   -> handle unions
-  -> compute priority
 
 Error handling:
   -> check the version stuff, design a separate module for error interfacing
@@ -72,3 +72,6 @@ Support for disable-output-escaping="yes":
      level.
   => Done with a trick, text node name is different, requires > 2.2.11
 
+Pattern scanner:
+  -> compute priority
+  => done
index a96c19e..3b6529b 100644 (file)
@@ -280,7 +280,17 @@ xsltTestCompMatch(xsltCompMatchPtr comp, xmlNodePtr node) {
                    continue;
                if (!xmlStrEqual(step->value, node->name))
                    return(0);
-               /* TODO: Handle namespace ... */
+
+               /* Namespace test */
+               if (node->ns == NULL) {
+                   if (step->value2 != NULL)
+                       return(0);
+               } else if (node->ns->href != NULL) {
+                   if (step->value2 == NULL)
+                       return(0);
+                   if (!xmlStrEqual(step->value2, node->ns->href))
+                       return(0);
+               }
                continue;
             case XSLT_OP_CHILD:
                TODO /* Handle OP_CHILD */
@@ -292,7 +302,17 @@ xsltTestCompMatch(xsltCompMatchPtr comp, xmlNodePtr node) {
                    continue;
                if (!xmlStrEqual(step->value, node->name))
                    return(0);
-               /* TODO: Handle namespace ... */
+
+               /* Namespace test */
+               if (node->ns == NULL) {
+                   if (step->value2 != NULL)
+                       return(0);
+               } else if (node->ns->href != NULL) {
+                   if (step->value2 == NULL)
+                       return(0);
+                   if (!xmlStrEqual(step->value2, node->ns->href))
+                       return(0);
+               }
                continue;
             case XSLT_OP_PARENT:
                node = node->parent;
@@ -302,7 +322,16 @@ xsltTestCompMatch(xsltCompMatchPtr comp, xmlNodePtr node) {
                    continue;
                if (!xmlStrEqual(step->value, node->name))
                    return(0);
-               /* TODO: Handle namespace ... */
+               /* Namespace test */
+               if (node->ns == NULL) {
+                   if (step->value2 != NULL)
+                       return(0);
+               } else if (node->ns->href != NULL) {
+                   if (step->value2 == NULL)
+                       return(0);
+                   if (!xmlStrEqual(step->value2, node->ns->href))
+                       return(0);
+               }
                continue;
             case XSLT_OP_ANCESTOR:
                /* TODO: implement coalescing of ANCESTOR/NODE ops */
@@ -323,8 +352,15 @@ xsltTestCompMatch(xsltCompMatchPtr comp, xmlNodePtr node) {
                    if (node == NULL)
                        return(0);
                    if (xmlStrEqual(step->value, node->name)) {
-                       /* TODO: Handle namespace ... */
-                       break;
+                       /* Namespace test */
+                       if (node->ns == NULL) {
+                           if (step->value2 == NULL)
+                               break;
+                       } else if (node->ns->href != NULL) {
+                           if ((step->value2 != NULL) &&
+                               (xmlStrEqual(step->value2, node->ns->href)))
+                               break;
+                       }
                    }
                }
                if (node == NULL)
@@ -337,25 +373,61 @@ xsltTestCompMatch(xsltCompMatchPtr comp, xmlNodePtr node) {
                TODO /* Handle Keys, might be done differently */
                break;
             case XSLT_OP_NS:
-               TODO /* Handle Namespace */
+               /* Namespace test */
+               if (node->ns == NULL) {
+                   if (step->value != NULL)
+                       return(0);
+               } else if (node->ns->href != NULL) {
+                   if (step->value == NULL)
+                       return(0);
+                   if (!xmlStrEqual(step->value, node->ns->href))
+                       return(0);
+               }
                break;
             case XSLT_OP_ALL:
-               TODO /* Handle * */
+               switch (node->type) {
+                   case XML_DOCUMENT_NODE:
+                   case XML_HTML_DOCUMENT_NODE:
+                   case XML_ELEMENT_NODE:
+                       break;
+                   default:
+                       return(0);
+               }
                break;
            case XSLT_OP_PREDICATE:
                TODO /* Handle Predicate */
                break;
             case XSLT_OP_PI:
-               TODO /* Handle PI() */
+               if (node->type != XML_PI_NODE)
+                   return(0);
+               if (step->value == NULL) {
+                   if (!xmlStrEqual(step->value, node->name))
+                       return(0);
+               }
                break;
             case XSLT_OP_COMMENT:
-               TODO /* Handle Comments() */
+               if (node->type != XML_COMMENT_NODE)
+                   return(0);
                break;
             case XSLT_OP_TEXT:
-               TODO /* Handle Text() */
+               if ((node->type != XML_TEXT_NODE) &&
+                   (node->type != XML_CDATA_SECTION_NODE))
+                   return(0);
                break;
             case XSLT_OP_NODE:
-               TODO /* Handle Node() */
+               switch (node->type) {
+                   case XML_DOCUMENT_NODE:
+                   case XML_HTML_DOCUMENT_NODE:
+                   case XML_ELEMENT_NODE:
+                   case XML_CDATA_SECTION_NODE:
+                   case XML_PI_NODE:
+                   case XML_COMMENT_NODE:
+                   case XML_TEXT_NODE:
+                   case XML_ATTRIBUTE_NODE:
+                       break;
+                   default:
+                       return(0);
+               }
                break;
        }
     }
@@ -601,7 +673,7 @@ xsltCompileIdKeyPattern(xsltParserContextPtr ctxt, xmlChar *name, int aid) {
        }
        NEXT;
        PUSH(XSLT_OP_COMMENT, NULL, NULL);
-    } else if (xmlStrEqual(name, (const xmlChar *)"comment")) {
+    } else if (xmlStrEqual(name, (const xmlChar *)"node")) {
        NEXT;
        SKIP_BLANKS;
        if (CUR != ')') {
@@ -973,7 +1045,7 @@ error:
 int
 xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur) {
     xsltCompMatchPtr pat, list;
-    const xmlChar *name;
+    const xmlChar *name = NULL;
     xmlChar *p, *pattern, tmp;
 
     if ((style == NULL) || (cur == NULL))
index 5c1e073..b463578 100644 (file)
@@ -2,24 +2,3 @@
 
 SUBDIRS=REC1 REC2
 
-INCLUDES = -I$(srcdir) -I$(top_srcdir)/libxslt \
-       $(LIBXML_CFLAGS) -Wall -ansi
-
-noinst_PROGRAMS = # testxslt testevents
-
-DEPS = $(top_builddir)/libxslt/libxslt.la
-LDADDS = $(top_builddir)/libxslt/libxslt.la $(LIBXML_LIBS)
-
-#testxslt_SOURCES = test-xslt.c
-#testxslt_LDFLAGS =
-#testxslt_DEPENDENCIES = $(DEPS)
-#testxslt_LDADD = $(LDADDS)
-#
-#testevents_SOURCES = test-events.c
-#testevents_LDFLAGS =
-#testevents_DEPENDENCIES = $(DEPS)
-#testevents_LDADD = $(LDADDS)
-
-test tests: $(top_builddir)/libxslt/xsltproc
-       @(cd REC1 ; make test)
-       @(cd REC2 ; make test)