diff --git a/ChangeLog b/ChangeLog index 361132ed976c364a61ce9e9fcedd42d0bf62dbbf_Q2hhbmdlTG9n..d510b2f0d0332fb52c6e83b0a1d9af96fa4c04cd_Q2hhbmdlTG9n 100644 --- 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 diff --git a/libxslt/Makefile.am b/libxslt/Makefile.am index 361132ed976c364a61ce9e9fcedd42d0bf62dbbf_bGlieHNsdC9NYWtlZmlsZS5hbQ==..d510b2f0d0332fb52c6e83b0a1d9af96fa4c04cd_bGlieHNsdC9NYWtlZmlsZS5hbQ== 100644 --- a/libxslt/Makefile.am +++ b/libxslt/Makefile.am @@ -16,7 +16,7 @@ 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 = diff --git a/libxslt/xslt.c b/libxslt/xslt.c index 361132ed976c364a61ce9e9fcedd42d0bf62dbbf_bGlieHNsdC94c2x0LmM=..d510b2f0d0332fb52c6e83b0a1d9af96fa4c04cd_bGlieHNsdC94c2x0LmM= 100644 --- a/libxslt/xslt.c +++ b/libxslt/xslt.c @@ -9,5 +9,8 @@ * Daniel.Veillard@imag.fr */ +#include <string.h> + +#include <libxml/xmlmemory.h> #include <libxml/parser.h> #include <libxml/tree.h> @@ -12,5 +15,6 @@ #include <libxml/parser.h> #include <libxml/tree.h> +#include <libxml/xmlerror.h> #include <libxslt/xslt.h> #include <libxslt/xsltInternals.h> @@ -14,6 +18,12 @@ #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 * @@ -21,6 +31,27 @@ ************************************************************************/ /** + * 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 * @@ -28,6 +59,12 @@ */ 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 @@ 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); } diff --git a/libxslt/xsltInternals.h b/libxslt/xsltInternals.h index 361132ed976c364a61ce9e9fcedd42d0bf62dbbf_bGlieHNsdC94c2x0SW50ZXJuYWxzLmg=..d510b2f0d0332fb52c6e83b0a1d9af96fa4c04cd_bGlieHNsdC94c2x0SW50ZXJuYWxzLmg= 100644 --- a/libxslt/xsltInternals.h +++ b/libxslt/xsltInternals.h @@ -21,9 +21,10 @@ 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); @@ -24,9 +25,10 @@ }; /* * Functions associated to the internal types */ xsltStylesheetPtr xsltParseStylesheetFile (const xmlChar* filename); +void xsltFreeStylesheet (xsltStylesheetPtr sheet); #ifdef __cplusplus } diff --git a/libxslt/xsltproc.c b/libxslt/xsltproc.c index 361132ed976c364a61ce9e9fcedd42d0bf62dbbf_bGlieHNsdC94c2x0cHJvYy5j..d510b2f0d0332fb52c6e83b0a1d9af96fa4c04cd_bGlieHNsdC94c2x0cHJvYy5j 100644 --- a/libxslt/xsltproc.c +++ b/libxslt/xsltproc.c @@ -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 @@ int main(int argc, char **argv) { - int i, count; - int files = 0; + int i; xsltStylesheetPtr cur; LIBXML_TEST_VERSION