very early steps, Daniel.
authorDaniel Veillard <veillard@src.gnome.org>
Sun, 7 Jan 2001 15:17:08 +0000 (15:17 +0000)
committerDaniel Veillard <veillard@src.gnome.org>
Sun, 7 Jan 2001 15:17:08 +0000 (15:17 +0000)
ChangeLog
libxslt/Makefile.am
libxslt/xslt.c
libxslt/xsltInternals.h
libxslt/xsltproc.c

index 0ac8959..151acb4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Jan  7 16:11:42 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xslt.[ch] libxslt/xsltInternals.h libxslt/xsltproc.c:
+         very early coding
+
 Sun Jan  7 15:10:54 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
 
        * configure.in Makefile.am AUTHORS NEWS autogen.sh config.h.in
index eea81b5..173d626 100644 (file)
@@ -16,7 +16,7 @@ libxslt_la_SOURCES =                  \
 noinst_PROGRAMS = xsltproc
 
 DEPS = $(top_builddir)/libxslt/libxslt.la
-LDADDS = $(top_builddir)/libxslt/libxslt.la $(LIBXML_LIBS)
+LDADDS = -L. $(top_builddir)/libxslt/libxslt.la $(LIBXML_LIBS)
 
 xsltproc_SOURCES = xsltproc.c
 xsltproc_LDFLAGS =
index c92cf7d..e88dcda 100644 (file)
@@ -9,11 +9,21 @@
  * Daniel.Veillard@imag.fr
  */
 
+#include <string.h>
+
+#include <libxml/xmlmemory.h>
 #include <libxml/parser.h>
 #include <libxml/tree.h>
+#include <libxml/xmlerror.h>
 #include <libxslt/xslt.h>
 #include <libxslt/xsltInternals.h>
 
+/*
+ * There is no XSLT specific error reporting module yet
+ */
+#define xsltGenericError xmlGenericError
+#define xsltGenericErrorContext xmlGenericErrorContext
+
 /************************************************************************
  *                                                                     *
  *             Routines to handle XSLT data structures                 *
  ************************************************************************/
 
 /**
+ * xsltNewStylesheet:
+ *
+ * Create a new XSLT Stylesheet
+ *
+ * Returns the newly allocated xsltStylesheetPtr or NULL in case of error
+ */
+xsltStylesheetPtr
+xsltNewStylesheet(void) {
+    xsltStylesheetPtr cur;
+
+    cur = (xsltStylesheetPtr) xmlMalloc(sizeof(xsltStylesheet));
+    if (cur == NULL) {
+        xsltGenericError(xsltGenericErrorContext,
+               "xsltNewStylesheet : malloc failed\n");
+       return(NULL);
+    }
+    memset(cur, 0, sizeof(xsltStylesheet));
+    return(cur);
+}
+
+/**
  * xsltFreeStylesheet:
  * @sheet:  an XSLT stylesheet
  *
  */
 void
 xsltFreeStylesheet(xsltStylesheetPtr sheet) {
+    if (sheet == NULL)
+       return;
+    if (sheet->doc != NULL)
+       xmlFreeDoc(sheet->doc);
+    memset(sheet, -1, sizeof(xsltStylesheet));
+    xmlFree(sheet);
 }
 
 /************************************************************************
@@ -48,6 +85,24 @@ xsltFreeStylesheet(xsltStylesheetPtr sheet) {
 xsltStylesheetPtr
 xsltParseStylesheetFile(const xmlChar* filename) {
     xsltStylesheetPtr ret;
+    xmlDocPtr doc;
+
+    if (filename == NULL)
+       return(NULL);
+
+    doc = xmlParseFile(filename);
+    if (doc == NULL) {
+        xsltGenericError(xsltGenericErrorContext,
+               "xsltParseStylesheetFile : cannot parse %s\n", filename);
+       return(NULL);
+    }
+    ret = xsltNewStylesheet();
+    if (ret == NULL) {
+       xmlFreeDoc(doc);
+       return(NULL);
+    }
+
+    ret->doc = doc;
 
     return(ret);
 }
index c59d780..4cbaea6 100644 (file)
@@ -21,12 +21,14 @@ extern "C" {
 typedef struct _xsltStylesheet xsltStylesheet;
 typedef xsltStylesheet *xsltStylesheetPtr;
 struct _xsltStylesheet {
+    xmlDocPtr doc;     /* the parsed XML stylesheet */
 };
 
 /*
  * Functions associated to the internal types
  */
 xsltStylesheetPtr      xsltParseStylesheetFile (const xmlChar* filename);
+void                   xsltFreeStylesheet      (xsltStylesheetPtr sheet);
 
 #ifdef __cplusplus
 }
index 56c5cd6..e0690ce 100644 (file)
@@ -6,6 +6,8 @@
  * Daniel.Veillard@imag.fr
  */
 
+#include <string.h>
+#include <libxml/xmlmemory.h>
 #include <libxslt/xslt.h>
 #include <libxslt/xsltInternals.h>
 
@@ -13,8 +15,7 @@ static int debug = 0;
 
 int
 main(int argc, char **argv) {
-    int i, count;
-    int files = 0;
+    int i;
     xsltStylesheetPtr cur;
 
     LIBXML_TEST_VERSION