dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] pnetlib ./ChangeLog System.Xml/Private/Attribut...


From: Gopal.V
Subject: [dotgnu-pnet-commits] pnetlib ./ChangeLog System.Xml/Private/Attribut...
Date: Mon, 06 Mar 2006 12:28:10 +0000

CVSROOT:        /cvsroot/dotgnu-pnet
Module name:    pnetlib
Branch:         
Changes by:     Gopal.V <address@hidden>        06/03/06 12:28:10

Modified files:
        .              : ChangeLog 
        System.Xml/Private: Attributes.cs XmlDocumentNavigator.cs 
        System.Xml     : XmlDocument.cs XmlNamespaceManager.cs 
                         XmlNodeReader.cs XmlTextReader.cs 
                         XmlTextWriter.cs 
        System.Xml/XPath: XPathNavigator.cs 

Log message:
        xml namespace constants, namespaces for full document fragments,
        endelement fakes for xmlnodereader and namespace navigation in
        xmldocuments.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/ChangeLog.diff?tr1=1.2365&tr2=1.2366&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Xml/Private/Attributes.cs.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Xml/Private/XmlDocumentNavigator.cs.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Xml/XmlDocument.cs.diff?tr1=1.39&tr2=1.40&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Xml/XmlNamespaceManager.cs.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Xml/XmlNodeReader.cs.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Xml/XmlTextReader.cs.diff?tr1=1.60&tr2=1.61&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Xml/XmlTextWriter.cs.diff?tr1=1.32&tr2=1.33&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Xml/XPath/XPathNavigator.cs.diff?tr1=1.8&tr2=1.9&r1=text&r2=text

Patches:
Index: pnetlib/ChangeLog
diff -u pnetlib/ChangeLog:1.2365 pnetlib/ChangeLog:1.2366
--- pnetlib/ChangeLog:1.2365    Mon Mar  6 11:19:16 2006
+++ pnetlib/ChangeLog   Mon Mar  6 12:28:09 2006
@@ -1,6 +1,25 @@
-2006-02-22  Heiko Weiss <address@hidden>
 
-       * System.Windows.Forms/TextBoxBase.cs: Fixed changing selected text, 
setting caret pos and notify text changes
+2006-03-04  Gopal V  <address@hidden>
+
+       * System.Xml/XmlDocument.cs,
+       System.Xml/XmlNamespaceManager.cs,
+       System.Xml/XmlTextWriter.cs,
+       System.Xml/Private/Attributes.cs: add XmlDocument.xmlnsXml
+       and use the same everywhere.
+       
+       * System.Xml/Private/XmlDocumentNavigator.cs,
+       System.Xml/XPath/XPathNavigator.cs: Fix Namespace navigation.
+
+       * System.Xml/XmlNodeReader.cs: Fix Attribute count for the
+       fake EndElement node reads.
+       
+       * System.Xml/XmlTextReader.cs: Enable namespaces when reading
+       entire documents via the fragment codepath.
+
+2006-03-06  Heiko Weiss  <address@hidden>
+
+       * System.Windows.Forms/TextBoxBase.cs: Fixed changing selected text,
+       setting caret pos and notify text changes.
 
 2006-03-04  Gopal V  <address@hidden>
 
Index: pnetlib/System.Xml/Private/Attributes.cs
diff -u pnetlib/System.Xml/Private/Attributes.cs:1.6 
pnetlib/System.Xml/Private/Attributes.cs:1.7
--- pnetlib/System.Xml/Private/Attributes.cs:1.6        Tue May 25 07:56:24 2004
+++ pnetlib/System.Xml/Private/Attributes.cs    Mon Mar  6 12:28:09 2006
@@ -34,9 +34,6 @@
        private XmlNameTable nt;
        private XmlNamespaceManager nm;
 
-       private static readonly String xmlnsUri = 
"http://www.w3.org/2000/xmlns/";;
-
-
        // Constructor.
        public Attributes(ErrorHandler error)
                        : base(error)
@@ -201,7 +198,7 @@
                                        }
                                        else if(localName == "xmlns")
                                        {
-                                               namespaceURI = nt.Add(xmlnsUri);
+                                               namespaceURI = 
nt.Add(XmlDocument.xmlns);
                                        }
 
                                        // create the key
Index: pnetlib/System.Xml/Private/XmlDocumentNavigator.cs
diff -u pnetlib/System.Xml/Private/XmlDocumentNavigator.cs:1.9 
pnetlib/System.Xml/Private/XmlDocumentNavigator.cs:1.10
--- pnetlib/System.Xml/Private/XmlDocumentNavigator.cs:1.9      Sat Mar  4 
13:46:55 2006
+++ pnetlib/System.Xml/Private/XmlDocumentNavigator.cs  Mon Mar  6 12:28:09 2006
@@ -35,11 +35,17 @@
        private XmlAttribute nsAttr = null;
        private XmlDocument document;
 
+       /* xml:xmlns="http://www.w3.org/XML/1998/namespace"; */
+       private XmlAttribute xmlAttr = null;
+
        public XmlDocumentNavigator(XmlNode node) : base()
        {
                this.node = node;
                this.document = (node is XmlDocument) ? 
                                                        (XmlDocument)node : 
node.OwnerDocument;
+               this.xmlAttr = document.CreateAttribute("xmlns", "xml", 
+                                                                               
                XmlDocument.xmlns);
+               this.xmlAttr.Value = XmlDocument.xmlnsXml;
        }
 
        public XmlDocumentNavigator(XmlDocumentNavigator copy)
@@ -83,6 +89,7 @@
                        node = nav.node;
                        nsAttr = nav.nsAttr;
                        document = nav.document;
+                       xmlAttr = nav.xmlAttr;
                        return true;
                }
                return false;
@@ -160,7 +167,8 @@
                return false;
        }
 
-       public override bool MoveToFirstNamespace(XPathNamespaceScope 
namespaceScope)
+       public override bool MoveToFirstNamespace(
+                                                               
XPathNamespaceScope namespaceScope)
        {
                if(NodeType != XPathNodeType.Element)
                {
@@ -174,8 +182,9 @@
                        {
                                foreach(XmlAttribute attr in element.Attributes)
                                {
-                                       Console.WriteLine(attr.NamespaceURI);
-                                       if(attr.NamespaceURI == 
XmlDocument.xmlns)
+                                       /* TODO: checks for duplicates, not 
cheat */
+                                       if(attr.NamespaceURI == 
XmlDocument.xmlns 
+                                               && (attr.Name != "xmlns"))
                                        {
                                                NamespaceAttribute = attr;
                                                return true;
@@ -192,7 +201,12 @@
 
                if(namespaceScope == XPathNamespaceScope.All)
                {
-                       // TODO
+                       /* TODO: implement better duplicate checking */
+                       if(((Object)nsAttr) != ((Object)this.xmlAttr)) 
+                       {
+                               NamespaceAttribute = xmlAttr;
+                               return true;
+                       }
                }
                return false;
        }
@@ -204,6 +218,14 @@
 
        public override bool MoveToNamespace(String name)
        {
+               if(name == "xml")
+               {
+                       /* seems to be that xml namespaces are valid
+                          wherever you are ? */
+                       NamespaceAttribute = xmlAttr;
+                       return true;
+               }
+               
                if(NodeType != XPathNodeType.Element)
                {
                        return false;
@@ -216,7 +238,9 @@
                        {
                                foreach(XmlAttribute attr in element.Attributes)
                                {
-                                       if(attr.NamespaceURI == 
XmlDocument.xmlns)
+                                       /* TODO: checks for duplicates, not 
cheat */
+                                       if(attr.NamespaceURI == 
XmlDocument.xmlns
+                                               && (attr.Name != "xmlns"))
                                        {
                                                NamespaceAttribute = attr;
                                                return true;
@@ -294,6 +318,30 @@
                return false;
        }
 
+       private XmlAttribute GetNextNamespace(XmlElement owner, 
+                                                                               
        XmlAttribute current)
+       {
+               for(int i = 0; i < owner.Attributes.Count; i++)
+               {
+                       XmlAttribute attr = owner.Attributes[i];
+                       if(((Object)attr) == ((Object)current) || current == 
null)
+                       {
+                               for(int j = i+1; j < owner.Attributes.Count; 
j++)
+                               {
+                                       attr = owner.Attributes[j];
+                                       /* TODO: checks for duplicates, not 
cheat */
+                                       if(attr.NamespaceURI == 
XmlDocument.xmlns 
+                                               && (attr.Name != "xmlns"))
+                                       {
+                                               return attr;    
+                                       }
+                               }
+                       }
+               }
+
+               return null;
+       }
+
        public override bool MoveToNextNamespace(XPathNamespaceScope 
namespaceScope)
        {
                if(nsAttr == null)
@@ -303,35 +351,51 @@
                
                XmlElement owner = nsAttr.OwnerElement;
                
-               if(owner == null) 
+               if(owner == null || ((Object)nsAttr) == ((Object)this.xmlAttr)) 
                {
+                       /* technically, I don't think we need the extra 
condition
+                          because xmlAttr won't be attached to an element, but
+                          it's there because it makes it clear :) */
                        return false;
                }
 
-               for(int i = 0; i < owner.Attributes.Count; i++)
+               XmlAttribute nextNs = GetNextNamespace(owner, nsAttr);
+
+               if(nextNs != null)
                {
-                       XmlAttribute attr = owner.Attributes[i];
-                       if(attr == nsAttr)
-                       {
-                               for(int j = 0; j < owner.Attributes.Count; j++)
-                               {
-                                       if(owner.Attributes[j].NamespaceURI == 
-                                                       XmlDocument.xmlns)
-                                       {
-                                               NamespaceAttribute = 
owner.Attributes[j];       
-                                       }
-                               }
-                       }
+                       NamespaceAttribute = nextNs;
+                       return true;
                }
 
                if(namespaceScope == XPathNamespaceScope.Local)
                {
-                       // TODO: 
+                       return false;
+               }
+               
+               for(XmlNode node = owner.ParentNode;
+                               node != null; node = node.ParentNode)
+               {
+                       owner = (node as XmlElement);
+                       if(owner == null)
+                       {
+                               continue;
+                       }
+                       nextNs = GetNextNamespace(owner, null);
+                       if(nextNs != null)
+                       {
+                               NamespaceAttribute = nextNs;
+                               return true;
+                       }
                }
                
                if(namespaceScope == XPathNamespaceScope.All)
                {
-                       // TODO:
+                       /* TODO: implement better duplicate checking */
+                       if(((Object)nsAttr) != ((Object)this.xmlAttr)) 
+                       {
+                               NamespaceAttribute = xmlAttr;
+                               return true;
+                       }
                }
                return false;
        }
@@ -341,6 +405,10 @@
        {
                if(nsAttr != null)
                {
+                       /* the scary part is the MoveToNextNamespace
+                          function where you just traverse up. So
+                          there is no guarantee that parent node of
+                          nsAttr is the next node you want */
                        NamespaceAttribute = null;
                        return true;
                }
Index: pnetlib/System.Xml/XPath/XPathNavigator.cs
diff -u pnetlib/System.Xml/XPath/XPathNavigator.cs:1.8 
pnetlib/System.Xml/XPath/XPathNavigator.cs:1.9
--- pnetlib/System.Xml/XPath/XPathNavigator.cs:1.8      Sat Mar  4 13:46:55 2006
+++ pnetlib/System.Xml/XPath/XPathNavigator.cs  Mon Mar  6 12:28:09 2006
@@ -138,7 +138,7 @@
 
        public bool MoveToNextNamespace()
                        {
-                               return 
MoveToFirstNamespace(XPathNamespaceScope.All);
+                               return 
MoveToNextNamespace(XPathNamespaceScope.All);
                        }
 
        public abstract bool MoveToNextNamespace(XPathNamespaceScope 
namespaceScope);
Index: pnetlib/System.Xml/XmlDocument.cs
diff -u pnetlib/System.Xml/XmlDocument.cs:1.39 
pnetlib/System.Xml/XmlDocument.cs:1.40
--- pnetlib/System.Xml/XmlDocument.cs:1.39      Mon Feb 27 06:56:43 2006
+++ pnetlib/System.Xml/XmlDocument.cs   Mon Mar  6 12:28:09 2006
@@ -43,6 +43,8 @@
        internal XmlDocumentFragment placeholder;
        internal XmlImplementation implementation;
        internal static readonly String xmlns = "http://www.w3.org/2000/xmlns/";;
+       /* is it me or did they a miss a trailing '/' here ? */
+       internal static readonly String xmlnsXml = 
"http://www.w3.org/XML/1998/namespace";;
 
        // Constructors.
        public XmlDocument() : base(null)
Index: pnetlib/System.Xml/XmlNamespaceManager.cs
diff -u pnetlib/System.Xml/XmlNamespaceManager.cs:1.6 
pnetlib/System.Xml/XmlNamespaceManager.cs:1.7
--- pnetlib/System.Xml/XmlNamespaceManager.cs:1.6       Thu May  6 06:40:14 2004
+++ pnetlib/System.Xml/XmlNamespaceManager.cs   Mon Mar  6 12:28:09 2006
@@ -56,11 +56,11 @@
                                xmlNsCompareQuick = nameTable.Add("xmlns");
                                namespaces = new NamespaceInfo
                                        (xmlCompareQuick,
-                                        
nameTable.Add("http://www.w3.org/XML/1998/namespace";),
+                                        nameTable.Add(XmlDocument.xmlnsXml),
                                         null);
                                namespaces = new NamespaceInfo
                                        (xmlNsCompareQuick,
-                                        
nameTable.Add("http://www.w3.org/2000/xmlns/";),
+                                        nameTable.Add(XmlDocument.xmlns),
                                         namespaces);
 
                                // Mark the position of the outermost scope 
level.
Index: pnetlib/System.Xml/XmlNodeReader.cs
diff -u pnetlib/System.Xml/XmlNodeReader.cs:1.2 
pnetlib/System.Xml/XmlNodeReader.cs:1.3
--- pnetlib/System.Xml/XmlNodeReader.cs:1.2     Mon Feb 27 06:56:43 2006
+++ pnetlib/System.Xml/XmlNodeReader.cs Mon Mar  6 12:28:09 2006
@@ -502,8 +502,6 @@
 
                bool eof = false;
 
-               Console.WriteLine(this.currentNode.Name);
-
                if (IsEmptyElement || this.isEndElement)
                {
                        this.isEndElement = false;
@@ -670,6 +668,10 @@
                        {
                                case XmlNodeType.Element:
                                {
+                                       if(this.isEndElement)
+                                       {
+                                               return 0;
+                                       }
                                        return 
((XmlElement)this.currentNode).Attributes.Count;
                                }
                                break;
Index: pnetlib/System.Xml/XmlTextReader.cs
diff -u pnetlib/System.Xml/XmlTextReader.cs:1.60 
pnetlib/System.Xml/XmlTextReader.cs:1.61
--- pnetlib/System.Xml/XmlTextReader.cs:1.60    Tue Nov 23 15:15:22 2004
+++ pnetlib/System.Xml/XmlTextReader.cs Mon Mar  6 12:28:09 2006
@@ -234,7 +234,7 @@
                                        }
                                        input.Reader = sr;
                                }
-                               namespaces = false;
+                               namespaces = (fragType == XmlNodeType.Document);
                        }
        public XmlTextReader(String xmlFragment, XmlNodeType fragType,
                                                 XmlParserContext context)
@@ -285,7 +285,7 @@
                                        }
                                        input.Reader = sr.TxtReader;
                                }
-                               namespaces = false;
+                               namespaces = (fragType == XmlNodeType.Document);
                        }
        public XmlTextReader(String url)
                        : this(url, new NameTable())
Index: pnetlib/System.Xml/XmlTextWriter.cs
diff -u pnetlib/System.Xml/XmlTextWriter.cs:1.32 
pnetlib/System.Xml/XmlTextWriter.cs:1.33
--- pnetlib/System.Xml/XmlTextWriter.cs:1.32    Wed Nov  9 12:31:30 2005
+++ pnetlib/System.Xml/XmlTextWriter.cs Mon Mar  6 12:28:09 2006
@@ -1353,7 +1353,7 @@
                                                // Ensure the namespace is 
correct.
                                                if(nsLen != 0 &&
                                                   (nsLen != 29 ||
-                                                   ns != 
"http://www.w3.org/2000/xmlns/";))
+                                                   ns != XmlDocument.xmlns))
                                                {
                                                        throw new 
ArgumentException(/* TODO */);
                                                }
@@ -1380,7 +1380,7 @@
                                                // Ensure the namespace is 
correct.
                                                if(nsLen != 0 &&
                                                   (nsLen != 36 ||
-                                                   ns != 
"http://www.w3.org/XML/1998/namespace";))
+                                                   ns != XmlDocument.xmlnsXml))
                                                {
                                                        throw new 
ArgumentException(/* TODO */);
                                                }
@@ -1452,7 +1452,7 @@
                                           (localName.Length == 5 && localName 
== "xmlns"))
                                        {
                                                // Ensure the namespace is 
correct.
-                                               if(nsLen != 29 || ns != 
"http://www.w3.org/2000/xmlns/";)
+                                               if(nsLen != 29 || ns != 
XmlDocument.xmlns)
                                                {
                                                        throw new 
ArgumentException(/* TODO */);
                                                }
@@ -1464,12 +1464,12 @@
                                                return;
                                        }
                                        else if(nsLen == 29 &&
-                                               ns == 
"http://www.w3.org/2000/xmlns/";)
+                                               ns == XmlDocument.xmlns)
                                        {
                                                throw new ArgumentException(/* 
TODO */);
                                        }
                                        else if(nsLen == 36 &&
-                                               ns == 
"http://www.w3.org/XML/1998/namespace";)
+                                               ns == XmlDocument.xmlnsXml)
                                        {
                                                throw new ArgumentException(/* 
TODO */);
                                        }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]