XPathDocument.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. //
  2. // System.Xml.XPath.XPathDocument
  3. //
  4. // Authors:
  5. // Tim Coleman ([email protected])
  6. // Atsushi Enomoto ([email protected])
  7. //
  8. // (C) Copyright 2002 Tim Coleman
  9. // (C) 2003 Atsushi Enomoto
  10. //
  11. using System;
  12. using System.Collections;
  13. using System.IO;
  14. using System.Xml;
  15. using System.Xml.Schema;
  16. using System.Text;
  17. using Mono.Xml.XPath;
  18. namespace System.Xml.XPath
  19. {
  20. public class XPathDocument : IXPathNavigable
  21. {
  22. DTMXPathDocument document;
  23. #region Constructors
  24. public XPathDocument (Stream stream)
  25. {
  26. XmlValidatingReader vr = new XmlValidatingReader (new XmlTextReader (stream));
  27. vr.ValidationType = ValidationType.None;
  28. Initialize (vr, XmlSpace.None);
  29. }
  30. public XPathDocument (string uri)
  31. : this (uri, XmlSpace.None)
  32. {
  33. }
  34. public XPathDocument (TextReader reader)
  35. {
  36. XmlValidatingReader vr = new XmlValidatingReader (new XmlTextReader (reader));
  37. vr.ValidationType = ValidationType.None;
  38. Initialize (vr, XmlSpace.None);
  39. }
  40. public XPathDocument (XmlReader reader)
  41. : this (reader, XmlSpace.None)
  42. {
  43. }
  44. public XPathDocument (string uri, XmlSpace space)
  45. {
  46. XmlValidatingReader vr = null;
  47. try {
  48. vr = new XmlValidatingReader (new XmlTextReader (uri));
  49. vr.ValidationType = ValidationType.None;
  50. Initialize (vr, space);
  51. } finally {
  52. if (vr != null)
  53. vr.Close ();
  54. }
  55. }
  56. public XPathDocument (XmlReader reader, XmlSpace space)
  57. {
  58. Initialize (reader, space);
  59. }
  60. private void Initialize (XmlReader reader, XmlSpace space)
  61. {
  62. document = new DTMXPathDocumentBuilder (reader, space).CreateDocument ();
  63. }
  64. #endregion
  65. #region Events
  66. #if NET_2_0
  67. public event NodeChangedEventHandler ChangeRejected;
  68. public event NodeChangedEventHandler ItemChanged;
  69. public event NodeChangedEventHandler ItemChanging;
  70. public event NodeChangedEventHandler ItemInserted;
  71. public event NodeChangedEventHandler ItemInserting;
  72. public event NodeChangedEventHandler ItemRemoved;
  73. public event NodeChangedEventHandler ItemRemoving;
  74. public event NodeChangedEventHandler RejectingChange;
  75. #endif // NET_2_0
  76. #endregion // Events
  77. #region Properties
  78. #if NET_2_0
  79. [MonoTODO]
  80. public virtual bool ContainsListCollection {
  81. get { throw new NotImplementedException (); }
  82. }
  83. [MonoTODO]
  84. public bool EnableChangeTracking {
  85. get { throw new NotImplementedException (); }
  86. set { throw new NotImplementedException (); }
  87. }
  88. [MonoTODO]
  89. public Encoding Encoding {
  90. get { throw new NotImplementedException (); }
  91. set { throw new NotImplementedException (); }
  92. }
  93. [MonoTODO]
  94. public XmlNameTable NameTable {
  95. get { throw new NotImplementedException (); }
  96. }
  97. [MonoTODO]
  98. public bool PreserveWhitespace {
  99. get { throw new NotImplementedException (); }
  100. }
  101. [MonoTODO]
  102. public XmlSchemaSet Schemas {
  103. get { throw new NotImplementedException (); }
  104. set { throw new NotImplementedException (); }
  105. }
  106. #endif // NET_2_0
  107. #endregion // Properies
  108. #region Methods
  109. #if NET_2_0
  110. [MonoTODO]
  111. public XPathChangeNavigator CreateChangeNavigator ()
  112. {
  113. throw new NotImplementedException ();
  114. }
  115. [MonoTODO]
  116. public XPathEditableNavigator CreateEditor ()
  117. {
  118. throw new NotImplementedException ();
  119. }
  120. [MonoTODO ("This code is only for compatibility.")]
  121. public XPathNavigator CreateNavigator ()
  122. {
  123. return document.CreateNavigator ();
  124. }
  125. [MonoTODO]
  126. public XmlWriter CreateWriter ()
  127. {
  128. throw new NotImplementedException ();
  129. }
  130. [MonoTODO]
  131. public virtual IList GetList ()
  132. {
  133. throw new NotImplementedException ();
  134. }
  135. [MonoTODO]
  136. public bool HasChanges ()
  137. {
  138. throw new NotImplementedException ();
  139. }
  140. [MonoTODO]
  141. public bool HasChanges (XmlChangeFilters changeFilter)
  142. {
  143. throw new NotImplementedException ();
  144. }
  145. [MonoTODO]
  146. public void Load (string xml)
  147. {
  148. throw new NotImplementedException ();
  149. // tree = new XPathDocumentTree (xmlReader);
  150. // if (acceptChangesOnLoad)
  151. // AcceptChanges ();
  152. }
  153. [MonoTODO]
  154. public void RejectChanges ()
  155. {
  156. throw new NotImplementedException ();
  157. }
  158. [MonoTODO ("Confirm writer settings etc.")]
  159. public void Save (Stream stream)
  160. {
  161. Save (new XmlTextWriter (stream, null));
  162. }
  163. [MonoTODO ("Confirm writer settings etc.")]
  164. public void Save (string filename)
  165. {
  166. using (XmlWriter w = new XmlTextWriter (filename, null)) {
  167. Save (w);
  168. }
  169. }
  170. [MonoTODO ("Confirm writer settings etc.")]
  171. public void Save (TextWriter writer)
  172. {
  173. Save (new XmlTextWriter (writer));
  174. }
  175. [MonoTODO]
  176. public void Save (XmlWriter writer)
  177. {
  178. throw new NotImplementedException ();
  179. }
  180. [MonoTODO]
  181. public XPathNodeIterator SelectNodes (string xpath)
  182. {
  183. return SelectNodes (xpath, null);
  184. }
  185. [MonoTODO]
  186. public XPathNodeIterator SelectNodes (XPathExpression expr)
  187. {
  188. throw new NotImplementedException ();
  189. }
  190. [MonoTODO]
  191. public XPathNodeIterator SelectNodes (string xpath ,IXmlNamespaceResolver nsResolver)
  192. {
  193. throw new NotImplementedException ();
  194. }
  195. [MonoTODO]
  196. public XPathEditableNavigator SelectSingleNode (string xpath)
  197. {
  198. return SelectSingleNode (xpath, null);
  199. }
  200. [MonoTODO]
  201. public XPathEditableNavigator SelectSingleNode (XPathExpression expr)
  202. {
  203. throw new NotImplementedException ();
  204. }
  205. [MonoTODO]
  206. public XPathEditableNavigator SelectSingleNode (string xpath ,IXmlNamespaceResolver nsResolver)
  207. {
  208. throw new NotImplementedException ();
  209. }
  210. #else // !NET_2_0
  211. public XPathNavigator CreateNavigator ()
  212. {
  213. return document.CreateNavigator ();
  214. }
  215. #endif
  216. #endregion
  217. }
  218. }