2005-08-05 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Fri, 5 Aug 2005 06:05:27 +0000 (06:05 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Fri, 5 Aug 2005 06:05:27 +0000 (06:05 -0000)
* Pattern.cs, IdPattern.cs, LocationPathPattern.cs, UnionPattern.cs :
  added bool EvaluatedNodeType property (used in XslKeyTable).

* XslKey.cs : Fixed match pattern in xsl:key to check attribute nodes.
  To minimize attribute iteration, use Pattern.EvaluatedNodeType.
  Fixed bug #75709.

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

mcs/class/System.XML/Mono.Xml.XPath/ChangeLog
mcs/class/System.XML/Mono.Xml.XPath/IdPattern.cs
mcs/class/System.XML/Mono.Xml.XPath/LocationPathPattern.cs
mcs/class/System.XML/Mono.Xml.XPath/Pattern.cs
mcs/class/System.XML/Mono.Xml.XPath/UnionPattern.cs
mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
mcs/class/System.XML/Mono.Xml.Xsl/XslKey.cs

index cf99b3def624fe1aad5a15181b0a787569ec9817..8b2787a0b6ad2d9818372f29f2aa390d26c8a72b 100644 (file)
@@ -1,3 +1,8 @@
+2005-08-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Pattern.cs, IdPattern.cs, LocationPathPattern.cs, UnionPattern.cs :
+         added bool EvaluatedNodeType property (used in XslKeyTable).
+
 2005-05-05  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XPathEditableDocument.cs : sync with updated 2.0 API.
index 7be75056a9573f427e3ea9c3ec032081369763c1..b4d6f4b5bb49d2e4c6dc4e27314c2aafaa89910f 100644 (file)
@@ -47,7 +47,11 @@ namespace Mono.Xml.XPath {
                {
                        ids = arg0.Split (XmlChar.WhitespaceChars);
                }
-               
+
+               public override XPathNodeType EvaluatedNodeType {
+                       get { return XPathNodeType.Element; }
+               }
+
                public override bool Matches (XPathNavigator node, XsltContext ctx)
                {
                        XPathNavigator tmp = ((XsltCompiledContext) ctx).GetNavCache (this, node);
index 8a6133a708b5f7c3ae04110e0001a7160af13782..97ddddad8e57c7e75a3b2cfa089dbfce57d0637b 100644 (file)
@@ -82,6 +82,10 @@ namespace Mono.Xml.XPath {
                                return .5;
                        }
                }
+
+               public override XPathNodeType EvaluatedNodeType {
+                       get { return nodeTest.EvaluatedNodeType; }
+               }
                
                public override bool Matches (XPathNavigator node, XsltContext ctx)
                {
index b258e4f36121860b0932264b210814bcbe6bc51c..1c8d474c604bf14a1c5b4161f9bfcbb77752a43b 100644 (file)
@@ -107,7 +107,11 @@ namespace Mono.Xml.XPath
                }
                
                public virtual double DefaultPriority { get { return 0.5; }}
-               
+
+               public virtual XPathNodeType EvaluatedNodeType {
+                       get { return XPathNodeType.All; }
+               }
+
                public abstract bool Matches (XPathNavigator node, XsltContext ctx);
        }
 }
\ No newline at end of file
index b22ba21a7ae85daaa04ac76378d8af5c1c8d3a92..c9cf0d3c33abd3ab02cc506da8437a9eda4dcbf2 100644 (file)
@@ -46,6 +46,13 @@ namespace Mono.Xml.XPath {
                        this.p0 = p0;
                        this.p1 = p1;
                }
+
+               public override XPathNodeType EvaluatedNodeType {
+                       get {
+                               return p0.EvaluatedNodeType == p1.EvaluatedNodeType ?
+                                       p0.EvaluatedNodeType : XPathNodeType.All;
+                       }
+               }
                
                public override bool Matches (XPathNavigator node, XsltContext ctx)
                {
index 876d002c67a15e37a5b7c6cc90b6760237b85bc1..b8ce61c38f5992c7a514bf9974c9ba1c7bfdadcb 100644 (file)
@@ -1,3 +1,9 @@
+2005-08-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XslKey.cs : Fixed match pattern in xsl:key to check attribute nodes.
+         To minimize attribute iteration, use Pattern.EvaluatedNodeType.
+         Fixed bug #75709.
+
 2005-07-29  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XslFunctions.cs : XslTransform recovers from errors on document
index 5c88baa8bb20c3fe5141587c7dc65e4287d3f966..521ec67140c28b452f3b7929fc4385995f4cc8ce 100644 (file)
@@ -119,19 +119,37 @@ namespace Mono.Xml.Xsl
                        nav.MoveToRoot ();
                        XPathNavigator tmp = doc.Clone ();
 
+                       bool matchesAttributes = false;
+                       switch (key.Match.EvaluatedNodeType) {
+                       case XPathNodeType.All:
+                       case XPathNodeType.Attribute:
+                               matchesAttributes = true;
+                               break;
+                       }
+
                        do {
                                if (key.Match.Matches (nav, ctx)) {
                                        tmp.MoveTo (nav);
                                        CollectIndex (nav, tmp);
                                }
-                       } while (MoveNavigatorToNext (nav));
+                       } while (MoveNavigatorToNext (nav, matchesAttributes));
                        if (map != null)
                                foreach (ArrayList list in map.Values)
                                        list.Sort (XPathNavigatorComparer.Instance);
                }
 
-               private bool MoveNavigatorToNext (XPathNavigator nav)
+               private bool MoveNavigatorToNext (XPathNavigator nav, bool matchesAttributes)
                {
+                       if (matchesAttributes) {
+                               if (nav.NodeType != XPathNodeType.Attribute &&
+                                       nav.MoveToFirstAttribute ())
+                                       return true;
+                               else if (nav.NodeType == XPathNodeType.Attribute) {
+                                       if (nav.MoveToNextAttribute ())
+                                               return true;
+                                       nav.MoveToParent ();
+                               }
+                       }
                        if (nav.MoveToFirstChild ())
                                return true;
                        do {