From 8d73a2306c27e346de99e78f9159c90f6a2335b3 Mon Sep 17 00:00:00 2001 From: Piers Haken Date: Sun, 23 Jun 2002 16:52:58 +0000 Subject: 2002-06-23 Piers Haken System.Xml: * XmlDocumentNavigator.cs: implement Clone() * XmlElement.cs: remove bogus unimplemented override of InnerText * XmlNode.cs: implment SelectNodes/SelectSingleNode * XmlNodeArrayList.cs: new support class for SelectNodes System.Xml.Xsl: * XsltContext.cs: added 'PreserveWhitespace' abstract method System.Xml.XPath: * XPathNavigator.cs: implement: - Compile - Evaluate - Clone - Select - ToString - some forwarding methods * XPathNodeIterator: implement caching Count * Tokenizer.cs: new XPath tokenizer * Parser.jay: new XPath grammar * Parser.cs: new precompiled XPath grammar * Expression.cs: new XPath expression objects * Iterator.cs: new XPath result/context objects * DefaultContext.cs: new XPath function binding context svn path=/trunk/mcs/; revision=5421 --- mcs/class/System.XML/System.Xml/ChangeLog | 7 +++++ .../System.XML/System.Xml/XmlDocumentNavigator.cs | 5 +-- mcs/class/System.XML/System.Xml/XmlElement.cs | 7 ----- mcs/class/System.XML/System.Xml/XmlNode.cs | 30 ++++++++++++++---- .../System.XML/System.Xml/XmlNodeArrayList.cs | 36 ++++++++++++++++++++++ 5 files changed, 70 insertions(+), 15 deletions(-) create mode 100644 mcs/class/System.XML/System.Xml/XmlNodeArrayList.cs (limited to 'mcs/class/System.XML/System.Xml') diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog index c4a90709c57..8e0760b7a9c 100644 --- a/mcs/class/System.XML/System.Xml/ChangeLog +++ b/mcs/class/System.XML/System.Xml/ChangeLog @@ -1,3 +1,10 @@ +2002-06-23 Piers Haken + + * XmlDocumentNavigator.cs: implement Clone() + * XmlElement.cs: remove bogus unimplemented override of InnerText + * XmlNode.cs: implment SelectNodes/SelectSingleNode + * XmlNodeArrayList.cs: new support class for SelectNodes + 2002-06-21 Ajay kumar Dwivedi * XmlQualifiedName: Name and Namespaces are never null. If null is passed diff --git a/mcs/class/System.XML/System.Xml/XmlDocumentNavigator.cs b/mcs/class/System.XML/System.Xml/XmlDocumentNavigator.cs index 3ee415ddc45..bdd44a165f6 100644 --- a/mcs/class/System.XML/System.Xml/XmlDocumentNavigator.cs +++ b/mcs/class/System.XML/System.Xml/XmlDocumentNavigator.cs @@ -168,10 +168,9 @@ namespace System.Xml #region Methods - [MonoTODO] public override XPathNavigator Clone () { - throw new NotImplementedException (); + return new XmlDocumentNavigator (node); } [MonoTODO] @@ -305,6 +304,8 @@ namespace System.Xml node = node.OwnerDocument; } + internal XmlNode Node { get { return node; } } + #endregion } } diff --git a/mcs/class/System.XML/System.Xml/XmlElement.cs b/mcs/class/System.XML/System.Xml/XmlElement.cs index c352c96a1a4..58726978473 100644 --- a/mcs/class/System.XML/System.Xml/XmlElement.cs +++ b/mcs/class/System.XML/System.Xml/XmlElement.cs @@ -50,13 +50,6 @@ namespace System.Xml get { return attributes.Count > 0; } } - [MonoTODO] - public override string InnerText { - get { throw new NotImplementedException (); } - - set { throw new NotImplementedException (); } - } - [MonoTODO ("Setter.")] public override string InnerXml { get { diff --git a/mcs/class/System.XML/System.Xml/XmlNode.cs b/mcs/class/System.XML/System.Xml/XmlNode.cs index c5dbad00267..ca9df1ee022 100644 --- a/mcs/class/System.XML/System.Xml/XmlNode.cs +++ b/mcs/class/System.XML/System.Xml/XmlNode.cs @@ -323,28 +323,46 @@ namespace System.Xml throw new NotImplementedException (); } - [MonoTODO] public XmlNodeList SelectNodes (string xpath) { - throw new NotImplementedException (); + return SelectNodes (xpath, null); } [MonoTODO] public XmlNodeList SelectNodes (string xpath, XmlNamespaceManager nsmgr) { - throw new NotImplementedException (); + XPathNavigator nav = CreateNavigator (); + XPathExpression expr = nav.Compile (xpath); + if (nsmgr != null) + expr.SetContext (nsmgr); + XPathNodeIterator iter = nav.Select (expr); + if (!iter.MoveNext ()) + return null; + ArrayList rgNodes = new ArrayList (); + do + { + rgNodes.Add (((XmlDocumentNavigator) iter.Current).Node); + } + while (iter.MoveNext ()); + return new XmlNodeArrayList (rgNodes); } - [MonoTODO] public XmlNode SelectSingleNode (string xpath) { - throw new NotImplementedException (); + return SelectSingleNode (xpath, null); } [MonoTODO] public XmlNode SelectSingleNode (string xpath, XmlNamespaceManager nsmgr) { - throw new NotImplementedException (); + XPathNavigator nav = CreateNavigator (); + XPathExpression expr = nav.Compile (xpath); + if (nsmgr != null) + expr.SetContext (nsmgr); + XPathNodeIterator iter = nav.Select (expr); + if (!iter.MoveNext ()) + return null; + return ((XmlDocumentNavigator) iter.Current).Node; } internal void SetParentNode (XmlNode parent) diff --git a/mcs/class/System.XML/System.Xml/XmlNodeArrayList.cs b/mcs/class/System.XML/System.Xml/XmlNodeArrayList.cs new file mode 100644 index 00000000000..a62fd77f401 --- /dev/null +++ b/mcs/class/System.XML/System.Xml/XmlNodeArrayList.cs @@ -0,0 +1,36 @@ +// +// System.Xml.XmlNodeArrayList +// +// Author: +// Piers Haken +// +// (C) 2002 Piers Haken +// + +using System; +using System.Collections; + +namespace System.Xml +{ + internal class XmlNodeArrayList : XmlNodeList + { + ArrayList _rgNodes; + + public XmlNodeArrayList (ArrayList rgNodes) + { + _rgNodes = rgNodes; + } + + public override int Count { get { return _rgNodes.Count; } } + + public override IEnumerator GetEnumerator () + { + return _rgNodes.GetEnumerator (); + } + + public override XmlNode Item (int index) + { + return (XmlNode) _rgNodes [index]; + } + } +} -- cgit v1.2.3