2006-02-11 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Sat, 11 Feb 2006 19:21:23 +0000 (19:21 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Sat, 11 Feb 2006 19:21:23 +0000 (19:21 -0000)
* Makefile : now we can depend on Alejandro's System.Query.dll.

* XElementSequence.cs : implemented (not sure if it works).
* XName.cs : strict null comparison.
* XIterators.cs : (XFilterIterator) check attribute XName as well.
* System.Xml.XLinq.cs : solved FIXMEs.

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

mcs/class/System.Xml.XLinq/ChangeLog
mcs/class/System.Xml.XLinq/Makefile
mcs/class/System.Xml.XLinq/System.Xml.XLinq/ChangeLog
mcs/class/System.Xml.XLinq/System.Xml.XLinq/System.Xml.XLinq.cs
mcs/class/System.Xml.XLinq/System.Xml.XLinq/XElementSequence.cs
mcs/class/System.Xml.XLinq/System.Xml.XLinq/XIterators.cs
mcs/class/System.Xml.XLinq/System.Xml.XLinq/XName.cs

index bc4e0dd2f339be0d77f4b79ccbaca83c353c7f14..86b16b4aab1839a0d41c125842735b3b16a06402 100644 (file)
@@ -1,3 +1,7 @@
+2006-02-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Makefile : now we can depend on Alejandro's System.Query.dll.
+
 2005-09-20  Atsushi Enomoto  <atsushi@ximian.com>
 
        * Makefile,
index 82a7d3df8554c57342ef5658f628b89cd2fee028..ef551ae23fe7428594ddeb36ae30dab8a87821f2 100644 (file)
@@ -5,6 +5,7 @@ include ../../build/rules.make
 LIBRARY = System.Xml.XLinq.dll
 LIB_MCS_FLAGS = \
                /r:System.dll \
+               /r:System.Query.dll \
                /r:System.Xml.dll \
                /d:LIST_BASED
 
@@ -12,4 +13,13 @@ TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)
 
 EXTRA_DISTFILES =
 
+# This is a .NET 2.0 only assembly
+VALID_PROFILE := $(filter net_2_0_bootstrap net_2_0, $(PROFILE))
+ifndef VALID_PROFILE
+LIBRARY_NAME = dummy-System.Xml.XLinq.dll
+NO_INSTALL = yes
+NO_SIGN_ASSEMBLY = yes
+NO_TEST = yes
+endif
+
 include ../../build/library.make
index 2c2f0c0e2389e7bdb4197d16ec7585a1e74983ad..6fcc5ee7c6b62d882b59590e531afd6291f6fd4d 100644 (file)
@@ -1,3 +1,10 @@
+2006-02-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XElementSequence.cs : implemented (not sure if it works).
+       * XName.cs : strict null comparison.
+       * XIterators.cs : (XFilterIterator) check attribute XName as well.
+       * System.Xml.XLinq.cs : solved FIXMEs.
+
 2005-09-20  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XAttribute.cs, XIterators.cs, XName.cs, XElementSequence.cs,
index 914c4c5b2fd8b6ca3adbf3fbfb0b4b2b6fd84c62..ba67c8097124fb8eff881ea3411a3fdaaa624b3d 100644 (file)
@@ -607,8 +607,7 @@ namespace System.Xml.XLinq
                public static XDocument Load (string uri, bool preserveWhitespaces)
                {
                        XmlReaderSettings s = new XmlReaderSettings ();
-                       // FIXME: finish System.Xml 2.0
-//                     s.IgnoreWhitespaces = !preserveWhitespaces;
+                       s.IgnoreWhitespace = !preserveWhitespaces;
                        using (XmlReader r = XmlReader.Create (uri, s)) {
                                return Load (r);
                        }
@@ -622,10 +621,8 @@ namespace System.Xml.XLinq
                public static XDocument Load (TextReader reader, bool preserveWhitespaces)
                {
                        XmlReaderSettings s = new XmlReaderSettings ();
-                       // FIXME: finish System.Xml 2.0
-//                     s.IgnoreWhitespaces = !preserveWhitespaces;
-//                     using (XmlReader r = XmlReader.Create (reader, s)) {
-                       using (XmlReader r = XmlReader.Create (reader)) {
+                       s.IgnoreWhitespace = !preserveWhitespaces;
+                       using (XmlReader r = XmlReader.Create (reader, s)) {
                                return Load (r);
                        }
                }
@@ -888,8 +885,7 @@ namespace System.Xml.XLinq
                public static XElement Load (string uri, bool preserveWhitespaces)
                {
                        XmlReaderSettings s = new XmlReaderSettings ();
-                       // FIXME: finish System.Xml 2.0
-//                     s.IgnoreWhitespaces = !preserveWhitespaces;
+                       s.IgnoreWhitespace = !preserveWhitespaces;
                        using (XmlReader r = XmlReader.Create (uri, s)) {
                                return Load (r);
                        }
@@ -903,10 +899,8 @@ namespace System.Xml.XLinq
                public static XElement Load (TextReader tr, bool preserveWhitespaces)
                {
                        XmlReaderSettings s = new XmlReaderSettings ();
-                       // FIXME: finish System.Xml 2.0
-//                     s.IgnoreWhitespaces = !preserveWhitespaces;
-//                     using (XmlReader r = XmlReader.Create (tr, s)) {
-                       using (XmlReader r = XmlReader.Create (tr)) {
+                       s.IgnoreWhitespace = !preserveWhitespaces;
+                       using (XmlReader r = XmlReader.Create (tr, s)) {
                                return Load (r);
                        }
                }
index a8f52dd116ba96b9d189b8b7474ebd739529547f..2861bb1ece7fafbe0a47cbb7c31e7a12674eb8e3 100644 (file)
@@ -3,34 +3,43 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
+using System.Runtime.CompilerServices;
 
 namespace System.Xml.XLinq
 {
-       // [ExtensionAttribute]
+       [ExtensionAttribute]
        public static class XElementSequence
        {
-               // [ExtensionAttribute]
+               [ExtensionAttribute]
                public static IEnumerable <XElement> Ancestors (IEnumerable <XElement> source)
                {
-                       throw new NotImplementedException ();
+                       foreach (XElement item in source)
+                               foreach (XElement elem in item.Ancestors ())
+                                       yield return elem;
                }
 
-               // [ExtensionAttribute]
+               [ExtensionAttribute]
                public static IEnumerable <XElement> Ancestors (IEnumerable <XElement> source, XName name)
                {
-                       throw new NotImplementedException ();
+                       foreach (XElement item in source)
+                               foreach (XElement elem in item.Ancestors (name))
+                                       yield return elem;
                }
 
-               // [ExtensionAttribute]
-               public static IEnumerable <XAttribute> Attributes (IEnumerable <XAttribute> source)
+               [ExtensionAttribute]
+               public static IEnumerable <XAttribute> Attributes (IEnumerable <XElement> source)
                {
-                       throw new NotImplementedException ();
+                       foreach (XElement item in source)
+                               foreach (XAttribute attr in item.Attributes ())
+                                       yield return attr;
                }
 
-               // [ExtensionAttribute]
-               public static IEnumerable <XAttribute> Attributes (IEnumerable <XAttribute> source, XName name)
+               [ExtensionAttribute]
+               public static IEnumerable <XAttribute> Attributes (IEnumerable <XElement> source, XName name)
                {
-                       throw new NotImplementedException ();
+                       foreach (XElement item in source)
+                               foreach (XAttribute attr in item.Attributes (name))
+                                       yield return attr;
                }
        }
 }
index 5379f4ea2cd92512c7010cffe5bd55e26f39d0c8..3e9762ccb1bbbd6a8007574f350fdab453237aca 100644 (file)
@@ -29,9 +29,17 @@ namespace System.Xml.XLinq
                        foreach (object o in source) {
                                if (! (o is T))
                                        continue;
-                               if (name != null && (! (o is XElement) || ((XElement) o).Name != name))
-                                       continue;
-                               yield return o as T;
+                               if (name != null) {
+                                       if (o is XElement) {
+                                               if (((XElement) o).Name != name)
+                                                       continue;
+                                       }
+                                       else if (o is XAttribute) {
+                                               if (((XAttribute) o).Name != name)
+                                                       continue;
+                                       }
+                               }
+                               yield return (T) o;
                        }
                }
 
index 5f8d8ec1ba255883091a05b3606f0e824587ea2e..6ca08373f0eaf5aaf65b5e9371e1010ef557d14c 100644 (file)
@@ -89,14 +89,17 @@ namespace System.Xml.XLinq
 
                public static bool operator == (XName n1, XName n2)
                {
-                       return (object) n1 == null && (object) n2 == null ||
-                               object.ReferenceEquals (n1, n2) ||
+                       if ((object) n1 == null)
+                               return (object) n2 == null;
+                       else if ((object) n2 == null)
+                               return false;
+                       return object.ReferenceEquals (n1, n2) ||
                                n1.local == n2.local && n1.ns == n2.ns;
                }
 
                public static implicit operator XName (string s)
                {
-                       return Get (s);
+                       return s == null ? null : Get (s);
                }
 
                public static bool operator != (XName n1, XName n2)