diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2006-12-05 13:07:29 +0300 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2006-12-05 13:07:29 +0300 |
commit | 23638c8d3c8964abf6916d0e36553d49523cc675 (patch) | |
tree | be319956c11059baf2e7c619cc7bc08b9d8b2891 /mcs/class/System.XML/Mono.Xml.XPath | |
parent | 37adfe5087ada2a2dea92317afd85fb3daf8adf4 (diff) |
2006-12-05 Atsushi Enomoto <atsushi@ximian.com>
* XmlNode.cs : GetPrefixOfNamespace() was not correctly searching
ancestors' namespaces.
* XPathEditableDocument.cs : those writers should lookup prefix when
WriteStartElement/WriteStartAttribute are passed null prefix.
Removed nodeStack in XmlDocumentInsertionWriter, since nodes are
always added to current node immediately.
* XmlNodeTests.cs : added another test for GetPrefixOfNamespace().
* XPathNavigatorTests.cs : added test for XPath navigator editor's
LookupPrefix().
svn path=/trunk/mcs/; revision=69021
Diffstat (limited to 'mcs/class/System.XML/Mono.Xml.XPath')
-rw-r--r-- | mcs/class/System.XML/Mono.Xml.XPath/ChangeLog | 7 | ||||
-rw-r--r-- | mcs/class/System.XML/Mono.Xml.XPath/XPathEditableDocument.cs | 32 |
2 files changed, 22 insertions, 17 deletions
diff --git a/mcs/class/System.XML/Mono.Xml.XPath/ChangeLog b/mcs/class/System.XML/Mono.Xml.XPath/ChangeLog index b21d0e774ce..ee3ffbabb02 100644 --- a/mcs/class/System.XML/Mono.Xml.XPath/ChangeLog +++ b/mcs/class/System.XML/Mono.Xml.XPath/ChangeLog @@ -1,3 +1,10 @@ +2006-12-05 Atsushi Enomoto <atsushi@ximian.com> + + * XPathEditableDocument.cs : those writers should lookup prefix when + WriteStartElement/WriteStartAttribute are passed null prefix. + Removed nodeStack in XmlDocumentInsertionWriter, since nodes are + always added to current node immediately. + 2006-11-10 Atsushi Enomoto <atsushi@ximian.com> * XPathNavigatorReader.cs : removed node type restriction on diff --git a/mcs/class/System.XML/Mono.Xml.XPath/XPathEditableDocument.cs b/mcs/class/System.XML/Mono.Xml.XPath/XPathEditableDocument.cs index bda76959225..d7a008ebcfb 100644 --- a/mcs/class/System.XML/Mono.Xml.XPath/XPathEditableDocument.cs +++ b/mcs/class/System.XML/Mono.Xml.XPath/XPathEditableDocument.cs @@ -74,7 +74,8 @@ namespace Mono.Xml.XPath XmlNode parent; XmlNode current; XmlNode nextSibling; - Stack nodeStack = new Stack (); + WriteState state; + XmlAttribute attribute; public XmlDocumentInsertionWriter (XmlNode owner, XmlNode nextSibling) { @@ -96,20 +97,15 @@ namespace Mono.Xml.XPath state = WriteState.Content; } - WriteState state; - XmlAttribute attribute; - public override WriteState WriteState { get { return state; } } public override void Close () { - while (nodeStack.Count > 0) { - XmlNode n = nodeStack.Pop () as XmlNode; - n.AppendChild (current); - current = n; - } + while (current.ParentNode != null) + current = current.ParentNode; + parent.InsertBefore ((XmlDocumentFragment) current, nextSibling); if (Closed != null) Closed (this); @@ -117,8 +113,6 @@ namespace Mono.Xml.XPath internal event XmlWriterClosedEventHandler Closed; - internal XmlNode AppendedFirstChild; - public override void Flush () { } @@ -132,6 +126,8 @@ namespace Mono.Xml.XPath { if (state != WriteState.Content) throw new InvalidOperationException ("Current state is not inside element. Cannot start attribute."); + if (prefix == null && ns != null && ns.Length > 0) + prefix = LookupPrefix (ns); attribute = current.OwnerDocument.CreateAttribute (prefix, name, ns); state = WriteState.Attribute; } @@ -156,17 +152,18 @@ namespace Mono.Xml.XPath public override void WriteStartElement (string prefix, string name, string ns) { + if (prefix == null && ns != null && ns.Length > 0) + prefix = LookupPrefix (ns); XmlElement el = current.OwnerDocument.CreateElement (prefix, name, ns); current.AppendChild (el); - nodeStack.Push (current); current = el; } public override void WriteEndElement () { - if (nodeStack.Count == 0) + current = current.ParentNode; + if (current == null) throw new InvalidOperationException ("No element is opened."); - current = nodeStack.Pop () as XmlNode; } public override void WriteFullEndElement () @@ -268,6 +265,8 @@ namespace Mono.Xml.XPath internal class XmlDocumentAttributeWriter : XmlWriter { XmlElement element; + WriteState state; + XmlAttribute attribute; public XmlDocumentAttributeWriter (XmlNode owner) { @@ -277,9 +276,6 @@ namespace Mono.Xml.XPath state = WriteState.Content; } - WriteState state; - XmlAttribute attribute; - public override WriteState WriteState { get { return state; } } @@ -301,6 +297,8 @@ namespace Mono.Xml.XPath { if (state != WriteState.Content) throw new InvalidOperationException ("Current state is not inside element. Cannot start attribute."); + if (prefix == null && ns != null && ns.Length > 0) + prefix = LookupPrefix (ns); attribute = element.OwnerDocument.CreateAttribute (prefix, name, ns); state = WriteState.Attribute; } |