From 1ca41856d9f2a29b6c7304cc76b1aaeb712ae275 Mon Sep 17 00:00:00 2001 From: Atsushi Eno Date: Thu, 28 Oct 2004 06:29:02 +0000 Subject: 2004-10-28 Atsushi Enomoto * XPathEditableDocument.cs : Copied from sys.xml. svn path=/trunk/mcs/; revision=35390 --- mcs/class/Mono.Xml.Ext/Mono.Xml.XPath/ChangeLog | 4 +++ .../Mono.Xml.XPath/XPathEditableDocument.cs | 33 +++++++++++++++++----- 2 files changed, 30 insertions(+), 7 deletions(-) (limited to 'mcs/class/Mono.Xml.Ext') diff --git a/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath/ChangeLog b/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath/ChangeLog index 596b2e9a6c5..d46297932c5 100755 --- a/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath/ChangeLog +++ b/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath/ChangeLog @@ -1,3 +1,7 @@ +2004-10-28 Atsushi Enomoto + + * XPathEditableDocument.cs : Copied from sys.xml. + 2004-10-22 Atsushi Enomoto DTMXPathDocument.cs, diff --git a/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath/XPathEditableDocument.cs b/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath/XPathEditableDocument.cs index 828a0414f05..4407c585b2a 100755 --- a/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath/XPathEditableDocument.cs +++ b/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath/XPathEditableDocument.cs @@ -6,7 +6,7 @@ // // (C)2004 Novell Inc. // -// Yet another implementation of editable XPathNavigator. +// Yet another implementation of XPathEditableNavigator. // (Even runnable under MS.NET 2.0) // // By rewriting XPathEditableDocument.CreateNavigator() as just to @@ -99,18 +99,26 @@ namespace Mono.Xml.XPath } */ - XmlDocument document; + XmlNode node; ArrayList changes = new ArrayList (); - public XPathEditableDocument (XmlDocument doc) + public XPathEditableDocument (XmlNode node) { - document = doc; + this.node = node; + } + + public virtual bool CanEdit { + get { return true; } + } + + public XmlNode Node { + get { return node; } } public XPathNavigator CreateNavigator () { - return document.CreateNavigator (); + return new XmlDocumentEditableNavigator (this); } public XmlWriter CreateWriter () @@ -592,13 +600,25 @@ namespace Mono.Xml.XPath public class XmlDocumentEditableNavigator : XPathNavigator, IHasXmlNode { + static readonly bool isXmlDocumentNavigatorImpl; + + static XmlDocumentEditableNavigator () + { + isXmlDocumentNavigatorImpl = + (typeof (XmlDocumentEditableNavigator).Assembly + == typeof (XmlDocument).Assembly); + } + XPathEditableDocument document; XPathNavigator navigator; public XmlDocumentEditableNavigator (XPathEditableDocument doc) { document = doc; - navigator = doc.CreateNavigator (); + if (isXmlDocumentNavigatorImpl) + navigator = new XmlDocumentNavigator (doc.Node); + else + navigator = doc.CreateNavigator (); } public XmlDocumentEditableNavigator (XmlDocumentEditableNavigator nav) @@ -755,7 +775,6 @@ namespace Mono.Xml.XPath foreach (XmlNode c in n.ChildNodes) document.DeleteNode (c); XmlWriter w = document.CreateInsertionWriter (n, null); - // FIXME: Hmm, it does not look like using it. w.WriteValue (value); w.Close (); } -- cgit v1.2.3