XPathDocument.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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 = new XmlValidatingReader (new XmlTextReader (uri));
  47. vr.ValidationType = ValidationType.None;
  48. Initialize (vr, space);
  49. }
  50. public XPathDocument (XmlReader reader, XmlSpace space)
  51. {
  52. Initialize (reader, space);
  53. }
  54. private void Initialize (XmlReader reader, XmlSpace space)
  55. {
  56. document = new DTMXPathDocumentBuilder (reader, space).CreateDocument ();
  57. }
  58. #endregion
  59. #region Events
  60. #if NET_2_0
  61. public event NodeChangedEventHandler ChangeRejected;
  62. public event NodeChangedEventHandler ItemChanged;
  63. public event NodeChangedEventHandler ItemChanging;
  64. public event NodeChangedEventHandler ItemInserted;
  65. public event NodeChangedEventHandler ItemInserting;
  66. public event NodeChangedEventHandler ItemRemoved;
  67. public event NodeChangedEventHandler ItemRemoving;
  68. public event NodeChangedEventHandler RejectingChange;
  69. #endif // NET_2_0
  70. #endregion // Events
  71. #region Properties
  72. #if NET_2_0
  73. [MonoTODO]
  74. public virtual bool ContainsListCollection {
  75. get { throw new NotImplementedException (); }
  76. }
  77. [MonoTODO]
  78. public bool EnableChangeTracking {
  79. get { throw new NotImplementedException (); }
  80. set { throw new NotImplementedException (); }
  81. }
  82. [MonoTODO]
  83. public Encoding Encoding {
  84. get { throw new NotImplementedException (); }
  85. set { throw new NotImplementedException (); }
  86. }
  87. [MonoTODO]
  88. public XmlNameTable NameTable {
  89. get { throw new NotImplementedException (); }
  90. }
  91. [MonoTODO]
  92. public bool PreserveWhitespace {
  93. get { throw new NotImplementedException (); }
  94. }
  95. [MonoTODO]
  96. public XmlSchemaSet Schemas {
  97. get { throw new NotImplementedException (); }
  98. set { throw new NotImplementedException (); }
  99. }
  100. #endif // NET_2_0
  101. #endregion // Properies
  102. #region Methods
  103. #if NET_2_0
  104. [MonoTODO]
  105. public XPathChangeNavigator CreateChangeNavigator ()
  106. {
  107. throw new NotImplementedException ();
  108. }
  109. [MonoTODO]
  110. public XPathEditableNavigator CreateEditor ()
  111. {
  112. throw new NotImplementedException ();
  113. }
  114. [MonoTODO ("This code is only for compatibility.")]
  115. public XPathNavigator CreateNavigator ()
  116. {
  117. return document.CreateNavigator ();
  118. }
  119. [MonoTODO]
  120. public XmlWriter CreateWriter ()
  121. {
  122. throw new NotImplementedException ();
  123. }
  124. [MonoTODO]
  125. public virtual IList GetList ()
  126. {
  127. throw new NotImplementedException ();
  128. }
  129. [MonoTODO]
  130. public bool HasChanges ()
  131. {
  132. throw new NotImplementedException ();
  133. }
  134. [MonoTODO]
  135. public bool HasChanges (XmlChangeFilters changeFilter)
  136. {
  137. throw new NotImplementedException ();
  138. }
  139. [MonoTODO]
  140. public void Load (string xml)
  141. {
  142. throw new NotImplementedException ();
  143. // tree = new XPathDocumentTree (xmlReader);
  144. // if (acceptChangesOnLoad)
  145. // AcceptChanges ();
  146. }
  147. [MonoTODO]
  148. public void RejectChanges ()
  149. {
  150. throw new NotImplementedException ();
  151. }
  152. [MonoTODO ("Confirm writer settings etc.")]
  153. public void Save (Stream stream)
  154. {
  155. Save (new XmlTextWriter (stream, null));
  156. }
  157. [MonoTODO ("Confirm writer settings etc.")]
  158. public void Save (string filename)
  159. {
  160. using (XmlWriter w = new XmlTextWriter (filename, null)) {
  161. Save (w);
  162. }
  163. }
  164. [MonoTODO ("Confirm writer settings etc.")]
  165. public void Save (TextWriter writer)
  166. {
  167. Save (new XmlTextWriter (writer));
  168. }
  169. [MonoTODO]
  170. public void Save (XmlWriter writer)
  171. {
  172. throw new NotImplementedException ();
  173. }
  174. [MonoTODO]
  175. public XPathNodeIterator SelectNodes (string xpath)
  176. {
  177. return SelectNodes (xpath, null);
  178. }
  179. [MonoTODO]
  180. public XPathNodeIterator SelectNodes (XPathExpression expr)
  181. {
  182. throw new NotImplementedException ();
  183. }
  184. [MonoTODO]
  185. public XPathNodeIterator SelectNodes (string xpath ,IXmlNamespaceResolver nsResolver)
  186. {
  187. throw new NotImplementedException ();
  188. }
  189. [MonoTODO]
  190. public XPathEditableNavigator SelectSingleNode (string xpath)
  191. {
  192. return SelectSingleNode (xpath, null);
  193. }
  194. [MonoTODO]
  195. public XPathEditableNavigator SelectSingleNode (XPathExpression expr)
  196. {
  197. throw new NotImplementedException ();
  198. }
  199. [MonoTODO]
  200. public XPathEditableNavigator SelectSingleNode (string xpath ,IXmlNamespaceResolver nsResolver)
  201. {
  202. throw new NotImplementedException ();
  203. }
  204. #else // !NET_2_0
  205. public XPathNavigator CreateNavigator ()
  206. {
  207. return document.CreateNavigator ();
  208. }
  209. #endif
  210. #endregion
  211. }
  212. }