diff options
5 files changed, 84 insertions, 108 deletions
diff --git a/mcs/class/System.XML/System.Xml.XPath/ChangeLog b/mcs/class/System.XML/System.Xml.XPath/ChangeLog index cc6687cd08e..be89aecdfb1 100644 --- a/mcs/class/System.XML/System.Xml.XPath/ChangeLog +++ b/mcs/class/System.XML/System.Xml.XPath/ChangeLog @@ -1,3 +1,12 @@ +2004-07-11 Atsushi Enomoto <atsushi@ximian.com> + + * Expression.cs, Iterator.cs, XPathNavigator.cs : + Use IXmlNamespaceResolver for net 2.0. Removed unused code. + * XPathEditableNavigator.cs : fixed namespace. + * XPathNavigator.cs : + Fixed inheritance. Added missing MonoTODO. + Removed old .net 1.2 code. + 2004-06-18 Atsushi Enomoto <atsushi@ximian.com> * DefaultContext.cs : Globalization. diff --git a/mcs/class/System.XML/System.Xml.XPath/Expression.cs b/mcs/class/System.XML/System.Xml.XPath/Expression.cs index 802a8c3006b..25ba965b994 100644 --- a/mcs/class/System.XML/System.Xml.XPath/Expression.cs +++ b/mcs/class/System.XML/System.Xml.XPath/Expression.cs @@ -36,6 +36,12 @@ using System.Xml.Xsl; using System.Globalization; using Mono.Xml.XPath; +#if NET_2_0 +using NSResolver = System.Xml.IXmlNamespaceResolver; +#else +using NSResolver = System.Xml.XmlNamespaceManager; +#endif + namespace System.Xml.XPath { #if XPATH_DEBUG @@ -44,7 +50,7 @@ namespace System.Xml.XPath internal class CompiledExpression : XPathExpression #endif { - protected XmlNamespaceManager _nsm; + protected NSResolver _nsm; protected Expression _expr; XPathSorters _sorters; @@ -69,7 +75,7 @@ namespace System.Xml.XPath { _nsm = nsManager; } - internal XmlNamespaceManager NamespaceManager { get { return _nsm; } } + internal NSResolver NamespaceManager { get { return _nsm; } } public override String Expression { get { return _expr.ToString (); }} public override XPathResultType ReturnType { get { return _expr.ReturnType; }} @@ -1141,7 +1147,7 @@ namespace System.Xml.XPath { _axis = new AxisSpecifier (axis); } - public abstract bool Match (XmlNamespaceManager nsm, XPathNavigator nav); + public abstract bool Match (NSResolver nsm, XPathNavigator nav); public AxisSpecifier Axis { get { return _axis; }} public override object Evaluate (BaseIterator iter) { @@ -1149,7 +1155,7 @@ namespace System.Xml.XPath return new AxisIterator (iterAxis, this); } - public abstract void GetInfo (out string name, out string ns, out XPathNodeType nodetype, XmlNamespaceManager nsm); + public abstract void GetInfo (out string name, out string ns, out XPathNodeType nodetype, NSResolver nsm); public override bool RequireSorting { get { @@ -1224,7 +1230,7 @@ namespace System.Xml.XPath } } - public override bool Match (XmlNamespaceManager nsm, XPathNavigator nav) + public override bool Match (NSResolver nsm, XPathNavigator nav) { XPathNodeType nodeType = nav.NodeType; switch (type) @@ -1244,7 +1250,7 @@ namespace System.Xml.XPath } } - public override void GetInfo (out string name, out string ns, out XPathNodeType nodetype, XmlNamespaceManager nsm) + public override void GetInfo (out string name, out string ns, out XPathNodeType nodetype, NSResolver nsm) { name = _param; ns = null; @@ -1274,7 +1280,7 @@ namespace System.Xml.XPath public XmlQualifiedName Name { get { return _name; } } - public override bool Match (XmlNamespaceManager nsm, XPathNavigator nav) + public override bool Match (NSResolver nsm, XPathNavigator nav) { // must be the correct node type if (nav.NodeType != _axis.NodeType) @@ -1305,7 +1311,7 @@ namespace System.Xml.XPath return strURI1 == nav.NamespaceURI; } - public override void GetInfo (out string name, out string ns, out XPathNodeType nodetype, XmlNamespaceManager nsm) + public override void GetInfo (out string name, out string ns, out XPathNodeType nodetype, NSResolver nsm) { // must be the correct node type nodetype = _axis.NodeType; diff --git a/mcs/class/System.XML/System.Xml.XPath/Iterator.cs b/mcs/class/System.XML/System.Xml.XPath/Iterator.cs index 6494e7c0b87..22cad45555d 100644 --- a/mcs/class/System.XML/System.Xml.XPath/Iterator.cs +++ b/mcs/class/System.XML/System.Xml.XPath/Iterator.cs @@ -36,23 +36,29 @@ using System.Xml; using System.Xml.XPath; using System.Xml.Xsl; +#if NET_2_0 +using NSResolver = System.Xml.IXmlNamespaceResolver; +#else +using NSResolver = System.Xml.XmlNamespaceManager; +#endif + namespace System.Xml.XPath { internal abstract class BaseIterator : XPathNodeIterator { - private XmlNamespaceManager _nsm; + private NSResolver _nsm; protected bool _needClone = true; // TODO: use this field in practice. internal BaseIterator (BaseIterator other) { _nsm = other._nsm; } - internal BaseIterator (XmlNamespaceManager nsm) + internal BaseIterator (NSResolver nsm) { _nsm = nsm; } - public XmlNamespaceManager NamespaceManager + public NSResolver NamespaceManager { get { return _nsm; } set { _nsm = value; } @@ -106,7 +112,7 @@ namespace System.Xml.XPath _pos = other._pos; _current = other._current.Clone (); } - public SimpleIterator (XPathNavigator nav, XmlNamespaceManager nsm) : base (nsm) + public SimpleIterator (XPathNavigator nav, NSResolver nsm) : base (nsm) { _nav = nav.Clone (); _current = nav.Clone (); @@ -119,7 +125,7 @@ namespace System.Xml.XPath internal class SelfIterator : SimpleIterator { public SelfIterator (BaseIterator iter) : base (iter) {} - public SelfIterator (XPathNavigator nav, XmlNamespaceManager nsm) : base (nav, nsm) {} + public SelfIterator (XPathNavigator nav, NSResolver nsm) : base (nav, nsm) {} protected SelfIterator (SelfIterator other) : base (other) {} public override XPathNodeIterator Clone () { return new SelfIterator (this); } public override bool MoveNext () @@ -140,7 +146,7 @@ namespace System.Xml.XPath { public NullIterator (BaseIterator iter) : base (iter) {} public NullIterator (XPathNavigator nav) : this (nav, null) {} - public NullIterator (XPathNavigator nav, XmlNamespaceManager nsm) : base (nav, nsm) {} + public NullIterator (XPathNavigator nav, NSResolver nsm) : base (nav, nsm) {} protected NullIterator (NullIterator other) : base (other) {} public override XPathNodeIterator Clone () { return new NullIterator (this); } public override bool MoveNext () @@ -178,7 +184,7 @@ namespace System.Xml.XPath { public ParentIterator (BaseIterator iter) : base (iter) {} protected ParentIterator (ParentIterator other) : base (other) {} - public ParentIterator (XPathNavigator nav, XmlNamespaceManager nsm) : base (nav, nsm) {} + public ParentIterator (XPathNavigator nav, NSResolver nsm) : base (nav, nsm) {} public override XPathNodeIterator Clone () { return new ParentIterator (this); } public override bool MoveNext () { @@ -1062,52 +1068,6 @@ namespace System.Xml.XPath public override bool RequireSorting { get { return true; } } } - /* - internal class EnumeratorIterator : BaseIterator - { - protected IEnumerator _enum; - protected int _pos; - bool _requireSorting; - - public EnumeratorIterator (BaseIterator iter, IEnumerator enumerator, bool requireSorting) : base (iter) - { - if (!(enumerator is ICloneable)) - throw new ArgumentException ("Target enumerator must be cloneable."); - _enum = enumerator; - _requireSorting = requireSorting; - } - - public EnumeratorIterator (IEnumerator enumerator, XmlNamespaceManager nsm, bool requireSorting) : base (nsm) - { - if (!(enumerator is ICloneable)) - throw new ArgumentException ("Target enumerator must be cloneable."); - _enum = enumerator; - _requireSorting = requireSorting; - } - - protected EnumeratorIterator (EnumeratorIterator other) : base (other) - { - ICloneable enumClone = other._enum as ICloneable; - _enum = (IEnumerator) enumClone.Clone (); - _pos = other._pos; - _requireSorting = other._requireSorting; - } - public override XPathNodeIterator Clone () { return new EnumeratorIterator (this); } - - public override bool MoveNext () - { - if (!_enum.MoveNext ()) - return false; - _pos++; - return true; - } - public override XPathNavigator Current { get { return (XPathNavigator) _enum.Current; }} - public override int CurrentPosition { get { return _pos; }} - - public override bool RequireSorting { get { return _requireSorting; } } - } - */ - internal class ListIterator : BaseIterator { protected IList _list; @@ -1122,7 +1082,7 @@ namespace System.Xml.XPath _requireSorting = requireSorting; } - public ListIterator (IList list, XmlNamespaceManager nsm, bool requireSorting) : base (nsm) + public ListIterator (IList list, NSResolver nsm, bool requireSorting) : base (nsm) { if (!(list is ICloneable)) throw new ArgumentException ("Target enumerator must be cloneable."); diff --git a/mcs/class/System.XML/System.Xml.XPath/XPathEditableNavigator.cs b/mcs/class/System.XML/System.Xml.XPath/XPathEditableNavigator.cs index d4e05b4a7c3..43839fb6dfd 100755 --- a/mcs/class/System.XML/System.Xml.XPath/XPathEditableNavigator.cs +++ b/mcs/class/System.XML/System.Xml.XPath/XPathEditableNavigator.cs @@ -41,7 +41,7 @@ using System.Xml.XPath; //using Mono.Xml.XPath2;
//using MS.Internal.Xml;
-namespace System.Xml
+namespace System.Xml.XPath
{
public abstract class XPathEditableNavigator
: XPathNavigator, IXPathEditable
diff --git a/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs b/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs index 52666dc7ac5..7ec5cdf43d4 100644 --- a/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs +++ b/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs @@ -36,9 +36,20 @@ using System.Xml; using System.Xml.Schema; using Mono.Xml.XPath; +#if NET_2_0 +using NSResolver = System.Xml.IXmlNamespaceResolver; +#else +using NSResolver = System.Xml.XmlNamespaceManager; +#endif + namespace System.Xml.XPath { +#if NET_2_0 + public abstract class XPathNavigator : XPathItem, + ICloneable, IXPathNavigable, IXmlNamespaceResolver +#else public abstract class XPathNavigator : ICloneable +#endif { #region Constructor @@ -70,7 +81,10 @@ namespace System.Xml.XPath public abstract string Prefix { get; } +#if NET_2_0 +#else public abstract string Value { get; } +#endif public abstract string XmlLang { get; } @@ -203,7 +217,7 @@ namespace System.Xml.XPath return Evaluate (expr, context, null); } - internal virtual object Evaluate (XPathExpression expr, XPathNodeIterator context, XmlNamespaceManager ctx) + internal virtual object Evaluate (XPathExpression expr, XPathNodeIterator context, NSResolver ctx) { CompiledExpression cexpr = (CompiledExpression) expr; if (ctx == null) @@ -216,7 +230,7 @@ namespace System.Xml.XPath return cexpr.Evaluate (iterContext); } - internal XPathNodeIterator EvaluateNodeSet (XPathExpression expr, XPathNodeIterator context, XmlNamespaceManager ctx) + internal XPathNodeIterator EvaluateNodeSet (XPathExpression expr, XPathNodeIterator context, NSResolver ctx) { CompiledExpression cexpr = (CompiledExpression) expr; if (ctx == null) @@ -229,7 +243,7 @@ namespace System.Xml.XPath return cexpr.EvaluateNodeSet (iterContext); } - internal string EvaluateString (XPathExpression expr, XPathNodeIterator context, XmlNamespaceManager ctx) + internal string EvaluateString (XPathExpression expr, XPathNodeIterator context, NSResolver ctx) { CompiledExpression cexpr = (CompiledExpression) expr; if (ctx == null) @@ -242,7 +256,7 @@ namespace System.Xml.XPath return cexpr.EvaluateString (iterContext); } - internal double EvaluateNumber (XPathExpression expr, XPathNodeIterator context, XmlNamespaceManager ctx) + internal double EvaluateNumber (XPathExpression expr, XPathNodeIterator context, NSResolver ctx) { CompiledExpression cexpr = (CompiledExpression) expr; if (ctx == null) @@ -255,7 +269,7 @@ namespace System.Xml.XPath return cexpr.EvaluateNumber (iterContext); } - internal bool EvaluateBoolean (XPathExpression expr, XPathNodeIterator context, XmlNamespaceManager ctx) + internal bool EvaluateBoolean (XPathExpression expr, XPathNodeIterator context, NSResolver ctx) { CompiledExpression cexpr = (CompiledExpression) expr; if (ctx == null) @@ -412,7 +426,7 @@ namespace System.Xml.XPath return Select (expr, null); } - internal virtual XPathNodeIterator Select (XPathExpression expr, XmlNamespaceManager ctx) + internal virtual XPathNodeIterator Select (XPathExpression expr, NSResolver ctx) { CompiledExpression cexpr = (CompiledExpression) expr; if (ctx == null) @@ -497,30 +511,11 @@ namespace System.Xml.XPath } [MonoTODO] - public virtual bool CheckValidity (XmlSchemaSet schemas, ValidationEventHandler handler, XmlSchemaAttribute attribute) - { - throw new NotImplementedException (); - } - - [MonoTODO] - public virtual bool CheckValidity (XmlSchemaSet schemas, ValidationEventHandler handler, XmlSchemaElement element) - { - throw new NotImplementedException (); - } - - [MonoTODO] - public virtual bool CheckValidity (XmlSchemaSet schemas, ValidationEventHandler handler, XmlSchemaType schemaType) - { - throw new NotImplementedException (); - } - - [MonoTODO] public virtual object CopyAsObject (Type targetType) { throw new NotImplementedException (); } - [MonoTODO] public virtual XPathNavigator CreateNavigator () { return Clone (); @@ -529,7 +524,7 @@ namespace System.Xml.XPath [MonoTODO] public virtual object Evaluate (string xpath, IXmlNamespaceResolver nsResolver) { - throw new NotImplementedException (); + return Evaluate (Compile (xpath), null, nsResolver); } [MonoTODO] @@ -577,13 +572,13 @@ namespace System.Xml.XPath throw new NotImplementedException (); } - public virtual object ValueAs (Type type) + public override object ValueAs (Type type) { - return ValueAs (type, null); + return ValueAs (type, this); } [MonoTODO] - public virtual object ValueAs (Type type, IXmlNamespaceResolver nsResolver) + public override object ValueAs (Type type, IXmlNamespaceResolver nsResolver) { throw new NotImplementedException (); } @@ -595,25 +590,20 @@ namespace System.Xml.XPath } [MonoTODO] - public bool HasNamespaceResolver { - get { throw new NotImplementedException (); } - } - - [MonoTODO] public virtual string InnerXml { get { throw new NotImplementedException (); } } - public virtual bool IsNode { + [MonoTODO] + public override bool IsNode { get { throw new NotImplementedException (); } } -/* FIXME: It should be member, but requires new Collection type. [MonoTODO] public virtual IKeyComparer NavigatorComparer { get { throw new NotImplementedException (); } } -*/ + [MonoTODO] public virtual string OuterXml { get { throw new NotImplementedException (); } @@ -634,46 +624,57 @@ namespace System.Xml.XPath get { throw new NotImplementedException (); } } - public virtual bool ValueAsBoolean { + [MonoTODO] + public override bool ValueAsBoolean { get { throw new NotImplementedException (); } } - public virtual DateTime ValueAsDateTime { + [MonoTODO] + public override DateTime ValueAsDateTime { get { throw new NotImplementedException (); } } - public virtual decimal ValueAsDecimal { + [MonoTODO] + public override decimal ValueAsDecimal { get { throw new NotImplementedException (); } } - public virtual double ValueAsDouble { + [MonoTODO] + public override double ValueAsDouble { get { throw new NotImplementedException (); } } - public virtual int ValueAsInt32 { + [MonoTODO] + public override int ValueAsInt32 { get { throw new NotImplementedException (); } } - public virtual long ValueAsInt64 { + [MonoTODO] + public override long ValueAsInt64 { get { throw new NotImplementedException (); } } - public virtual ICollection ValueAsList { + [MonoTODO] + public override ICollection ValueAsList { get { throw new NotImplementedException (); } } - public virtual float ValueAsSingle { + [MonoTODO] + public override float ValueAsSingle { get { throw new NotImplementedException (); } } + [MonoTODO] public virtual Type ValueType { get { throw new NotImplementedException (); } } + [MonoTODO] public virtual XmlSchemaType XmlType { get { throw new NotImplementedException (); } } + [MonoTODO] protected XmlReader GetValidatingReader (XmlSchemaSet schemas, ValidationEventHandler handler) { throw new NotImplementedException (); |