summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--configure.in1
-rw-r--r--libxslt/variables.c14
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/docs/Makefile.am1
-rw-r--r--tests/docs/bug-62.xml1
-rw-r--r--tests/general/Makefile.am2
-rw-r--r--tests/general/bug-62-inc.out0
-rw-r--r--tests/general/bug-62-inc.xsl4
-rw-r--r--tests/general/bug-62.out2
-rw-r--r--tests/general/bug-62.xsl8
-rw-r--r--tests/reports/Makefile.am32
-rw-r--r--tests/reports/tst-1.err2
-rw-r--r--tests/reports/tst-1.out2
-rw-r--r--tests/reports/tst-1.xml1
-rw-r--r--tests/reports/tst-1.xsl8
16 files changed, 87 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index dd67dde9..522b221d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Mon Sep 17 14:45:48 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+ * libxslt/variables.c: fixed a problem with global var override
+ being reported as an error.
+ * tests/docs/Makefile.am tests/docs/bug-61.xml
+ tests/general/Makefile.am tests/general/bug-61.*: added a
+ specific example in the regression tests
+ * configure.in tests/Makefile.am tests/reports/*: adding a test
+ to make sure redefinition of global variables in the same stylesheet
+ are still reported
+
Sat Sep 15 17:32:16 CEST 2001 Daniel Veillard <daniel@veillard.com>
* libxslt/extra.c: okay the code from Norm is really non
diff --git a/configure.in b/configure.in
index d65fcdc1..acb990d5 100644
--- a/configure.in
+++ b/configure.in
@@ -240,6 +240,7 @@ tests/REC1/Makefile
tests/REC2/Makefile
tests/REC/Makefile
tests/general/Makefile
+tests/reports/Makefile
tests/extensions/Makefile
tests/namespaces/Makefile
tests/numbers/Makefile
diff --git a/libxslt/variables.c b/libxslt/variables.c
index 6db477bb..64fadf6b 100644
--- a/libxslt/variables.c
+++ b/libxslt/variables.c
@@ -571,9 +571,17 @@ xsltEvalGlobalVariables(xsltTransformContextPtr ctxt) {
elem->name, elem->nameURI, def);
} else if ((elem->comp != NULL) &&
(elem->comp->type == XSLT_FUNC_VARIABLE)) {
- xsltPrintErrorContext(ctxt, style, elem->comp->inst);
- xsltGenericError(xsltGenericErrorContext,
- "Global variable %s already defined\n", elem->name);
+ /*
+ * Redefinition of variables from a different stylesheet
+ * should not generate a message.
+ */
+ if ((elem->comp->inst != NULL) &&
+ (def->comp != NULL) && (def->comp->inst != NULL) &&
+ (elem->comp->inst->doc == def->comp->inst->doc)) {
+ xsltPrintErrorContext(ctxt, style, elem->comp->inst);
+ xsltGenericError(xsltGenericErrorContext,
+ "Global variable %s already defined\n", elem->name);
+ }
}
elem = elem->next;
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f31e08ca..9c102d99 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,7 +1,7 @@
## Process this file with automake to produce Makefile.in
SUBDIRS=docs REC1 REC2 REC general namespaces numbers documents \
- extensions xmlspec multiple XSLTMark docbook exslt
+ extensions reports xmlspec multiple XSLTMark docbook exslt
all:
diff --git a/tests/docs/Makefile.am b/tests/docs/Makefile.am
index 045170ec..c8afbf75 100644
--- a/tests/docs/Makefile.am
+++ b/tests/docs/Makefile.am
@@ -63,6 +63,7 @@ EXTRA_DIST = \
bug-59.xml \
bug-60.xml \
bug-61.xml \
+ bug-62.xml \
character.xml \
array.xml \
items.xml
diff --git a/tests/docs/bug-62.xml b/tests/docs/bug-62.xml
new file mode 100644
index 00000000..69d62f2c
--- /dev/null
+++ b/tests/docs/bug-62.xml
@@ -0,0 +1 @@
+<doc/>
diff --git a/tests/general/Makefile.am b/tests/general/Makefile.am
index 58902be0..a971f446 100644
--- a/tests/general/Makefile.am
+++ b/tests/general/Makefile.am
@@ -65,6 +65,8 @@ EXTRA_DIST = \
bug-59.out bug-59.xsl \
bug-60.out bug-60.xsl \
bug-61.out bug-61.xsl \
+ bug-62-inc.out bug-62-inc.xsl \
+ bug-62.out bug-62.xsl \
character.out character.xsl \
character2.out character2.xsl \
itemschoose.out itemschoose.xsl \
diff --git a/tests/general/bug-62-inc.out b/tests/general/bug-62-inc.out
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/general/bug-62-inc.out
diff --git a/tests/general/bug-62-inc.xsl b/tests/general/bug-62-inc.xsl
new file mode 100644
index 00000000..c36ff6e3
--- /dev/null
+++ b/tests/general/bug-62-inc.xsl
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+ <xsl:variable name="my.var">old-value</xsl:variable>
+</xsl:stylesheet>
diff --git a/tests/general/bug-62.out b/tests/general/bug-62.out
new file mode 100644
index 00000000..c2f781e3
--- /dev/null
+++ b/tests/general/bug-62.out
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+the-value
diff --git a/tests/general/bug-62.xsl b/tests/general/bug-62.xsl
new file mode 100644
index 00000000..ccfca35d
--- /dev/null
+++ b/tests/general/bug-62.xsl
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+ <xsl:import href="bug-62-inc.xsl"/>
+ <xsl:variable name="my.var">the-value</xsl:variable>
+ <xsl:template match="/">
+ <xsl:value-of select="$my.var"/>
+ </xsl:template>
+</xsl:stylesheet>
diff --git a/tests/reports/Makefile.am b/tests/reports/Makefile.am
new file mode 100644
index 00000000..75a4f29b
--- /dev/null
+++ b/tests/reports/Makefile.am
@@ -0,0 +1,32 @@
+## Process this file with automake to produce Makefile.in
+
+$(top_builddir)/xsltproc/xsltproc:
+ @(cd ../../xsltproc ; $(MAKE) xsltproc)
+
+EXTRA_DIST = \
+ tst-1.xml tst-1.xsl tst-1.out tst-1.err
+
+
+all: test
+
+test tests: $(top_builddir)/xsltproc/xsltproc
+ @(echo > .memdump)
+ @(for i in $(srcdir)/*.xml ; do \
+ if [ -d $$i ] ; then continue ; fi ; \
+ doc=`basename $$i .xml` ; \
+ for j in $(srcdir)/$$doc*.xsl ; do \
+ if [ ! -f $$j ] ; then continue ; fi ; \
+ if [ -d $$j ] ; then continue ; fi ; \
+ name=`basename $$j .xsl`; \
+ out=$(srcdir)/"$$name".out; \
+ err=$(srcdir)/"$$name".err; \
+ echo Running $$j on $$i ; \
+ $(top_builddir)/xsltproc/xsltproc $$j $$i > result.$$name \
+ 2> err.$$name ; \
+ if [ ! -f $$out ] ; \
+ then cp result.$$name $$out; cp err.$$name $$err ; \
+ else diff $$out result.$$name; diff $$err err.$$name; fi ; \
+ grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" || true;\
+ rm -f result.$$name err.$$name ; \
+ done ; done)
+
diff --git a/tests/reports/tst-1.err b/tests/reports/tst-1.err
new file mode 100644
index 00000000..9815eb17
--- /dev/null
+++ b/tests/reports/tst-1.err
@@ -0,0 +1,2 @@
+runtime error: file ./tst-1.xsl line 4 element variable
+Global variable my.var already defined
diff --git a/tests/reports/tst-1.out b/tests/reports/tst-1.out
new file mode 100644
index 00000000..7e3e9b40
--- /dev/null
+++ b/tests/reports/tst-1.out
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+old-value
diff --git a/tests/reports/tst-1.xml b/tests/reports/tst-1.xml
new file mode 100644
index 00000000..69d62f2c
--- /dev/null
+++ b/tests/reports/tst-1.xml
@@ -0,0 +1 @@
+<doc/>
diff --git a/tests/reports/tst-1.xsl b/tests/reports/tst-1.xsl
new file mode 100644
index 00000000..4af7ca1e
--- /dev/null
+++ b/tests/reports/tst-1.xsl
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+ <xsl:variable name="my.var">old-value</xsl:variable>
+ <xsl:variable name="my.var">the-value</xsl:variable>
+ <xsl:template match="/">
+ <xsl:value-of select="$my.var"/>
+ </xsl:template>
+</xsl:stylesheet>