diff --git a/ChangeLog b/ChangeLog index 82990e3a..8a3eaead 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Fri Oct 31 15:53:45 CET 2003 Daniel Veillard + + * libxslt/documents.c libxslt/imports.c libxslt/xslt.c libxslt/xslt.h + xsltproc/xsltproc.c: switch to use xmlReadfile instead of + xmlParseFile, this avoid relying on global parser options, far + far cleaner. + * tests/XSLTMark/xslbench1.out tests/general/bug-90.out: fixes a + slightly corrected output for CDATA and STYLE element save. + Tue Oct 28 15:30:54 CET 2003 Daniel Veillard * configure.in python/Makefile.am python/tests/Makefile.am: applied diff --git a/libxslt/documents.c b/libxslt/documents.c index 34b3f656..304ff721 100644 --- a/libxslt/documents.c +++ b/libxslt/documents.c @@ -192,7 +192,11 @@ xsltLoadDocument(xsltTransformContextPtr ctxt, const xmlChar *URI) { ret = ret->next; } +#ifdef XSLT_PARSE_OPTIONS + doc = xmlReadFile((const char *) URI, NULL, XSLT_PARSE_OPTIONS); +#else doc = xmlParseFile((const char *) URI); +#endif if (doc == NULL) return(NULL); @@ -262,7 +266,11 @@ xsltLoadStyleDocument(xsltStylesheetPtr style, const xmlChar *URI) { ret = ret->next; } +#ifdef XSLT_PARSE_OPTIONS + doc = xmlReadFile((const char *) URI, NULL, XSLT_PARSE_OPTIONS); +#else doc = xmlParseFile((const char *) URI); +#endif if (doc == NULL) return(NULL); diff --git a/libxslt/imports.c b/libxslt/imports.c index 5df2a57a..eea90c19 100644 --- a/libxslt/imports.c +++ b/libxslt/imports.c @@ -107,7 +107,11 @@ xsltParseStylesheetImport(xsltStylesheetPtr style, xmlNodePtr cur) { } } - import = xmlParseFile((const char *)URI); +#ifdef XSLT_PARSE_OPTIONS + import = xmlReadFile((const char *) URI, NULL, XSLT_PARSE_OPTIONS); +#else + import = xmlParseFile((const char *) URI); +#endif if (import == NULL) { xsltTransformError(NULL, style, cur, "xsl:import : unable to load %s\n", URI); diff --git a/libxslt/xslt.c b/libxslt/xslt.c index 676b1190..0c5287d7 100644 --- a/libxslt/xslt.c +++ b/libxslt/xslt.c @@ -2059,7 +2059,11 @@ xsltParseStylesheetFile(const xmlChar* filename) { } } +#ifdef XSLT_PARSE_OPTIONS + doc = xmlReadFile((const char *) filename, NULL, XSLT_PARSE_OPTIONS); +#else doc = xmlParseFile((const char *) filename); +#endif if (doc == NULL) { xsltTransformError(NULL, NULL, NULL, "xsltParseStylesheetFile : cannot parse %s\n", filename); @@ -2254,6 +2258,14 @@ xsltLoadStylesheetPI(xmlDocPtr doc) { subtree = ID->parent; fake = xmlNewDoc(NULL); if (fake != NULL) { +#if LIBXML_VERSION >= 20600 + /* + * the dictionnary should be shared since nodes are + * moved over. + */ + fake->dict = doc->dict; + xmlDictReference(doc->dict); +#endif xmlUnlinkNode(subtree); xmlAddChild((xmlNodePtr) fake, subtree); ret = xsltParseStylesheetDoc(fake); diff --git a/libxslt/xslt.h b/libxslt/xslt.h index 4c2eaa01..d2584bab 100644 --- a/libxslt/xslt.h +++ b/libxslt/xslt.h @@ -44,6 +44,16 @@ extern "C" { */ #define XSLT_NAMESPACE ((xmlChar *) "http://www.w3.org/1999/XSL/Transform") +#if LIBXML_VERSION >= 20600 +/** + * XSLT_PARSE_OPTIONS: + * + * The set of options to pass to an xmlReadxxx when loading files for + * XSLT consumption. + */ +#define XSLT_PARSE_OPTIONS \ + XML_PARSE_NOENT | XML_PARSE_DTDLOAD | XML_PARSE_DTDATTR | XML_PARSE_NOCDATA +#endif /** * xsltMaxDepth: * diff --git a/tests/XSLTMark/xslbench1.out b/tests/XSLTMark/xslbench1.out index a7a9c3a1..40cac787 100644 --- a/tests/XSLTMark/xslbench1.out +++ b/tests/XSLTMark/xslbench1.out @@ -15,7 +15,8 @@ - diff --git a/tests/general/bug-90.out b/tests/general/bug-90.out index 04765ecb..24d329bf 100644 --- a/tests/general/bug-90.out +++ b/tests/general/bug-90.out @@ -1,17 +1,13 @@ - - - - - - diff --git a/xsltproc/xsltproc.c b/xsltproc/xsltproc.c index ea937b74..91a3a45b 100644 --- a/xsltproc/xsltproc.c +++ b/xsltproc/xsltproc.c @@ -40,6 +40,7 @@ #ifdef LIBXML_CATALOG_ENABLED #include #endif +#include #include #include @@ -103,6 +104,9 @@ static int profile = 0; #define MAX_PARAMETERS 64 #define MAX_PATHS 64 +#if LIBXML_VERSION >= 20600 +static int options = XSLT_PARSE_OPTIONS; +#endif static const char *params[MAX_PARAMETERS + 1]; static int nbparams = 0; static xmlChar *strparams[MAX_PARAMETERS + 1]; @@ -386,12 +390,21 @@ xsltProcess(xmlDocPtr doc, xsltStylesheetPtr cur, const char *filename) { res = xsltApplyStylesheet(cur, doc, params); xmlFreeDoc(res); xmlFreeDoc(doc); +#if LIBXML_VERSION >= 20600 +#ifdef LIBXML_HTML_ENABLED + if (html) + doc = htmlReadFile(filename, NULL, options); + else +#endif + doc = xmlReadFile(filename, NULL, options); +#else #ifdef LIBXML_HTML_ENABLED if (html) doc = htmlParseFile(filename, NULL); else #endif doc = xmlParseFile(filename); +#endif } } ctxt = xsltNewTransformContext(cur, doc); @@ -539,7 +552,6 @@ main(int argc, char **argv) LIBXML_TEST_VERSION - xmlLineNumbersDefault(1); sec = xsltNewSecurityPrefs(); xsltSetDefaultSecurityPrefs(sec); defaultEntityLoader = xmlGetExternalEntityLoader(); @@ -723,16 +735,17 @@ main(int argc, char **argv) } params[nbparams] = NULL; +#if LIBXML_VERSION < 20600 + /* + * The old parser interfaces uses the global variables + */ if (novalid == 0) xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS; else xmlLoadExtDtdDefaultValue = 0; - - - /* - * Replace entities with their content. - */ xmlSubstituteEntitiesDefault(1); + xmlLineNumbersDefault(1); +#endif /* * Register the EXSLT extensions and the test module @@ -780,7 +793,11 @@ main(int argc, char **argv) if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0)) { if (timing) startTimer(); +#if LIBXML_VERSION >= 20600 + style = xmlReadFile((const char *) argv[i], NULL, options); +#else style = xmlParseFile((const char *) argv[i]); +#endif if (timing) endTimer("Parsing stylesheet %s", argv[i]); if (style == NULL) { @@ -814,23 +831,35 @@ main(int argc, char **argv) } } +#if LIBXML_VERSION < 20600 /* + * The old parser interfaces uses the global variables * disable CDATA from being built in the document tree */ xmlDefaultSAXHandlerInit(); xmlDefaultSAXHandler.cdataBlock = NULL; +#endif if ((cur != NULL) && (cur->errors == 0)) { for (; i < argc; i++) { doc = NULL; if (timing) startTimer(); +#if LIBXML_VERSION >= 20600 +#ifdef LIBXML_HTML_ENABLED + if (html) + doc = htmlReadFile(argv[i], NULL, options); + else +#endif + doc = xmlReadFile(argv[i], NULL, options); +#else #ifdef LIBXML_HTML_ENABLED if (html) doc = htmlParseFile(argv[i], NULL); else #endif doc = xmlParseFile(argv[i]); +#endif if (doc == NULL) { fprintf(stderr, "unable to parse %s\n", argv[i]); errorno = 6;