2007-01-09 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Tue, 9 Jan 2007 16:24:35 +0000 (16:24 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Tue, 9 Jan 2007 16:24:35 +0000 (16:24 -0000)
* XslKey.cs : keep keytables per instance document and do not share
  them among all.

svn path=/trunk/mcs/; revision=70725

mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
mcs/class/System.XML/Mono.Xml.Xsl/XslKey.cs

index fd0a2ce4d161f5762c62eb78a433629886b69eb9..d0bba12cc8c48884bb047864c1eae01b387616b0 100644 (file)
@@ -1,3 +1,8 @@
+2007-01-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XslKey.cs : keep keytables per instance document and do not share
+         them among all.
+
 2006-11-30  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XslStylesheet.cs, XslTemplate.cs : added XSLT stack frame debug
index 1e97bf03ee58b0e77a9c543edc748045ba52f518..101bcaffea2318daf3e4ae6d0cefba6434cc0bb3 100644 (file)
@@ -100,7 +100,6 @@ namespace Mono.Xml.Xsl
        {
                XsltCompiledContext ctx;
                XslKey key;
-               Hashtable map;
                Hashtable mappedDocuments;
 
                public KeyIndexTable (XsltCompiledContext ctx, XslKey key)
@@ -113,7 +112,7 @@ namespace Mono.Xml.Xsl
                        get { return key; }
                }
 
-               private void CollectTable (XPathNavigator doc, XsltContext ctx)
+               private void CollectTable (XPathNavigator doc, XsltContext ctx, Hashtable map)
                {
                        XPathNavigator nav = doc.Clone ();
                        nav.MoveToRoot ();
@@ -130,7 +129,7 @@ namespace Mono.Xml.Xsl
                        do {
                                if (key.Match.Matches (nav, ctx)) {
                                        tmp.MoveTo (nav);
-                                       CollectIndex (nav, tmp);
+                                       CollectIndex (nav, tmp, map);
                                }
                        } while (MoveNavigatorToNext (nav, matchesAttributes));
                        if (map != null)
@@ -159,33 +158,33 @@ namespace Mono.Xml.Xsl
                        return false;
                }
 
-               private void CollectIndex (XPathNavigator nav, XPathNavigator target)
+               private void CollectIndex (XPathNavigator nav, XPathNavigator target, Hashtable map)
                {
                        XPathNodeIterator iter;
                        switch (key.Use.ReturnType) {
                        case XPathResultType.NodeSet:
                                iter = nav.Select (key.Use);
                                while (iter.MoveNext ())
-                                       AddIndex (iter.Current.Value, target);
+                                       AddIndex (iter.Current.Value, target, map);
                                break;
                        case XPathResultType.Any:
                                object o = nav.Evaluate (key.Use);
                                iter = o as XPathNodeIterator;
                                if (iter != null) {
                                        while (iter.MoveNext ())
-                                               AddIndex (iter.Current.Value, target);
+                                               AddIndex (iter.Current.Value, target, map);
                                }
                                else
-                                       AddIndex (XPathFunctions.ToString (o), target);
+                                       AddIndex (XPathFunctions.ToString (o), target, map);
                                break;
                        default:
                                string keyValue = nav.EvaluateString (key.Use, null, null);
-                               AddIndex (keyValue, target);
+                               AddIndex (keyValue, target, map);
                                break;
                        }
                }
 
-               private void AddIndex (string key, XPathNavigator target)
+               private void AddIndex (string key, XPathNavigator target, Hashtable map)
                {
                        ArrayList al = map [key] as ArrayList;
                        if (al == null) {
@@ -200,13 +199,13 @@ namespace Mono.Xml.Xsl
 
                private ArrayList GetNodesByValue (XPathNavigator nav, string value, XsltContext ctx)
                {
-                       if (map == null) {
+                       if (mappedDocuments == null)
                                mappedDocuments = new Hashtable ();
+                       Hashtable map = (Hashtable) mappedDocuments [nav.BaseURI];
+                       if (map == null) {
                                map = new Hashtable ();
-                       }
-                       if (!mappedDocuments.ContainsKey (nav.BaseURI)) {
-                               mappedDocuments.Add (nav.BaseURI, nav.BaseURI);
-                               CollectTable (nav, ctx);
+                               mappedDocuments.Add (nav.BaseURI, map);
+                               CollectTable (nav, ctx, map);
                        }
                        
                        return map [value] as ArrayList;