Boring stuff for a Sunday evening:
authorDaniel Veillard <veillard@src.gnome.org>
Sun, 28 Jan 2001 20:47:06 +0000 (20:47 +0000)
committerDaniel Veillard <veillard@src.gnome.org>
Sun, 28 Jan 2001 20:47:06 +0000 (20:47 +0000)
- FEATURES TODO: updates
- libxslt/xsltutils.[ch] libxslt/xsltInternals.h libxslt/xsltutils.h:
  added xsl:message
Daniel

ChangeLog
FEATURES
TODO
libxslt/transform.c
libxslt/xsltInternals.h
libxslt/xsltutils.c
libxslt/xsltutils.h

index ea0627e..dcd1a94 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sun Jan 28 21:45:23 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * FEATURES TODO: updates
+       * libxslt/xsltutils.[ch] libxslt/xsltInternals.h libxslt/xsltutils.h:
+         added xsl:message
+
 Sun Jan 28 17:25:35 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
 
        * FEATURES TODO: updates
index 08e00c8..bc85487 100644 (file)
--- a/FEATURES
+++ b/FEATURES
@@ -177,8 +177,8 @@ NO                  zero-digit = char
 NO                     digit = char 
 NO                     pattern-separator = char
 
-NO                 xsl:message
-NO                     terminate = "yes" | "no"
+YES                xsl:message
+YES                    terminate = "yes" | "no"
 
 NO                 xsl:fallback
 
diff --git a/TODO b/TODO
index 2253637..9327d43 100644 (file)
--- a/TODO
+++ b/TODO
@@ -20,7 +20,7 @@ Import:
 
 Extra functions:
   -> document() should not be a problem since Result Tree Fragments are
-     implemnted
+     implemented
   => started, incomplete
   -> missing key support
 
@@ -32,7 +32,6 @@ Pattern tester:
 
 Pattern scanner:
   -> add error checks on all returns
-  -> handle unions
 
 Error handling:
   -> check the version stuff, design a separate module for error interfacing
@@ -83,6 +82,7 @@ Support for disable-output-escaping="yes":
 
 Pattern scanner:
   -> compute priority
+  -> handle unions
   => done
 
 Pattern tester:
index 171e45b..665d1ea 100644 (file)
@@ -571,6 +571,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
     xmlNodePtr delete = NULL;
     int strip_spaces = -1;
 
+    CHECK_STOPPED;
     switch (node->type) {
        case XML_DOCUMENT_NODE:
        case XML_HTML_DOCUMENT_NODE:
@@ -714,6 +715,7 @@ xsltCallTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
     }
     cur = inst->children;
     while (cur != NULL) {
+       CHECK_STOPPEDE;
        if (IS_XSLT_ELEM(cur)) {
            if (IS_XSLT_NAME(cur, "with-param")) {
                if (has_param == 0) {
@@ -917,6 +919,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
     xmlNodePtr oldInsert;
     int has_variables = 0;
 
+    CHECK_STOPPED;
     oldInsert = insert = ctxt->insert;
     /*
      * Insert all non-XSLT nodes found in the template
@@ -987,6 +990,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
                    has_variables = 1;
                }
                xsltCallTemplate(ctxt, node, cur);
+           } else if (IS_XSLT_NAME(cur, "message")) {
            } else {
 #ifdef DEBUG_PROCESS
                xsltGenericError(xsltGenericDebugContext,
@@ -994,6 +998,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
 #endif
                TODO
            }
+           CHECK_STOPPED;
            goto skip_children;
        } else if (cur->type == XML_TEXT_NODE) {
            /*
index 9056dc5..b4f7c0b 100644 (file)
@@ -131,6 +131,12 @@ typedef enum {
     XSLT_OUTPUT_TEXT
 } xsltOutputType;
 
+typedef enum {
+    XSLT_STATE_OK = 0,
+    XSLT_STATE_ERROR,
+    XSLT_STATE_STOPPED
+} xsltTransformState;
+
 typedef struct _xsltTransformContext xsltTransformContext;
 typedef xsltTransformContext *xsltTransformContextPtr;
 struct _xsltTransformContext {
@@ -148,8 +154,13 @@ struct _xsltTransformContext {
     void *variablesHash;               /* hash table or wherever variables
                                           informations are stored */
     xmlDocPtr extraDocs;               /* extra docs parsed by document() */
+    xsltTransformState state;          /* the current state */
 };
 
+#define CHECK_STOPPED if (ctxt->state == XSLT_STATE_STOPPED) return;
+#define CHECK_STOPPEDE if (ctxt->state == XSLT_STATE_STOPPED) goto error;
+#define CHECK_STOPPED0 if (ctxt->state == XSLT_STATE_STOPPED) return(0);
+
 /*
  * Functions associated to the internal types
  */
index ba2457a..71fdbba 100644 (file)
 #include <libxml/xmlerror.h>
 #include <libxml/xmlIO.h>
 #include "xsltutils.h"
+#include "templates.h"
 #include "xsltInternals.h"
 
 
 /************************************************************************
  *                                                                     *
+ *             Handling of XSLT stylesheets messages                   *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltMessage:
+ * @ctxt:  an XSLT processing context
+ * @node:  The current node
+ * @inst:  The node containing the message instruction
+ *
+ * Process and xsl:message construct
+ */
+void
+xsltMessage(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst) {
+    xmlChar *prop, *message;
+    int terminate = 0;
+
+    if ((ctxt == NULL) || (inst == NULL))
+       return;
+
+    prop = xmlGetNsProp(inst, (const xmlChar *)"terminate", XSLT_NAMESPACE);
+    if (prop != NULL) {
+       if (xmlStrEqual(prop, (const xmlChar *)"yes")) {
+           terminate = 1;
+       } else if (xmlStrEqual(prop, (const xmlChar *)"yes")) {
+           terminate = 0;
+       } else {
+           xsltGenericError(xsltGenericErrorContext,
+               "xsl:message : terminate expecting 'yes' or 'no'\n");
+       }
+       xmlFree(prop);
+    }
+    message = xsltEvalTemplateString(ctxt, node, inst);
+    if (message != NULL) {
+       xsltGenericError(xsltGenericErrorContext, (const char *)message);
+       xmlFree(message);
+    }
+    if (terminate)
+       ctxt->state = XSLT_STATE_STOPPED;
+}
+
+/************************************************************************
+ *                                                                     *
  *             Handling of out of context errors                       *
  *                                                                     *
  ************************************************************************/
index c3246be..59d06c4 100644 (file)
@@ -59,6 +59,9 @@ extern void *xsltGenericErrorContext;
 extern xmlGenericErrorFunc xsltGenericDebug;
 extern void *xsltGenericDebugContext;
 
+void           xsltMessage                     (xsltTransformContextPtr ctxt,
+                                                xmlNodePtr node,
+                                                xmlNodePtr inst);
 void           xsltSetGenericErrorFunc         (void *ctx,
                                                 xmlGenericErrorFunc handler);
 void           xsltSetGenericDebugFunc         (void *ctx,