XPathEditableNavigator.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. //
  2. // XPathEditableNavigator.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // (C)2003 Atsushi Enomoto
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. #if NET_2_0
  30. using System;
  31. using System.Collections;
  32. using System.Collections.Specialized;
  33. using System.ComponentModel;
  34. using System.IO;
  35. using System.Security.Policy;
  36. using System.Xml.Schema;
  37. using System.Xml.XPath;
  38. //using Mono.Xml.XPath2;
  39. //using MS.Internal.Xml;
  40. namespace System.Xml
  41. {
  42. public abstract class XPathEditableNavigator
  43. : XPathNavigator, IXPathEditable
  44. {
  45. protected XPathEditableNavigator ()
  46. {
  47. }
  48. public abstract XmlWriter AppendChild ();
  49. public virtual XPathEditableNavigator AppendChild (
  50. string xmlFragments)
  51. {
  52. // FIXME: should XmlParserContext be something?
  53. return AppendChild (new XmlTextReader (xmlFragments, XmlNodeType.Element, null));
  54. }
  55. [MonoTODO]
  56. public virtual XPathEditableNavigator AppendChild (
  57. XmlReader reader)
  58. {
  59. XmlWriter w = AppendChild ();
  60. w.WriteNode (reader, false);
  61. throw new NotImplementedException ();
  62. }
  63. [MonoTODO]
  64. public virtual XPathEditableNavigator AppendChild (
  65. XPathNavigator nav)
  66. {
  67. throw new NotImplementedException ();
  68. // AppendChild (new XPathNavigatorReader (nav));
  69. }
  70. public void AppendChildElement (string prefix, string name, string ns, string value)
  71. {
  72. XmlWriter xw = AppendChild ();
  73. xw.WriteStartElement (prefix, name, ns);
  74. xw.WriteString (value);
  75. xw.WriteEndElement ();
  76. xw.Close ();
  77. }
  78. public virtual void CreateAttribute (string prefix, string localName, string namespaceURI, string value)
  79. {
  80. using (XmlWriter w = CreateAttributes ()) {
  81. w.WriteAttributeString (prefix, localName, namespaceURI, value);
  82. }
  83. }
  84. public abstract XmlWriter CreateAttributes ();
  85. public virtual XPathEditableNavigator CreateEditor ()
  86. {
  87. return (XPathEditableNavigator) Clone ();
  88. }
  89. // LAMESPEC: documented as public abstract, but it conflicts
  90. // with XPathNavigator.CreateNavigator ().
  91. // public abstract XPathNavigator CreateNavigator ();
  92. public abstract bool DeleteCurrent ();
  93. public abstract XmlWriter InsertAfter ();
  94. public virtual XPathEditableNavigator InsertAfter (string xmlFragments)
  95. {
  96. return InsertAfter (new XmlTextReader (xmlFragments, XmlNodeType.Element, null));
  97. }
  98. [MonoTODO]
  99. public virtual XPathEditableNavigator InsertAfter (XmlReader reader)
  100. {
  101. using (XmlWriter w = InsertAfter ()) {
  102. w.WriteNode (reader, false);
  103. }
  104. throw new NotImplementedException ();
  105. }
  106. [MonoTODO]
  107. public virtual XPathEditableNavigator InsertAfter (XPathNavigator nav)
  108. {
  109. // InsertAfter (new XPathNavigatorReader (nav));
  110. throw new NotImplementedException ();
  111. }
  112. public abstract XmlWriter InsertBefore ();
  113. public virtual XPathEditableNavigator InsertBefore (string xmlFragments)
  114. {
  115. return InsertBefore (new XmlTextReader (xmlFragments, XmlNodeType.Element, null));
  116. }
  117. [MonoTODO]
  118. public virtual XPathEditableNavigator InsertBefore (XmlReader reader)
  119. {
  120. using (XmlWriter w = InsertBefore ()) {
  121. w.WriteNode (reader, false);
  122. }
  123. throw new NotImplementedException ();
  124. }
  125. [MonoTODO]
  126. public virtual XPathEditableNavigator InsertBefore (XPathNavigator nav)
  127. {
  128. // InsertBefore (new XPathNavigatorReader (nav));
  129. throw new NotImplementedException ();
  130. }
  131. public virtual void InsertElementAfter (string prefix,
  132. string localName, string namespaceURI, string value)
  133. {
  134. using (XmlWriter w = InsertAfter ()) {
  135. w.WriteElementString (prefix, localName, namespaceURI, value);
  136. }
  137. }
  138. public virtual void InsertElementBefore (string prefix,
  139. string localName, string namespaceURI, string value)
  140. {
  141. using (XmlWriter w = InsertBefore ()) {
  142. w.WriteElementString (prefix, localName, namespaceURI, value);
  143. }
  144. }
  145. public abstract XmlWriter PrependChild ();
  146. public virtual XPathEditableNavigator PrependChild (string xmlFragments)
  147. {
  148. return PrependChild (new XmlTextReader (xmlFragments, XmlNodeType.Element, null));
  149. }
  150. [MonoTODO]
  151. public virtual XPathEditableNavigator PrependChild (XmlReader reader)
  152. {
  153. using (XmlWriter w = PrependChild ()) {
  154. w.WriteNode (reader, false);
  155. }
  156. throw new NotImplementedException ();
  157. }
  158. [MonoTODO]
  159. public virtual XPathEditableNavigator PrependChild (XPathNavigator nav)
  160. {
  161. // PrependChild (new XPathNavigatorReader (nav));
  162. throw new NotImplementedException ();
  163. }
  164. public virtual void PrependChildElement (string prefix,
  165. string localName, string namespaceURI, string value)
  166. {
  167. using (XmlWriter w = PrependChild ()) {
  168. w.WriteElementString (prefix, localName, namespaceURI, value);
  169. }
  170. }
  171. // Dunno the exact purpose, but maybe internal editor use
  172. [MonoTODO]
  173. public virtual void SetFromObject (object value)
  174. {
  175. throw new NotImplementedException ();
  176. }
  177. public abstract void SetValue (object value);
  178. [MonoTODO]
  179. public virtual void Validate (XmlSchemaSet schemas, ValidationEventHandler handler)
  180. {
  181. throw new NotImplementedException ();
  182. }
  183. [MonoTODO]
  184. public virtual void Validate (XmlSchemaSet schemas, ValidationEventHandler handler, XmlSchemaAttribute attribute)
  185. {
  186. throw new NotImplementedException ();
  187. }
  188. [MonoTODO]
  189. public virtual void Validate (XmlSchemaSet schemas, ValidationEventHandler handler, XmlSchemaElement element)
  190. {
  191. throw new NotImplementedException ();
  192. }
  193. [MonoTODO]
  194. public virtual void Validate (XmlSchemaSet schemas, ValidationEventHandler handler, XmlSchemaType schemaType)
  195. {
  196. throw new NotImplementedException ();
  197. }
  198. [MonoTODO]
  199. public override string InnerXml {
  200. get { throw new NotImplementedException (); }
  201. }
  202. [MonoTODO]
  203. public override string OuterXml {
  204. get { throw new NotImplementedException (); }
  205. }
  206. }
  207. }
  208. #endif