[XML-SIG] 4xslt: bug and patch: variable import order

Dieter Maurer dieter@handshake.de
Tue, 8 May 2001 23:21:06 +0200 (CEST)

Content-Type: text/plain; charset=US-ASCII

The XSLT spec specifies that definitions and template rules
in an importing stylesheet take precedence over those from
an imported stylesheet. This is essential for easy customization
of imported stylesheets.

"4xslt" implements this feature only partially:

   Top level variables in an importing stylesheet do not
   take precedence over imported ones.

The attached patch hopefully fixes the problem.
It ensures that variables in importing style sheets
take precedence over those defined in imported style sheets
and that all style sheets use the same top level variables.


Content-Type: application/octet-stream
Content-Disposition: attachment; filename="var_import_order.pat"
Content-Transfer-Encoding: 7bit

--- :Stylesheet.py	Thu May  3 01:29:05 2001
+++ Stylesheet.py	Tue May  8 23:19:29 2001
@@ -398,8 +398,16 @@
         self._primedContext = context
         #Note: key expressions can't have var refs, so we needn't worry about imports
         self._updateKeys(contextNode, processor)
+        # DM: imported variables have lower precedence than that from
+        #     the main style sheet.
+        d= {}
         for imp in self._imports:
-            self._primedContext.varBindings.update(imp.stylesheet._primedContext.varBindings)
+            d.update(imp.stylesheet._primedContext.varBindings)
+        d.update(self._primedContext.varBindings)
+        self._primedContext.varBindings= d
+        # DM: all use the same set of top level variables
+        for imp in self._imports:
+            imp.stylesheet._primedContext.varBindings= d
         return topLevelParams