fixed 2 problems with xsl:include (bug #151795)
authorWilliam M. Brack <wbrack@src.gnome.org>
Mon, 6 Sep 2004 21:29:48 +0000 (21:29 +0000)
committerWilliam M. Brack <wbrack@src.gnome.org>
Mon, 6 Sep 2004 21:29:48 +0000 (21:29 +0000)
* libxslt/imports.c, libxslt/xslt.c, libxslt/xsltInternals.h:
  fixed 2 problems with xsl:include (bug #151795)

ChangeLog
libxslt/imports.c
libxslt/xslt.c
libxslt/xsltInternals.h

index 763b31e..c9bd062 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Sep  6 14:27:38 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/imports.c, libxslt/xslt.c, libxslt/xsltInternals.h:
+         fixed 2 problems with xsl:include (bug #151795)
+
 Tue Aug 31 15:45:42 CEST 2004 Daniel Veillard <daniel@veillard.com>
 
        * NEWS configure.in doc/*: Release of libxslt-1.1.10
index 21480fb..e1456ba 100644 (file)
@@ -189,6 +189,7 @@ xsltParseStylesheetInclude(xsltStylesheetPtr style, xmlNodePtr cur) {
     xsltStylesheetPtr result;
     xsltDocumentPtr include;
     xsltDocumentPtr docptr;
+    int oldNopreproc;
 
     if ((cur == NULL) || (style == NULL))
        return (ret);
@@ -234,7 +235,11 @@ xsltParseStylesheetInclude(xsltStylesheetPtr style, xmlNodePtr cur) {
     /* chain to stylesheet for recursion checking */
     include->includes = style->includes;
     style->includes = include;
+    oldNopreproc = style->nopreproc;
+    style->nopreproc = include->preproc;
     result = xsltParseStylesheetProcess(style, include->doc);
+    style->nopreproc = oldNopreproc;
+    include->preproc = 1;
     style->includes = include->includes;
     style->doc = oldDoc;
     if (result == NULL) {
index 6e7727a..e483da3 100644 (file)
@@ -1739,11 +1739,16 @@ xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) {
     prop = xsltGetNsProp(template, (const xmlChar *)"name", XSLT_NAMESPACE);
     if (prop != NULL) {
         const xmlChar *URI;
+       xsltTemplatePtr cur;
 
-       if (ret->name != NULL) xmlFree(ret->name);
-       ret->name = NULL;
-       if (ret->nameURI != NULL) xmlFree(ret->nameURI);
-       ret->nameURI = NULL;
+       if (ret->name != NULL) {
+           xmlFree(ret->name);
+           ret->name = NULL;
+       }
+       if (ret->nameURI != NULL) {
+           xmlFree(ret->nameURI);
+           ret->nameURI = NULL;
+       }
 
        URI = xsltGetQNameURI(template, &prop);
        if (prop == NULL) {
@@ -1761,6 +1766,16 @@ xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) {
                ret->nameURI = xmlStrdup(URI);
            else
                ret->nameURI = NULL;
+           cur = ret->next;
+           while (cur != NULL) {
+               if (xmlStrEqual(cur->name, prop)) {
+                   xsltTransformError(NULL, style, template,
+                       "xsl:template: error duplicate name '%s'\n", prop);
+                   style->errors++;
+                   goto error;
+               }
+               cur = cur->next;
+           }
        }
     }
 
@@ -1959,7 +1974,8 @@ xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc) {
        return(NULL);
     }
     xsltParseStylesheetExcludePrefix(ret, cur);
-    xsltPrecomputeStylesheet(ret, cur);
+    if (!ret->nopreproc)
+       xsltPrecomputeStylesheet(ret, cur);
 
     if ((IS_XSLT_ELEM(cur)) && 
        ((IS_XSLT_NAME(cur, "stylesheet")) ||
index 386405c..3629b9a 100644 (file)
@@ -144,6 +144,7 @@ struct _xsltDocument {
     xmlDocPtr doc;             /* the parsed document */
     void *keys;                        /* key tables storage */
     struct _xsltDocument *includes; /* subsidiary includes */
+    int preproc;               /* pre-processing already done */
 };
 
 typedef struct _xsltTransformContext xsltTransformContext;
@@ -435,6 +436,10 @@ struct _xsltStylesheet {
      * if namespace-alias has an alias for the default stylesheet prefix
      */
     const xmlChar *defaultAlias;
+    /*
+     * bypass pre-processing (already done) (used in imports)
+     */
+    int nopreproc;
 };
 
 /*