XmlDocumentNavigator.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  1. //
  2. // System.Xml.XmlDocumentNavigator
  3. //
  4. // Authors:
  5. // Jason Diamond <[email protected]>
  6. // Atsushi Enomoto <[email protected]>
  7. //
  8. // (C) 2002 Jason Diamond
  9. // (C) 2003 Atsushi Enomoto
  10. //
  11. //
  12. // Permission is hereby granted, free of charge, to any person obtaining
  13. // a copy of this software and associated documentation files (the
  14. // "Software"), to deal in the Software without restriction, including
  15. // without limitation the rights to use, copy, modify, merge, publish,
  16. // distribute, sublicense, and/or sell copies of the Software, and to
  17. // permit persons to whom the Software is furnished to do so, subject to
  18. // the following conditions:
  19. //
  20. // The above copyright notice and this permission notice shall be
  21. // included in all copies or substantial portions of the Software.
  22. //
  23. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  27. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  28. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  29. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  30. //
  31. using System;
  32. using System.Collections;
  33. using System.Xml;
  34. using System.Xml.Schema;
  35. using System.Xml.XPath;
  36. namespace System.Xml
  37. {
  38. internal class XmlDocumentNavigator : XPathNavigator, IHasXmlNode
  39. {
  40. #region Constructors
  41. internal XmlDocumentNavigator (XmlNode node)
  42. {
  43. this.node = node;
  44. if (node.NodeType == XmlNodeType.Attribute && node.NamespaceURI == XmlNamespaceManager.XmlnsXmlns) {
  45. nsNode = (XmlAttribute) node;
  46. node = nsNode.OwnerElement;
  47. }
  48. }
  49. #endregion
  50. #region Fields
  51. private const string Xmlns = "http://www.w3.org/2000/xmlns/";
  52. private const string XmlnsXML = "http://www.w3.org/XML/1998/namespace";
  53. private XmlNode node;
  54. // Current namespace node (ancestor's attribute of current node).
  55. private XmlAttribute nsNode;
  56. private ArrayList iteratedNsNames;
  57. #endregion
  58. #region Properties
  59. internal XmlDocument Document {
  60. get { return node.NodeType == XmlNodeType.Document ? node as XmlDocument : node.OwnerDocument; }
  61. }
  62. public override string BaseURI {
  63. get {
  64. return node.BaseURI;
  65. }
  66. }
  67. public override bool HasAttributes {
  68. get {
  69. if (NsNode != null)
  70. return false;
  71. XmlElement el = node as XmlElement;
  72. if (el == null || !el.HasAttributes)
  73. return false;
  74. for (int i = 0; i < node.Attributes.Count; i++)
  75. if (node.Attributes [i].NamespaceURI != Xmlns)
  76. return true;
  77. return false;
  78. }
  79. }
  80. public override bool HasChildren {
  81. get {
  82. if (NsNode != null)
  83. return false;
  84. XPathNodeType nodeType = NodeType;
  85. bool canHaveChildren = nodeType == XPathNodeType.Root || nodeType == XPathNodeType.Element;
  86. return canHaveChildren && GetFirstChild (node) != null;
  87. }
  88. }
  89. public override bool IsEmptyElement {
  90. get {
  91. if (NsNode != null)
  92. return false;
  93. return node.NodeType == XmlNodeType.Element
  94. && ((XmlElement) node).IsEmpty;
  95. }
  96. }
  97. public XmlAttribute NsNode {
  98. get { return nsNode; }
  99. set {
  100. if (value == null)
  101. iteratedNsNames = null;
  102. else
  103. {
  104. if (iteratedNsNames == null)
  105. iteratedNsNames = new ArrayList();
  106. else
  107. {
  108. if (iteratedNsNames.IsReadOnly)
  109. iteratedNsNames = new ArrayList(iteratedNsNames);
  110. }
  111. iteratedNsNames.Add (value.Name);
  112. }
  113. nsNode = value;
  114. }
  115. }
  116. public override string LocalName {
  117. get {
  118. XmlAttribute nsNode = NsNode;
  119. if (nsNode != null) {
  120. if (nsNode == Document.NsNodeXml)
  121. return "xml";
  122. else
  123. return (nsNode.Name == "xmlns") ? String.Empty : nsNode.LocalName;
  124. }
  125. XPathNodeType nodeType = NodeType;
  126. bool canHaveName =
  127. nodeType == XPathNodeType.Element ||
  128. nodeType == XPathNodeType.Attribute ||
  129. nodeType == XPathNodeType.ProcessingInstruction ||
  130. nodeType == XPathNodeType.Namespace;
  131. return canHaveName ? node.LocalName : String.Empty;
  132. }
  133. }
  134. public override string Name {
  135. get {
  136. if (NsNode != null)
  137. return LocalName;
  138. XPathNodeType nodeType = NodeType;
  139. bool canHaveName =
  140. nodeType == XPathNodeType.Element ||
  141. nodeType == XPathNodeType.Attribute ||
  142. nodeType == XPathNodeType.ProcessingInstruction ||
  143. nodeType == XPathNodeType.Namespace;
  144. return canHaveName ? node.Name : String.Empty;
  145. }
  146. }
  147. public override string NamespaceURI {
  148. get { return (NsNode != null) ? String.Empty : node.NamespaceURI; }
  149. }
  150. public override XmlNameTable NameTable {
  151. get { return Document.NameTable; }
  152. }
  153. public override XPathNodeType NodeType {
  154. get {
  155. if (NsNode != null)
  156. return XPathNodeType.Namespace;
  157. XmlNode n = node;
  158. bool sw = false;
  159. do {
  160. switch (n.NodeType) {
  161. case XmlNodeType.SignificantWhitespace:
  162. sw = true;
  163. n = GetNextSibling (n);
  164. break;
  165. case XmlNodeType.Whitespace:
  166. n = GetNextSibling (n);
  167. break;
  168. case XmlNodeType.Text:
  169. case XmlNodeType.CDATA:
  170. return XPathNodeType.Text;
  171. default:
  172. n = null;
  173. break;
  174. }
  175. } while (n != null);
  176. return sw ?
  177. XPathNodeType.SignificantWhitespace :
  178. node.XPathNodeType;
  179. }
  180. }
  181. public override string Prefix {
  182. get { return (NsNode != null) ? String.Empty : node.Prefix; }
  183. }
  184. #if NET_2_0
  185. public override IXmlSchemaInfo SchemaInfo {
  186. get { return NsNode != null ? null : node.SchemaInfo; }
  187. }
  188. public override object UnderlyingObject {
  189. get { return node; }
  190. }
  191. #endif
  192. public override string Value {
  193. get {
  194. switch (NodeType) {
  195. case XPathNodeType.Attribute:
  196. case XPathNodeType.Comment:
  197. case XPathNodeType.ProcessingInstruction:
  198. return node.Value;
  199. case XPathNodeType.Text:
  200. case XPathNodeType.Whitespace:
  201. case XPathNodeType.SignificantWhitespace:
  202. string value = node.Value;
  203. for (XmlNode n = GetNextSibling (node); n != null; n = GetNextSibling (n)) {
  204. switch (n.XPathNodeType) {
  205. case XPathNodeType.Text:
  206. case XPathNodeType.Whitespace:
  207. case XPathNodeType.SignificantWhitespace:
  208. value += n.Value;
  209. continue;
  210. }
  211. break;
  212. }
  213. return value;
  214. case XPathNodeType.Element:
  215. case XPathNodeType.Root:
  216. return node.InnerText;
  217. case XPathNodeType.Namespace:
  218. return NsNode == Document.NsNodeXml ? XmlnsXML : NsNode.Value;
  219. }
  220. return String.Empty;
  221. }
  222. }
  223. public override string XmlLang {
  224. get {
  225. return node.XmlLang;
  226. }
  227. }
  228. #endregion
  229. #region Methods
  230. private bool CheckNsNameAppearance (string name, string ns)
  231. {
  232. if (iteratedNsNames != null && iteratedNsNames.Contains (name))
  233. return true;
  234. // default namespace erasure - just add name and never return this node
  235. if (ns == String.Empty) {
  236. if (iteratedNsNames == null)
  237. iteratedNsNames = new ArrayList();
  238. else
  239. {
  240. if (iteratedNsNames.IsReadOnly)
  241. iteratedNsNames = new ArrayList(iteratedNsNames);
  242. }
  243. iteratedNsNames.Add ("xmlns");
  244. return true;
  245. }
  246. return false;
  247. }
  248. public override XPathNavigator Clone ()
  249. {
  250. XmlDocumentNavigator clone = new XmlDocumentNavigator (node);
  251. clone.nsNode = nsNode;
  252. clone.iteratedNsNames = (iteratedNsNames == null || iteratedNsNames.IsReadOnly) ? iteratedNsNames : ArrayList.ReadOnly(iteratedNsNames);
  253. return clone;
  254. }
  255. public override string GetAttribute (string localName, string namespaceURI)
  256. {
  257. if (HasAttributes) {
  258. XmlElement el = Node as XmlElement;
  259. return el != null ? el.GetAttribute (localName, namespaceURI) : String.Empty;
  260. }
  261. return String.Empty;
  262. }
  263. public override string GetNamespace (string name)
  264. {
  265. // MSDN says "String.Empty if a matching namespace
  266. // node is not found or if the navigator is not
  267. // positioned on an element node", but in fact it
  268. // returns actual namespace for the other nodes.
  269. return Node.GetNamespaceOfPrefix (name);
  270. }
  271. public override bool IsDescendant (XPathNavigator other)
  272. {
  273. if (NsNode != null)
  274. return false;
  275. XmlDocumentNavigator o = other as XmlDocumentNavigator;
  276. if (o == null)
  277. return false;
  278. XmlNode n =
  279. o.node.NodeType == XmlNodeType.Attribute ?
  280. ((XmlAttribute) o.node).OwnerElement :
  281. o.node.ParentNode;
  282. for (;n != null; n = n.ParentNode)
  283. if (n == node)
  284. return true;
  285. return false;
  286. }
  287. public override bool IsSamePosition (XPathNavigator other)
  288. {
  289. XmlDocumentNavigator otherDocumentNavigator = other as XmlDocumentNavigator;
  290. if (otherDocumentNavigator != null)
  291. return node == otherDocumentNavigator.node
  292. && NsNode == otherDocumentNavigator.NsNode;
  293. return false;
  294. }
  295. public override bool MoveTo (XPathNavigator other)
  296. {
  297. XmlDocumentNavigator otherDocumentNavigator = other as XmlDocumentNavigator;
  298. if (otherDocumentNavigator != null) {
  299. if (Document == otherDocumentNavigator.Document) {
  300. node = otherDocumentNavigator.node;
  301. NsNode = otherDocumentNavigator.NsNode;
  302. return true;
  303. }
  304. }
  305. return false;
  306. }
  307. public override bool MoveToAttribute (string localName, string namespaceURI)
  308. {
  309. if (HasAttributes) {
  310. XmlAttribute attr = node.Attributes [localName, namespaceURI];
  311. if (attr != null) {
  312. node = attr;
  313. NsNode = null;
  314. return true;
  315. }
  316. }
  317. return false;
  318. }
  319. #if NET_2_0
  320. #else
  321. public override bool MoveToFirst ()
  322. {
  323. return MoveToFirstImpl ();
  324. }
  325. #endif
  326. public override bool MoveToFirstAttribute ()
  327. {
  328. if (NodeType == XPathNodeType.Element) {
  329. XmlElement el = node as XmlElement;
  330. if (!el.HasAttributes)
  331. return false;
  332. for (int i = 0; i < node.Attributes.Count; i++) {
  333. XmlAttribute attr = node.Attributes [i];
  334. if (attr.NamespaceURI != Xmlns) {
  335. node = attr;
  336. NsNode = null;
  337. return true;
  338. }
  339. }
  340. }
  341. return false;
  342. }
  343. public override bool MoveToFirstChild ()
  344. {
  345. if (HasChildren) {
  346. XmlNode n = GetFirstChild (node);
  347. if (n == null)
  348. return false;
  349. node = n;
  350. return true;
  351. }
  352. return false;
  353. }
  354. public override bool MoveToFirstNamespace (XPathNamespaceScope namespaceScope)
  355. {
  356. if (NodeType != XPathNodeType.Element)
  357. return false;
  358. XmlElement el = node as XmlElement;
  359. do {
  360. if (el.HasAttributes) {
  361. for (int i = 0; i < el.Attributes.Count; i++) {
  362. XmlAttribute attr = el.Attributes [i];
  363. if (attr.NamespaceURI == Xmlns) {
  364. if (CheckNsNameAppearance (attr.Name, attr.Value))
  365. continue;
  366. NsNode = attr;
  367. return true;
  368. }
  369. }
  370. }
  371. if (namespaceScope == XPathNamespaceScope.Local)
  372. return false;
  373. el = GetParentNode (el) as XmlElement;
  374. } while (el != null);
  375. if (namespaceScope == XPathNamespaceScope.All) {
  376. if (CheckNsNameAppearance (Document.NsNodeXml.Name, Document.NsNodeXml.Value))
  377. return false;
  378. NsNode = Document.NsNodeXml;
  379. return true;
  380. }
  381. else
  382. return false;
  383. }
  384. public override bool MoveToId (string id)
  385. {
  386. XmlElement eltNew = Document.GetElementById (id);
  387. if (eltNew == null)
  388. return false;
  389. node = eltNew;
  390. return true;
  391. }
  392. public override bool MoveToNamespace (string name)
  393. {
  394. if (name == "xml") {
  395. NsNode = Document.NsNodeXml;
  396. return true;
  397. }
  398. if (NodeType != XPathNodeType.Element)
  399. return false;
  400. XmlElement el = node as XmlElement;
  401. do {
  402. if (el.HasAttributes) {
  403. for (int i = 0; i < el.Attributes.Count; i++) {
  404. XmlAttribute attr = el.Attributes [i];
  405. if (attr.NamespaceURI == Xmlns && attr.Name == name) {
  406. NsNode = attr;
  407. return true;
  408. }
  409. }
  410. }
  411. el = GetParentNode (node) as XmlElement;
  412. } while (el != null);
  413. return false;
  414. }
  415. public override bool MoveToNext ()
  416. {
  417. if (NsNode != null)
  418. return false;
  419. XmlNode n = node;
  420. if (NodeType == XPathNodeType.Text) {
  421. do {
  422. n = GetNextSibling (n);
  423. if (n == null)
  424. return false;
  425. switch (n.NodeType) {
  426. case XmlNodeType.CDATA:
  427. case XmlNodeType.SignificantWhitespace:
  428. case XmlNodeType.Text:
  429. case XmlNodeType.Whitespace:
  430. continue;
  431. default:
  432. break;
  433. }
  434. break;
  435. } while (true);
  436. }
  437. else
  438. n = GetNextSibling (n);
  439. if (n == null)
  440. return false;
  441. node = n;
  442. return true;
  443. }
  444. public override bool MoveToNextAttribute ()
  445. {
  446. if (node == null)
  447. return false;
  448. if (NodeType != XPathNodeType.Attribute)
  449. return false;
  450. // Find current attribute.
  451. int pos = 0;
  452. XmlElement owner = ((XmlAttribute) node).OwnerElement;
  453. if (owner == null)
  454. return false;
  455. int count = owner.Attributes.Count;
  456. for(; pos < count; pos++)
  457. if (owner.Attributes [pos] == node)
  458. break;
  459. if (pos == count)
  460. return false; // Where is current attribute? Maybe removed.
  461. // Find next attribute.
  462. for(pos++; pos < count; pos++) {
  463. if (owner.Attributes [pos].NamespaceURI != Xmlns) {
  464. node = owner.Attributes [pos];
  465. NsNode = null;
  466. return true;
  467. }
  468. }
  469. return false;
  470. }
  471. public override bool MoveToNextNamespace (XPathNamespaceScope namespaceScope)
  472. {
  473. if (NsNode == Document.NsNodeXml)
  474. // Current namespace is "xml", so there should be no more namespace nodes.
  475. return false;
  476. if (NsNode == null)
  477. return false;
  478. // Get current attribute's position.
  479. int pos = 0;
  480. XmlElement owner = ((XmlAttribute) NsNode).OwnerElement;
  481. if (owner == null)
  482. return false;
  483. int count = owner.Attributes.Count;
  484. for(; pos < count; pos++)
  485. if (owner.Attributes [pos] == NsNode)
  486. break;
  487. if (pos == count)
  488. return false; // Where is current attribute? Maybe removed.
  489. // Find next namespace from the same element as current ns node.
  490. for(pos++; pos < count; pos++) {
  491. if (owner.Attributes [pos].NamespaceURI == Xmlns) {
  492. XmlAttribute a = owner.Attributes [pos];
  493. if (CheckNsNameAppearance (a.Name, a.Value))
  494. continue;
  495. NsNode = a;
  496. return true;
  497. }
  498. }
  499. // If not found more, then find from ancestors.
  500. // But if scope is Local, then it returns false here.
  501. if (namespaceScope == XPathNamespaceScope.Local)
  502. return false;
  503. owner = GetParentNode (owner) as XmlElement;
  504. while (owner != null) {
  505. if (owner.HasAttributes) {
  506. for (int i = 0; i < owner.Attributes.Count; i++) {
  507. XmlAttribute attr = owner.Attributes [i];
  508. if (attr.NamespaceURI == Xmlns) {
  509. if (CheckNsNameAppearance (attr.Name, attr.Value))
  510. continue;
  511. NsNode = attr;
  512. return true;
  513. }
  514. }
  515. }
  516. owner = GetParentNode (owner) as XmlElement;
  517. }
  518. if (namespaceScope == XPathNamespaceScope.All) {
  519. if (CheckNsNameAppearance (Document.NsNodeXml.Name, Document.NsNodeXml.Value))
  520. return false;
  521. NsNode = Document.NsNodeXml;
  522. return true;
  523. }
  524. return false;
  525. }
  526. public override bool MoveToParent ()
  527. {
  528. if (NsNode != null) {
  529. NsNode = null;
  530. return true;
  531. }
  532. else if (node.NodeType == XmlNodeType.Attribute) {
  533. XmlElement ownerElement = ((XmlAttribute)node).OwnerElement;
  534. if (ownerElement != null) {
  535. node = ownerElement;
  536. NsNode = null;
  537. return true;
  538. }
  539. else
  540. return false;
  541. }
  542. XmlNode n = GetParentNode (node);
  543. if (n == null)
  544. return false;
  545. node = n;
  546. NsNode = null;
  547. return true;
  548. }
  549. public override bool MoveToPrevious ()
  550. {
  551. if (NsNode != null)
  552. return false;
  553. XmlNode p = GetPreviousSibling (node);
  554. if (p == null)
  555. return false;
  556. node = p;
  557. return true;
  558. }
  559. public override void MoveToRoot ()
  560. {
  561. XmlAttribute attr = node as XmlAttribute;
  562. XmlNode tmp = attr != null ? attr.OwnerElement : node;
  563. if (tmp == null)
  564. return; // i.e. attr has null OwnerElement.
  565. for (XmlNode tmp2 = GetParentNode (tmp); tmp2 != null; tmp2 = GetParentNode (tmp2))
  566. tmp = tmp2;
  567. node = tmp;
  568. NsNode = null;
  569. }
  570. private XmlNode Node { get { return NsNode != null ? NsNode : node; } }
  571. XmlNode IHasXmlNode.GetNode ()
  572. {
  573. return Node;
  574. }
  575. private XmlNode GetFirstChild (XmlNode n)
  576. {
  577. if (n.FirstChild == null)
  578. return null;
  579. switch (n.FirstChild.NodeType) {
  580. case XmlNodeType.XmlDeclaration:
  581. case XmlNodeType.DocumentType:
  582. return GetNextSibling (n.FirstChild);
  583. case XmlNodeType.EntityReference:
  584. foreach (XmlNode c in n.ChildNodes) {
  585. if (c.NodeType == XmlNodeType.EntityReference) {
  586. XmlNode ec = GetFirstChild (c);
  587. if (ec != null)
  588. return ec;
  589. }
  590. else
  591. return c;
  592. }
  593. return null;
  594. default:
  595. return n.FirstChild;
  596. }
  597. }
  598. private XmlNode GetLastChild (XmlNode n)
  599. {
  600. if (n.LastChild == null)
  601. return null;
  602. switch (n.LastChild.NodeType) {
  603. case XmlNodeType.XmlDeclaration:
  604. case XmlNodeType.DocumentType:
  605. return GetPreviousSibling (n.LastChild);
  606. case XmlNodeType.EntityReference:
  607. for (XmlNode c = n.LastChild; c != null; c = c.PreviousSibling) {
  608. if (c.NodeType == XmlNodeType.EntityReference) {
  609. XmlNode ec = GetLastChild (c);
  610. if (ec != null)
  611. return ec;
  612. }
  613. else
  614. return c;
  615. }
  616. return null;
  617. default:
  618. return n.LastChild;
  619. }
  620. }
  621. private XmlNode GetPreviousSibling (XmlNode n)
  622. {
  623. XmlNode p = n.PreviousSibling;
  624. if (p != null) {
  625. switch (p.NodeType) {
  626. case XmlNodeType.EntityReference:
  627. XmlNode c = GetLastChild (p);
  628. if (c != null)
  629. return c;
  630. else // empty entity reference etc.
  631. return GetPreviousSibling (p);
  632. case XmlNodeType.XmlDeclaration:
  633. case XmlNodeType.DocumentType:
  634. return GetPreviousSibling (p);
  635. default:
  636. return p;
  637. }
  638. } else {
  639. if (n.ParentNode == null || n.ParentNode.NodeType != XmlNodeType.EntityReference)
  640. return null;
  641. return GetPreviousSibling (n.ParentNode);
  642. }
  643. }
  644. private XmlNode GetNextSibling (XmlNode n)
  645. {
  646. XmlNode nx = n.NextSibling;
  647. if (nx != null) {
  648. switch (nx.NodeType) {
  649. case XmlNodeType.EntityReference:
  650. XmlNode c = GetFirstChild (nx);
  651. if (c != null)
  652. return c;
  653. else // empty entity reference etc.
  654. return GetNextSibling (nx);
  655. case XmlNodeType.XmlDeclaration:
  656. case XmlNodeType.DocumentType:
  657. return GetNextSibling (nx);
  658. default:
  659. return n.NextSibling;
  660. }
  661. } else {
  662. if (n.ParentNode == null || n.ParentNode.NodeType != XmlNodeType.EntityReference)
  663. return null;
  664. return GetNextSibling (n.ParentNode);
  665. }
  666. }
  667. private XmlNode GetParentNode (XmlNode n)
  668. {
  669. if (n.ParentNode == null)
  670. return null;
  671. for (XmlNode p = n.ParentNode; p != null; p = p.ParentNode)
  672. if (p.NodeType != XmlNodeType.EntityReference)
  673. return p;
  674. return null;
  675. }
  676. #if NET_2_0
  677. public
  678. #else
  679. internal
  680. #endif
  681. override string LookupNamespace (string prefix)
  682. {
  683. // FIXME: optimize
  684. return base.LookupNamespace (prefix);
  685. }
  686. #if NET_2_0
  687. public
  688. #else
  689. internal
  690. #endif
  691. override string LookupPrefix (string namespaceUri)
  692. {
  693. // FIXME: optimize
  694. return base.LookupPrefix (namespaceUri);
  695. }
  696. #if NET_2_0
  697. public
  698. #else
  699. internal
  700. #endif
  701. override bool MoveToChild (XPathNodeType type)
  702. {
  703. // FIXME: optimize
  704. return base.MoveToChild (type);
  705. }
  706. #if NET_2_0
  707. public
  708. #else
  709. internal
  710. #endif
  711. override bool MoveToChild (string localName, string namespaceURI)
  712. {
  713. // FIXME: optimize
  714. return base.MoveToChild (localName, namespaceURI);
  715. }
  716. #if NET_2_0
  717. public
  718. #else
  719. internal
  720. #endif
  721. override bool MoveToNext (string localName, string namespaceURI)
  722. {
  723. // FIXME: optimize
  724. return base.MoveToNext (localName, namespaceURI);
  725. }
  726. #if NET_2_0
  727. public
  728. #else
  729. internal
  730. #endif
  731. override bool MoveToNext (XPathNodeType type)
  732. {
  733. // FIXME: optimize
  734. return base.MoveToNext (type);
  735. }
  736. #if NET_2_0
  737. public
  738. #else
  739. internal
  740. #endif
  741. override bool MoveToFollowing (string localName,
  742. string namespaceURI, XPathNavigator end)
  743. {
  744. // FIXME: optimize
  745. return base.MoveToFollowing (localName, namespaceURI, end);
  746. }
  747. #if NET_2_0
  748. public
  749. #else
  750. internal
  751. #endif
  752. override bool MoveToFollowing (XPathNodeType type,
  753. XPathNavigator end)
  754. {
  755. // FIXME: optimize
  756. return base.MoveToFollowing (type, end);
  757. }
  758. #endregion
  759. }
  760. }