mscorlib(4.0.0.0) API with additions
XPathNavigator.cs
1 using MS.Internal.Xml.XPath;
2 using System.Collections;
4 using System.Diagnostics;
6 using System.IO;
7 using System.Text;
8 using System.Xml.Schema;
9 
10 namespace System.Xml.XPath
11 {
13  [DebuggerDisplay("{debuggerDisplayProxy}")]
15  {
16  private class CheckValidityHelper
17  {
18  private bool isValid;
19 
20  private ValidationEventHandler nextEventHandler;
21 
22  private XPathNavigatorReader reader;
23 
24  internal bool IsValid => isValid;
25 
26  internal CheckValidityHelper(ValidationEventHandler nextEventHandler, XPathNavigatorReader reader)
27  {
28  isValid = true;
29  this.nextEventHandler = nextEventHandler;
30  this.reader = reader;
31  }
32 
33  internal void ValidationCallback(object sender, ValidationEventArgs args)
34  {
35  if (args.Severity == XmlSeverityType.Error)
36  {
37  isValid = false;
38  }
40  if (ex != null && reader != null)
41  {
42  ex.SetSourceObject(reader.UnderlyingObject);
43  }
44  if (nextEventHandler != null)
45  {
46  nextEventHandler(sender, args);
47  }
48  else if (ex != null && args.Severity == XmlSeverityType.Error)
49  {
50  throw ex;
51  }
52  }
53  }
54 
55  [DebuggerDisplay("{ToString()}")]
56  internal struct DebuggerDisplayProxy
57  {
58  private XPathNavigator nav;
59 
60  public DebuggerDisplayProxy(XPathNavigator nav)
61  {
62  this.nav = nav;
63  }
64 
65  public override string ToString()
66  {
67  string text = nav.NodeType.ToString();
68  switch (nav.NodeType)
69  {
70  case XPathNodeType.Element:
71  text = text + ", Name=\"" + nav.Name + "\"";
72  break;
73  case XPathNodeType.Attribute:
74  case XPathNodeType.Namespace:
75  case XPathNodeType.ProcessingInstruction:
76  text = text + ", Name=\"" + nav.Name + "\"";
77  text = text + ", Value=\"" + XmlConvert.EscapeValueForDebuggerDisplay(nav.Value) + "\"";
78  break;
79  case XPathNodeType.Text:
80  case XPathNodeType.SignificantWhitespace:
81  case XPathNodeType.Whitespace:
82  case XPathNodeType.Comment:
83  text = text + ", Value=\"" + XmlConvert.EscapeValueForDebuggerDisplay(nav.Value) + "\"";
84  break;
85  }
86  return text;
87  }
88  }
89 
90  internal static readonly XPathNavigatorKeyComparer comparer = new XPathNavigatorKeyComparer();
91 
92  internal static readonly char[] NodeTypeLetter = new char[10]
93  {
94  'R',
95  'E',
96  'A',
97  'N',
98  'T',
99  'S',
100  'W',
101  'P',
102  'C',
103  'X'
104  };
105 
106  internal static readonly char[] UniqueIdTbl = new char[32]
107  {
108  'A',
109  'B',
110  'C',
111  'D',
112  'E',
113  'F',
114  'G',
115  'H',
116  'I',
117  'J',
118  'K',
119  'L',
120  'M',
121  'N',
122  'O',
123  'P',
124  'Q',
125  'R',
126  'S',
127  'T',
128  'U',
129  'V',
130  'W',
131  'X',
132  'Y',
133  'Z',
134  '1',
135  '2',
136  '3',
137  '4',
138  '5',
139  '6'
140  };
141 
142  internal const int AllMask = int.MaxValue;
143 
144  internal const int NoAttrNmspMask = 2147483635;
145 
146  internal const int TextMask = 112;
147 
148  internal static readonly int[] ContentKindMasks = new int[10]
149  {
150  1,
151  2,
152  0,
153  0,
154  112,
155  32,
156  64,
157  128,
158  256,
159  2147483635
160  };
161 
164  public sealed override bool IsNode => true;
165 
168  public override XmlSchemaType XmlType
169  {
170  get
171  {
172  IXmlSchemaInfo schemaInfo = SchemaInfo;
173  if (schemaInfo != null && schemaInfo.Validity == XmlSchemaValidity.Valid)
174  {
175  XmlSchemaType memberType = schemaInfo.MemberType;
176  if (memberType != null)
177  {
178  return memberType;
179  }
180  return schemaInfo.SchemaType;
181  }
182  return null;
183  }
184  }
185 
188  public override object TypedValue
189  {
190  get
191  {
192  IXmlSchemaInfo schemaInfo = SchemaInfo;
193  if (schemaInfo != null)
194  {
195  if (schemaInfo.Validity == XmlSchemaValidity.Valid)
196  {
197  XmlSchemaType xmlSchemaType = schemaInfo.MemberType;
198  if (xmlSchemaType == null)
199  {
200  xmlSchemaType = schemaInfo.SchemaType;
201  }
202  if (xmlSchemaType != null)
203  {
204  XmlSchemaDatatype datatype = xmlSchemaType.Datatype;
205  if (datatype != null)
206  {
207  return xmlSchemaType.ValueConverter.ChangeType(Value, datatype.ValueType, this);
208  }
209  }
210  }
211  else
212  {
213  XmlSchemaType xmlSchemaType = schemaInfo.SchemaType;
214  if (xmlSchemaType != null)
215  {
216  XmlSchemaDatatype datatype = xmlSchemaType.Datatype;
217  if (datatype != null)
218  {
219  return xmlSchemaType.ValueConverter.ChangeType(datatype.ParseValue(Value, NameTable, this), datatype.ValueType, this);
220  }
221  }
222  }
223  }
224  return Value;
225  }
226  }
227 
230  public override Type ValueType
231  {
232  get
233  {
234  IXmlSchemaInfo schemaInfo = SchemaInfo;
235  if (schemaInfo != null)
236  {
237  if (schemaInfo.Validity == XmlSchemaValidity.Valid)
238  {
239  XmlSchemaType xmlSchemaType = schemaInfo.MemberType;
240  if (xmlSchemaType == null)
241  {
242  xmlSchemaType = schemaInfo.SchemaType;
243  }
244  if (xmlSchemaType != null)
245  {
246  XmlSchemaDatatype datatype = xmlSchemaType.Datatype;
247  if (datatype != null)
248  {
249  return datatype.ValueType;
250  }
251  }
252  }
253  else
254  {
255  XmlSchemaType xmlSchemaType = schemaInfo.SchemaType;
256  if (xmlSchemaType != null)
257  {
258  XmlSchemaDatatype datatype = xmlSchemaType.Datatype;
259  if (datatype != null)
260  {
261  return datatype.ValueType;
262  }
263  }
264  }
265  }
266  return typeof(string);
267  }
268  }
269 
274  public override bool ValueAsBoolean
275  {
276  get
277  {
278  IXmlSchemaInfo schemaInfo = SchemaInfo;
279  if (schemaInfo != null)
280  {
281  if (schemaInfo.Validity == XmlSchemaValidity.Valid)
282  {
283  XmlSchemaType xmlSchemaType = schemaInfo.MemberType;
284  if (xmlSchemaType == null)
285  {
286  xmlSchemaType = schemaInfo.SchemaType;
287  }
288  if (xmlSchemaType != null)
289  {
290  return xmlSchemaType.ValueConverter.ToBoolean(Value);
291  }
292  }
293  else
294  {
295  XmlSchemaType xmlSchemaType = schemaInfo.SchemaType;
296  if (xmlSchemaType != null)
297  {
298  XmlSchemaDatatype datatype = xmlSchemaType.Datatype;
299  if (datatype != null)
300  {
301  return xmlSchemaType.ValueConverter.ToBoolean(datatype.ParseValue(Value, NameTable, this));
302  }
303  }
304  }
305  }
306  return XmlUntypedConverter.Untyped.ToBoolean(Value);
307  }
308  }
309 
314  public override DateTime ValueAsDateTime
315  {
316  get
317  {
318  IXmlSchemaInfo schemaInfo = SchemaInfo;
319  if (schemaInfo != null)
320  {
321  if (schemaInfo.Validity == XmlSchemaValidity.Valid)
322  {
323  XmlSchemaType xmlSchemaType = schemaInfo.MemberType;
324  if (xmlSchemaType == null)
325  {
326  xmlSchemaType = schemaInfo.SchemaType;
327  }
328  if (xmlSchemaType != null)
329  {
330  return xmlSchemaType.ValueConverter.ToDateTime(Value);
331  }
332  }
333  else
334  {
335  XmlSchemaType xmlSchemaType = schemaInfo.SchemaType;
336  if (xmlSchemaType != null)
337  {
338  XmlSchemaDatatype datatype = xmlSchemaType.Datatype;
339  if (datatype != null)
340  {
341  return xmlSchemaType.ValueConverter.ToDateTime(datatype.ParseValue(Value, NameTable, this));
342  }
343  }
344  }
345  }
346  return XmlUntypedConverter.Untyped.ToDateTime(Value);
347  }
348  }
349 
354  public override double ValueAsDouble
355  {
356  get
357  {
358  IXmlSchemaInfo schemaInfo = SchemaInfo;
359  if (schemaInfo != null)
360  {
361  if (schemaInfo.Validity == XmlSchemaValidity.Valid)
362  {
363  XmlSchemaType xmlSchemaType = schemaInfo.MemberType;
364  if (xmlSchemaType == null)
365  {
366  xmlSchemaType = schemaInfo.SchemaType;
367  }
368  if (xmlSchemaType != null)
369  {
370  return xmlSchemaType.ValueConverter.ToDouble(Value);
371  }
372  }
373  else
374  {
375  XmlSchemaType xmlSchemaType = schemaInfo.SchemaType;
376  if (xmlSchemaType != null)
377  {
378  XmlSchemaDatatype datatype = xmlSchemaType.Datatype;
379  if (datatype != null)
380  {
381  return xmlSchemaType.ValueConverter.ToDouble(datatype.ParseValue(Value, NameTable, this));
382  }
383  }
384  }
385  }
386  return XmlUntypedConverter.Untyped.ToDouble(Value);
387  }
388  }
389 
394  public override int ValueAsInt
395  {
396  get
397  {
398  IXmlSchemaInfo schemaInfo = SchemaInfo;
399  if (schemaInfo != null)
400  {
401  if (schemaInfo.Validity == XmlSchemaValidity.Valid)
402  {
403  XmlSchemaType xmlSchemaType = schemaInfo.MemberType;
404  if (xmlSchemaType == null)
405  {
406  xmlSchemaType = schemaInfo.SchemaType;
407  }
408  if (xmlSchemaType != null)
409  {
410  return xmlSchemaType.ValueConverter.ToInt32(Value);
411  }
412  }
413  else
414  {
415  XmlSchemaType xmlSchemaType = schemaInfo.SchemaType;
416  if (xmlSchemaType != null)
417  {
418  XmlSchemaDatatype datatype = xmlSchemaType.Datatype;
419  if (datatype != null)
420  {
421  return xmlSchemaType.ValueConverter.ToInt32(datatype.ParseValue(Value, NameTable, this));
422  }
423  }
424  }
425  }
426  return XmlUntypedConverter.Untyped.ToInt32(Value);
427  }
428  }
429 
434  public override long ValueAsLong
435  {
436  get
437  {
438  IXmlSchemaInfo schemaInfo = SchemaInfo;
439  if (schemaInfo != null)
440  {
441  if (schemaInfo.Validity == XmlSchemaValidity.Valid)
442  {
443  XmlSchemaType xmlSchemaType = schemaInfo.MemberType;
444  if (xmlSchemaType == null)
445  {
446  xmlSchemaType = schemaInfo.SchemaType;
447  }
448  if (xmlSchemaType != null)
449  {
450  return xmlSchemaType.ValueConverter.ToInt64(Value);
451  }
452  }
453  else
454  {
455  XmlSchemaType xmlSchemaType = schemaInfo.SchemaType;
456  if (xmlSchemaType != null)
457  {
458  XmlSchemaDatatype datatype = xmlSchemaType.Datatype;
459  if (datatype != null)
460  {
461  return xmlSchemaType.ValueConverter.ToInt64(datatype.ParseValue(Value, NameTable, this));
462  }
463  }
464  }
465  }
466  return XmlUntypedConverter.Untyped.ToInt64(Value);
467  }
468  }
469 
472  public abstract XmlNameTable NameTable
473  {
474  get;
475  }
476 
479  public static IEqualityComparer NavigatorComparer => comparer;
480 
483  public abstract XPathNodeType NodeType
484  {
485  get;
486  }
487 
490  public abstract string LocalName
491  {
492  get;
493  }
494 
497  public abstract string Name
498  {
499  get;
500  }
501 
504  public abstract string NamespaceURI
505  {
506  get;
507  }
508 
511  public abstract string Prefix
512  {
513  get;
514  }
515 
518  public abstract string BaseURI
519  {
520  get;
521  }
522 
526  public abstract bool IsEmptyElement
527  {
528  get;
529  }
530 
533  public virtual string XmlLang
534  {
535  get
536  {
537  XPathNavigator xPathNavigator = Clone();
538  do
539  {
540  if (xPathNavigator.MoveToAttribute("lang", "http://www.w3.org/XML/1998/namespace"))
541  {
542  return xPathNavigator.Value;
543  }
544  }
545  while (xPathNavigator.MoveToParent());
546  return string.Empty;
547  }
548  }
549 
552  public virtual object UnderlyingObject => null;
553 
556  public virtual bool HasAttributes
557  {
558  get
559  {
560  if (!MoveToFirstAttribute())
561  {
562  return false;
563  }
564  MoveToParent();
565  return true;
566  }
567  }
568 
572  public virtual bool HasChildren
573  {
574  get
575  {
576  if (MoveToFirstChild())
577  {
578  MoveToParent();
579  return true;
580  }
581  return false;
582  }
583  }
584 
587  public virtual IXmlSchemaInfo SchemaInfo => this as IXmlSchemaInfo;
588 
592  public virtual bool CanEdit => false;
593 
596  public virtual string OuterXml
597  {
598  get
599  {
600  if (NodeType == XPathNodeType.Attribute)
601  {
602  return Name + "=\"" + Value + "\"";
603  }
604  if (NodeType == XPathNodeType.Namespace)
605  {
606  if (LocalName.Length == 0)
607  {
608  return "xmlns=\"" + Value + "\"";
609  }
610  return "xmlns:" + LocalName + "=\"" + Value + "\"";
611  }
613  XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
614  xmlWriterSettings.Indent = true;
615  xmlWriterSettings.OmitXmlDeclaration = true;
616  xmlWriterSettings.ConformanceLevel = ConformanceLevel.Auto;
617  XmlWriter xmlWriter = XmlWriter.Create(stringWriter, xmlWriterSettings);
618  try
619  {
620  xmlWriter.WriteNode(this, defattr: true);
621  }
622  finally
623  {
624  xmlWriter.Close();
625  }
626  return stringWriter.ToString();
627  }
628  set
629  {
630  ReplaceSelf(value);
631  }
632  }
633 
637  public virtual string InnerXml
638  {
639  get
640  {
641  switch (NodeType)
642  {
643  case XPathNodeType.Root:
644  case XPathNodeType.Element:
645  {
647  XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
648  xmlWriterSettings.Indent = true;
649  xmlWriterSettings.OmitXmlDeclaration = true;
650  xmlWriterSettings.ConformanceLevel = ConformanceLevel.Auto;
651  XmlWriter xmlWriter = XmlWriter.Create(stringWriter, xmlWriterSettings);
652  try
653  {
654  if (MoveToFirstChild())
655  {
656  do
657  {
658  xmlWriter.WriteNode(this, defattr: true);
659  }
660  while (MoveToNext());
661  MoveToParent();
662  }
663  }
664  finally
665  {
666  xmlWriter.Close();
667  }
668  return stringWriter.ToString();
669  }
670  case XPathNodeType.Attribute:
671  case XPathNodeType.Namespace:
672  return Value;
673  default:
674  return string.Empty;
675  }
676  }
677  set
678  {
679  if (value == null)
680  {
681  throw new ArgumentNullException("value");
682  }
683  switch (NodeType)
684  {
685  case XPathNodeType.Root:
686  case XPathNodeType.Element:
687  {
688  XPathNavigator xPathNavigator = CreateNavigator();
689  while (xPathNavigator.MoveToFirstChild())
690  {
691  xPathNavigator.DeleteSelf();
692  }
693  if (value.Length != 0)
694  {
695  xPathNavigator.AppendChild(value);
696  }
697  break;
698  }
699  case XPathNodeType.Attribute:
700  SetValue(value);
701  break;
702  default:
703  throw new InvalidOperationException(Res.GetString("Xpn_BadPosition"));
704  }
705  }
706  }
707 
708  internal uint IndexInParent
709  {
710  get
711  {
712  XPathNavigator xPathNavigator = Clone();
713  uint num = 0u;
714  XPathNodeType nodeType = NodeType;
715  if (nodeType != XPathNodeType.Attribute)
716  {
717  if (nodeType == XPathNodeType.Namespace)
718  {
719  while (xPathNavigator.MoveToNextNamespace())
720  {
721  num++;
722  }
723  }
724  else
725  {
726  while (xPathNavigator.MoveToNext())
727  {
728  num++;
729  }
730  }
731  }
732  else
733  {
734  while (xPathNavigator.MoveToNextAttribute())
735  {
736  num++;
737  }
738  }
739  return num;
740  }
741  }
742 
743  internal virtual string UniqueId
744  {
745  get
746  {
747  XPathNavigator xPathNavigator = Clone();
748  StringBuilder stringBuilder = new StringBuilder();
749  stringBuilder.Append(NodeTypeLetter[(int)NodeType]);
750  while (true)
751  {
752  uint num = xPathNavigator.IndexInParent;
753  if (!xPathNavigator.MoveToParent())
754  {
755  break;
756  }
757  if (num <= 31)
758  {
759  stringBuilder.Append(UniqueIdTbl[num]);
760  continue;
761  }
762  stringBuilder.Append('0');
763  do
764  {
765  stringBuilder.Append(UniqueIdTbl[num & 0x1F]);
766  num >>= 5;
767  }
768  while (num != 0);
769  stringBuilder.Append('0');
770  }
771  return stringBuilder.ToString();
772  }
773  }
774 
775  private object debuggerDisplayProxy => new DebuggerDisplayProxy(this);
776 
779  public override string ToString()
780  {
781  return Value;
782  }
783 
789  public virtual void SetValue(string value)
790  {
791  throw new NotSupportedException();
792  }
793 
800  public virtual void SetTypedValue(object typedValue)
801  {
802  if (typedValue == null)
803  {
804  throw new ArgumentNullException("typedValue");
805  }
806  XPathNodeType nodeType = NodeType;
807  if (nodeType != XPathNodeType.Element && nodeType != XPathNodeType.Attribute)
808  {
809  throw new InvalidOperationException(Res.GetString("Xpn_BadPosition"));
810  }
811  string text = null;
812  IXmlSchemaInfo schemaInfo = SchemaInfo;
813  if (schemaInfo != null)
814  {
815  XmlSchemaType schemaType = schemaInfo.SchemaType;
816  if (schemaType != null)
817  {
818  text = schemaType.ValueConverter.ToString(typedValue, this);
819  schemaType.Datatype?.ParseValue(text, NameTable, this);
820  }
821  }
822  if (text == null)
823  {
824  text = XmlUntypedConverter.Untyped.ToString(typedValue, this);
825  }
826  SetValue(text);
827  }
828 
835  public override object ValueAs(Type returnType, IXmlNamespaceResolver nsResolver)
836  {
837  if (nsResolver == null)
838  {
839  nsResolver = this;
840  }
841  IXmlSchemaInfo schemaInfo = SchemaInfo;
842  if (schemaInfo != null)
843  {
844  if (schemaInfo.Validity == XmlSchemaValidity.Valid)
845  {
846  XmlSchemaType xmlSchemaType = schemaInfo.MemberType;
847  if (xmlSchemaType == null)
848  {
849  xmlSchemaType = schemaInfo.SchemaType;
850  }
851  if (xmlSchemaType != null)
852  {
853  return xmlSchemaType.ValueConverter.ChangeType(Value, returnType, nsResolver);
854  }
855  }
856  else
857  {
858  XmlSchemaType xmlSchemaType = schemaInfo.SchemaType;
859  if (xmlSchemaType != null)
860  {
861  XmlSchemaDatatype datatype = xmlSchemaType.Datatype;
862  if (datatype != null)
863  {
864  return xmlSchemaType.ValueConverter.ChangeType(datatype.ParseValue(Value, NameTable, nsResolver), returnType, nsResolver);
865  }
866  }
867  }
868  }
869  return XmlUntypedConverter.Untyped.ChangeType(Value, returnType, nsResolver);
870  }
871 
874  object ICloneable.Clone()
875  {
876  return Clone();
877  }
878 
882  {
883  return Clone();
884  }
885 
889  public virtual string LookupNamespace(string prefix)
890  {
891  if (prefix == null)
892  {
893  return null;
894  }
895  if (NodeType != XPathNodeType.Element)
896  {
897  XPathNavigator xPathNavigator = Clone();
898  if (xPathNavigator.MoveToParent())
899  {
900  return xPathNavigator.LookupNamespace(prefix);
901  }
902  }
903  else if (MoveToNamespace(prefix))
904  {
905  string value = Value;
906  MoveToParent();
907  return value;
908  }
909  if (prefix.Length == 0)
910  {
911  return string.Empty;
912  }
913  if (prefix == "xml")
914  {
915  return "http://www.w3.org/XML/1998/namespace";
916  }
917  if (prefix == "xmlns")
918  {
919  return "http://www.w3.org/2000/xmlns/";
920  }
921  return null;
922  }
923 
927  public virtual string LookupPrefix(string namespaceURI)
928  {
929  if (namespaceURI == null)
930  {
931  return null;
932  }
933  XPathNavigator xPathNavigator = Clone();
934  if (NodeType != XPathNodeType.Element)
935  {
936  if (xPathNavigator.MoveToParent())
937  {
938  return xPathNavigator.LookupPrefix(namespaceURI);
939  }
940  }
941  else if (xPathNavigator.MoveToFirstNamespace(XPathNamespaceScope.All))
942  {
943  do
944  {
945  if (namespaceURI == xPathNavigator.Value)
946  {
947  return xPathNavigator.LocalName;
948  }
949  }
950  while (xPathNavigator.MoveToNextNamespace(XPathNamespaceScope.All));
951  }
952  if (namespaceURI == LookupNamespace(string.Empty))
953  {
954  return string.Empty;
955  }
956  if (namespaceURI == "http://www.w3.org/XML/1998/namespace")
957  {
958  return "xml";
959  }
960  if (namespaceURI == "http://www.w3.org/2000/xmlns/")
961  {
962  return "xmlns";
963  }
964  return null;
965  }
966 
971  {
972  XPathNodeType nodeType = NodeType;
973  if ((nodeType != XPathNodeType.Element && scope != XmlNamespaceScope.Local) || nodeType == XPathNodeType.Attribute || nodeType == XPathNodeType.Namespace)
974  {
975  XPathNavigator xPathNavigator = Clone();
976  if (xPathNavigator.MoveToParent())
977  {
978  return xPathNavigator.GetNamespacesInScope(scope);
979  }
980  }
982  if (scope == XmlNamespaceScope.All)
983  {
984  dictionary["xml"] = "http://www.w3.org/XML/1998/namespace";
985  }
987  {
988  do
989  {
990  string localName = LocalName;
991  string value = Value;
992  if (localName.Length != 0 || value.Length != 0 || scope == XmlNamespaceScope.Local)
993  {
994  dictionary[localName] = value;
995  }
996  }
998  MoveToParent();
999  }
1000  return dictionary;
1001  }
1002 
1005  public abstract XPathNavigator Clone();
1006 
1010  public virtual XmlReader ReadSubtree()
1011  {
1012  XPathNodeType nodeType = NodeType;
1013  if (nodeType != 0 && nodeType != XPathNodeType.Element)
1014  {
1015  throw new InvalidOperationException(Res.GetString("Xpn_BadPosition"));
1016  }
1017  return CreateReader();
1018  }
1019 
1022  public virtual void WriteSubtree(XmlWriter writer)
1023  {
1024  if (writer == null)
1025  {
1026  throw new ArgumentNullException("writer");
1027  }
1028  writer.WriteNode(this, defattr: true);
1029  }
1030 
1035  public virtual string GetAttribute(string localName, string namespaceURI)
1036  {
1037  if (!MoveToAttribute(localName, namespaceURI))
1038  {
1039  return "";
1040  }
1041  string value = Value;
1042  MoveToParent();
1043  return value;
1044  }
1045 
1050  public virtual bool MoveToAttribute(string localName, string namespaceURI)
1051  {
1052  if (MoveToFirstAttribute())
1053  {
1054  do
1055  {
1056  if (localName == LocalName && namespaceURI == NamespaceURI)
1057  {
1058  return true;
1059  }
1060  }
1061  while (MoveToNextAttribute());
1062  MoveToParent();
1063  }
1064  return false;
1065  }
1066 
1069  public abstract bool MoveToFirstAttribute();
1070 
1073  public abstract bool MoveToNextAttribute();
1074 
1078  public virtual string GetNamespace(string name)
1079  {
1080  if (!MoveToNamespace(name))
1081  {
1082  if (name == "xml")
1083  {
1084  return "http://www.w3.org/XML/1998/namespace";
1085  }
1086  if (name == "xmlns")
1087  {
1088  return "http://www.w3.org/2000/xmlns/";
1089  }
1090  return string.Empty;
1091  }
1092  string value = Value;
1093  MoveToParent();
1094  return value;
1095  }
1096 
1101  public virtual bool MoveToNamespace(string name)
1102  {
1104  {
1105  do
1106  {
1107  if (name == LocalName)
1108  {
1109  return true;
1110  }
1111  }
1113  MoveToParent();
1114  }
1115  return false;
1116  }
1117 
1121  public abstract bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope);
1122 
1126  public abstract bool MoveToNextNamespace(XPathNamespaceScope namespaceScope);
1127 
1130  public bool MoveToFirstNamespace()
1131  {
1133  }
1134 
1137  public bool MoveToNextNamespace()
1138  {
1140  }
1141 
1145  public abstract bool MoveToNext();
1146 
1149  public abstract bool MoveToPrevious();
1150 
1153  public virtual bool MoveToFirst()
1154  {
1155  XPathNodeType nodeType = NodeType;
1156  if (nodeType == XPathNodeType.Attribute || nodeType == XPathNodeType.Namespace)
1157  {
1158  return false;
1159  }
1160  if (!MoveToParent())
1161  {
1162  return false;
1163  }
1164  return MoveToFirstChild();
1165  }
1166 
1169  public abstract bool MoveToFirstChild();
1170 
1173  public abstract bool MoveToParent();
1174 
1176  public virtual void MoveToRoot()
1177  {
1178  while (MoveToParent())
1179  {
1180  }
1181  }
1182 
1186  public abstract bool MoveTo(XPathNavigator other);
1187 
1192  public abstract bool MoveToId(string id);
1193 
1198  public virtual bool MoveToChild(string localName, string namespaceURI)
1199  {
1200  if (MoveToFirstChild())
1201  {
1202  do
1203  {
1204  if (NodeType == XPathNodeType.Element && localName == LocalName && namespaceURI == NamespaceURI)
1205  {
1206  return true;
1207  }
1208  }
1209  while (MoveToNext());
1210  MoveToParent();
1211  }
1212  return false;
1213  }
1214 
1218  public virtual bool MoveToChild(XPathNodeType type)
1219  {
1220  if (MoveToFirstChild())
1221  {
1222  int contentKindMask = GetContentKindMask(type);
1223  do
1224  {
1225  if (((1 << (int)NodeType) & contentKindMask) != 0)
1226  {
1227  return true;
1228  }
1229  }
1230  while (MoveToNext());
1231  MoveToParent();
1232  }
1233  return false;
1234  }
1235 
1241  public virtual bool MoveToFollowing(string localName, string namespaceURI)
1242  {
1243  return MoveToFollowing(localName, namespaceURI, null);
1244  }
1245 
1252  public virtual bool MoveToFollowing(string localName, string namespaceURI, XPathNavigator end)
1253  {
1254  XPathNavigator other = Clone();
1255  XPathNodeType nodeType;
1256  if (end != null)
1257  {
1258  nodeType = end.NodeType;
1259  if (nodeType == XPathNodeType.Attribute || nodeType == XPathNodeType.Namespace)
1260  {
1261  end = end.Clone();
1262  end.MoveToNonDescendant();
1263  }
1264  }
1265  nodeType = NodeType;
1266  if ((nodeType == XPathNodeType.Attribute || nodeType == XPathNodeType.Namespace) && !MoveToParent())
1267  {
1268  return false;
1269  }
1270  do
1271  {
1272  if (!MoveToFirstChild())
1273  {
1274  while (!MoveToNext())
1275  {
1276  if (!MoveToParent())
1277  {
1278  MoveTo(other);
1279  return false;
1280  }
1281  }
1282  }
1283  if (end != null && IsSamePosition(end))
1284  {
1285  MoveTo(other);
1286  return false;
1287  }
1288  }
1289  while (NodeType != XPathNodeType.Element || localName != LocalName || namespaceURI != NamespaceURI);
1290  return true;
1291  }
1292 
1297  public virtual bool MoveToFollowing(XPathNodeType type)
1298  {
1299  return MoveToFollowing(type, null);
1300  }
1301 
1307  public virtual bool MoveToFollowing(XPathNodeType type, XPathNavigator end)
1308  {
1309  XPathNavigator other = Clone();
1310  int contentKindMask = GetContentKindMask(type);
1311  XPathNodeType nodeType;
1312  if (end != null)
1313  {
1314  nodeType = end.NodeType;
1315  if (nodeType == XPathNodeType.Attribute || nodeType == XPathNodeType.Namespace)
1316  {
1317  end = end.Clone();
1318  end.MoveToNonDescendant();
1319  }
1320  }
1321  nodeType = NodeType;
1322  if ((nodeType == XPathNodeType.Attribute || nodeType == XPathNodeType.Namespace) && !MoveToParent())
1323  {
1324  return false;
1325  }
1326  do
1327  {
1328  if (!MoveToFirstChild())
1329  {
1330  while (!MoveToNext())
1331  {
1332  if (!MoveToParent())
1333  {
1334  MoveTo(other);
1335  return false;
1336  }
1337  }
1338  }
1339  if (end != null && IsSamePosition(end))
1340  {
1341  MoveTo(other);
1342  return false;
1343  }
1344  }
1345  while (((1 << (int)NodeType) & contentKindMask) == 0);
1346  return true;
1347  }
1348 
1353  public virtual bool MoveToNext(string localName, string namespaceURI)
1354  {
1355  XPathNavigator other = Clone();
1356  while (MoveToNext())
1357  {
1358  if (NodeType == XPathNodeType.Element && localName == LocalName && namespaceURI == NamespaceURI)
1359  {
1360  return true;
1361  }
1362  }
1363  MoveTo(other);
1364  return false;
1365  }
1366 
1371  public virtual bool MoveToNext(XPathNodeType type)
1372  {
1373  XPathNavigator other = Clone();
1374  int contentKindMask = GetContentKindMask(type);
1375  while (MoveToNext())
1376  {
1377  if (((1 << (int)NodeType) & contentKindMask) != 0)
1378  {
1379  return true;
1380  }
1381  }
1382  MoveTo(other);
1383  return false;
1384  }
1385 
1390  public abstract bool IsSamePosition(XPathNavigator other);
1391 
1396  public virtual bool IsDescendant(XPathNavigator nav)
1397  {
1398  if (nav != null)
1399  {
1400  nav = nav.Clone();
1401  while (nav.MoveToParent())
1402  {
1403  if (nav.IsSamePosition(this))
1404  {
1405  return true;
1406  }
1407  }
1408  }
1409  return false;
1410  }
1411 
1416  {
1417  if (nav == null)
1418  {
1419  return XmlNodeOrder.Unknown;
1420  }
1421  if (IsSamePosition(nav))
1422  {
1423  return XmlNodeOrder.Same;
1424  }
1425  XPathNavigator xPathNavigator = Clone();
1426  XPathNavigator xPathNavigator2 = nav.Clone();
1427  int num = GetDepth(xPathNavigator.Clone());
1428  int num2 = GetDepth(xPathNavigator2.Clone());
1429  if (num > num2)
1430  {
1431  while (num > num2)
1432  {
1433  xPathNavigator.MoveToParent();
1434  num--;
1435  }
1436  if (xPathNavigator.IsSamePosition(xPathNavigator2))
1437  {
1438  return XmlNodeOrder.After;
1439  }
1440  }
1441  if (num2 > num)
1442  {
1443  while (num2 > num)
1444  {
1445  xPathNavigator2.MoveToParent();
1446  num2--;
1447  }
1448  if (xPathNavigator.IsSamePosition(xPathNavigator2))
1449  {
1450  return XmlNodeOrder.Before;
1451  }
1452  }
1453  XPathNavigator xPathNavigator3 = xPathNavigator.Clone();
1454  XPathNavigator xPathNavigator4 = xPathNavigator2.Clone();
1455  while (true)
1456  {
1457  if (!xPathNavigator3.MoveToParent() || !xPathNavigator4.MoveToParent())
1458  {
1459  return XmlNodeOrder.Unknown;
1460  }
1461  if (xPathNavigator3.IsSamePosition(xPathNavigator4))
1462  {
1463  break;
1464  }
1465  xPathNavigator.MoveToParent();
1466  xPathNavigator2.MoveToParent();
1467  }
1468  bool flag = xPathNavigator.GetType().ToString() != "Microsoft.VisualStudio.Modeling.StoreNavigator";
1469  return CompareSiblings(xPathNavigator, xPathNavigator2);
1470  }
1471 
1480  public virtual bool CheckValidity(XmlSchemaSet schemas, ValidationEventHandler validationEventHandler)
1481  {
1482  XmlSchemaType xmlSchemaType = null;
1483  XmlSchemaElement xmlSchemaElement = null;
1484  XmlSchemaAttribute xmlSchemaAttribute = null;
1485  switch (NodeType)
1486  {
1487  case XPathNodeType.Root:
1488  if (schemas == null)
1489  {
1490  throw new InvalidOperationException(Res.GetString("XPathDocument_MissingSchemas"));
1491  }
1492  xmlSchemaType = null;
1493  break;
1494  case XPathNodeType.Element:
1495  {
1496  if (schemas == null)
1497  {
1498  throw new InvalidOperationException(Res.GetString("XPathDocument_MissingSchemas"));
1499  }
1500  IXmlSchemaInfo schemaInfo = SchemaInfo;
1501  if (schemaInfo != null)
1502  {
1503  xmlSchemaType = schemaInfo.SchemaType;
1504  xmlSchemaElement = schemaInfo.SchemaElement;
1505  }
1506  if (xmlSchemaType == null && xmlSchemaElement == null)
1507  {
1508  throw new InvalidOperationException(Res.GetString("XPathDocument_NotEnoughSchemaInfo", null));
1509  }
1510  break;
1511  }
1512  case XPathNodeType.Attribute:
1513  {
1514  if (schemas == null)
1515  {
1516  throw new InvalidOperationException(Res.GetString("XPathDocument_MissingSchemas"));
1517  }
1518  IXmlSchemaInfo schemaInfo = SchemaInfo;
1519  if (schemaInfo != null)
1520  {
1521  xmlSchemaType = schemaInfo.SchemaType;
1522  xmlSchemaAttribute = schemaInfo.SchemaAttribute;
1523  }
1524  if (xmlSchemaType == null && xmlSchemaAttribute == null)
1525  {
1526  throw new InvalidOperationException(Res.GetString("XPathDocument_NotEnoughSchemaInfo", null));
1527  }
1528  break;
1529  }
1530  default:
1531  throw new InvalidOperationException(Res.GetString("XPathDocument_ValidateInvalidNodeType", null));
1532  }
1533  XmlReader xmlReader = CreateReader();
1534  CheckValidityHelper checkValidityHelper = new CheckValidityHelper(validationEventHandler, xmlReader as XPathNavigatorReader);
1535  validationEventHandler = checkValidityHelper.ValidationCallback;
1536  XmlReader validatingReader = GetValidatingReader(xmlReader, schemas, validationEventHandler, xmlSchemaType, xmlSchemaElement, xmlSchemaAttribute);
1537  while (validatingReader.Read())
1538  {
1539  }
1540  return checkValidityHelper.IsValid;
1541  }
1542 
1543  private XmlReader GetValidatingReader(XmlReader reader, XmlSchemaSet schemas, ValidationEventHandler validationEvent, XmlSchemaType schemaType, XmlSchemaElement schemaElement, XmlSchemaAttribute schemaAttribute)
1544  {
1545  if (schemaAttribute != null)
1546  {
1547  return schemaAttribute.Validate(reader, null, schemas, validationEvent);
1548  }
1549  if (schemaElement != null)
1550  {
1551  return schemaElement.Validate(reader, null, schemas, validationEvent);
1552  }
1553  if (schemaType != null)
1554  {
1555  return schemaType.Validate(reader, null, schemas, validationEvent);
1556  }
1557  XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
1558  xmlReaderSettings.ConformanceLevel = ConformanceLevel.Auto;
1559  xmlReaderSettings.ValidationType = ValidationType.Schema;
1560  xmlReaderSettings.Schemas = schemas;
1561  xmlReaderSettings.ValidationEventHandler += validationEvent;
1562  return XmlReader.Create(reader, xmlReaderSettings);
1563  }
1564 
1570  public virtual XPathExpression Compile(string xpath)
1571  {
1572  return XPathExpression.Compile(xpath);
1573  }
1574 
1580  public virtual XPathNavigator SelectSingleNode(string xpath)
1581  {
1582  return SelectSingleNode(XPathExpression.Compile(xpath));
1583  }
1584 
1591  public virtual XPathNavigator SelectSingleNode(string xpath, IXmlNamespaceResolver resolver)
1592  {
1593  return SelectSingleNode(XPathExpression.Compile(xpath, resolver));
1594  }
1595 
1602  {
1603  XPathNodeIterator xPathNodeIterator = Select(expression);
1604  if (xPathNodeIterator.MoveNext())
1605  {
1606  return xPathNodeIterator.Current;
1607  }
1608  return null;
1609  }
1610 
1616  public virtual XPathNodeIterator Select(string xpath)
1617  {
1618  return Select(XPathExpression.Compile(xpath));
1619  }
1620 
1627  public virtual XPathNodeIterator Select(string xpath, IXmlNamespaceResolver resolver)
1628  {
1629  return Select(XPathExpression.Compile(xpath, resolver));
1630  }
1631 
1638  {
1639  XPathNodeIterator xPathNodeIterator = Evaluate(expr) as XPathNodeIterator;
1640  if (xPathNodeIterator == null)
1641  {
1642  throw XPathException.Create("Xp_NodeSetExpected");
1643  }
1644  return xPathNodeIterator;
1645  }
1646 
1652  public virtual object Evaluate(string xpath)
1653  {
1654  return Evaluate(XPathExpression.Compile(xpath), null);
1655  }
1656 
1663  public virtual object Evaluate(string xpath, IXmlNamespaceResolver resolver)
1664  {
1665  return Evaluate(XPathExpression.Compile(xpath, resolver));
1666  }
1667 
1673  public virtual object Evaluate(XPathExpression expr)
1674  {
1675  return Evaluate(expr, null);
1676  }
1677 
1684  public virtual object Evaluate(XPathExpression expr, XPathNodeIterator context)
1685  {
1686  CompiledXpathExpr compiledXpathExpr = expr as CompiledXpathExpr;
1687  if (compiledXpathExpr == null)
1688  {
1689  throw XPathException.Create("Xp_BadQueryObject");
1690  }
1691  Query query = Query.Clone(compiledXpathExpr.QueryTree);
1692  query.Reset();
1693  if (context == null)
1694  {
1695  context = new XPathSingletonIterator(Clone(), moved: true);
1696  }
1697  object obj = query.Evaluate(context);
1698  if (obj is XPathNodeIterator)
1699  {
1700  return new XPathSelectionIterator(context.Current, query);
1701  }
1702  return obj;
1703  }
1704 
1711  public virtual bool Matches(XPathExpression expr)
1712  {
1713  CompiledXpathExpr compiledXpathExpr = expr as CompiledXpathExpr;
1714  if (compiledXpathExpr == null)
1715  {
1716  throw XPathException.Create("Xp_BadQueryObject");
1717  }
1718  Query query = Query.Clone(compiledXpathExpr.QueryTree);
1719  try
1720  {
1721  return query.MatchNode(this) != null;
1722  }
1723  catch (XPathException)
1724  {
1725  throw XPathException.Create("Xp_InvalidPattern", compiledXpathExpr.Expression);
1726  }
1727  }
1728 
1735  public virtual bool Matches(string xpath)
1736  {
1737  return Matches(CompileMatchPattern(xpath));
1738  }
1739 
1744  {
1745  return new XPathChildIterator(Clone(), type);
1746  }
1747 
1754  public virtual XPathNodeIterator SelectChildren(string name, string namespaceURI)
1755  {
1756  return new XPathChildIterator(Clone(), name, namespaceURI);
1757  }
1758 
1763  public virtual XPathNodeIterator SelectAncestors(XPathNodeType type, bool matchSelf)
1764  {
1765  return new XPathAncestorIterator(Clone(), type, matchSelf);
1766  }
1767 
1775  public virtual XPathNodeIterator SelectAncestors(string name, string namespaceURI, bool matchSelf)
1776  {
1777  return new XPathAncestorIterator(Clone(), name, namespaceURI, matchSelf);
1778  }
1779 
1785  public virtual XPathNodeIterator SelectDescendants(XPathNodeType type, bool matchSelf)
1786  {
1787  return new XPathDescendantIterator(Clone(), type, matchSelf);
1788  }
1789 
1798  public virtual XPathNodeIterator SelectDescendants(string name, string namespaceURI, bool matchSelf)
1799  {
1800  return new XPathDescendantIterator(Clone(), name, namespaceURI, matchSelf);
1801  }
1802 
1807  public virtual XmlWriter PrependChild()
1808  {
1809  throw new NotSupportedException();
1810  }
1811 
1816  public virtual XmlWriter AppendChild()
1817  {
1818  throw new NotSupportedException();
1819  }
1820 
1825  public virtual XmlWriter InsertAfter()
1826  {
1827  throw new NotSupportedException();
1828  }
1829 
1834  public virtual XmlWriter InsertBefore()
1835  {
1836  throw new NotSupportedException();
1837  }
1838 
1843  public virtual XmlWriter CreateAttributes()
1844  {
1845  throw new NotSupportedException();
1846  }
1847 
1854  public virtual XmlWriter ReplaceRange(XPathNavigator lastSiblingToReplace)
1855  {
1856  throw new NotSupportedException();
1857  }
1858 
1865  public virtual void ReplaceSelf(string newNode)
1866  {
1867  XmlReader newNode2 = CreateContextReader(newNode, fromCurrentNode: false);
1868  ReplaceSelf(newNode2);
1869  }
1870 
1878  public virtual void ReplaceSelf(XmlReader newNode)
1879  {
1880  if (newNode == null)
1881  {
1882  throw new ArgumentNullException("newNode");
1883  }
1884  XPathNodeType nodeType = NodeType;
1885  if (nodeType == XPathNodeType.Root || nodeType == XPathNodeType.Attribute || nodeType == XPathNodeType.Namespace)
1886  {
1887  throw new InvalidOperationException(Res.GetString("Xpn_BadPosition"));
1888  }
1889  XmlWriter xmlWriter = ReplaceRange(this);
1890  BuildSubtree(newNode, xmlWriter);
1891  xmlWriter.Close();
1892  }
1893 
1900  public virtual void ReplaceSelf(XPathNavigator newNode)
1901  {
1902  if (newNode == null)
1903  {
1904  throw new ArgumentNullException("newNode");
1905  }
1906  XmlReader newNode2 = newNode.CreateReader();
1907  ReplaceSelf(newNode2);
1908  }
1909 
1916  public virtual void AppendChild(string newChild)
1917  {
1918  XmlReader newChild2 = CreateContextReader(newChild, fromCurrentNode: true);
1919  AppendChild(newChild2);
1920  }
1921 
1929  public virtual void AppendChild(XmlReader newChild)
1930  {
1931  if (newChild == null)
1932  {
1933  throw new ArgumentNullException("newChild");
1934  }
1935  XmlWriter xmlWriter = AppendChild();
1936  BuildSubtree(newChild, xmlWriter);
1937  xmlWriter.Close();
1938  }
1939 
1945  public virtual void AppendChild(XPathNavigator newChild)
1946  {
1947  if (newChild == null)
1948  {
1949  throw new ArgumentNullException("newChild");
1950  }
1951  if (!IsValidChildType(newChild.NodeType))
1952  {
1953  throw new InvalidOperationException(Res.GetString("Xpn_BadPosition"));
1954  }
1955  XmlReader newChild2 = newChild.CreateReader();
1956  AppendChild(newChild2);
1957  }
1958 
1965  public virtual void PrependChild(string newChild)
1966  {
1967  XmlReader newChild2 = CreateContextReader(newChild, fromCurrentNode: true);
1968  PrependChild(newChild2);
1969  }
1970 
1978  public virtual void PrependChild(XmlReader newChild)
1979  {
1980  if (newChild == null)
1981  {
1982  throw new ArgumentNullException("newChild");
1983  }
1984  XmlWriter xmlWriter = PrependChild();
1985  BuildSubtree(newChild, xmlWriter);
1986  xmlWriter.Close();
1987  }
1988 
1994  public virtual void PrependChild(XPathNavigator newChild)
1995  {
1996  if (newChild == null)
1997  {
1998  throw new ArgumentNullException("newChild");
1999  }
2000  if (!IsValidChildType(newChild.NodeType))
2001  {
2002  throw new InvalidOperationException(Res.GetString("Xpn_BadPosition"));
2003  }
2004  XmlReader newChild2 = newChild.CreateReader();
2005  PrependChild(newChild2);
2006  }
2007 
2014  public virtual void InsertBefore(string newSibling)
2015  {
2016  XmlReader newSibling2 = CreateContextReader(newSibling, fromCurrentNode: false);
2017  InsertBefore(newSibling2);
2018  }
2019 
2027  public virtual void InsertBefore(XmlReader newSibling)
2028  {
2029  if (newSibling == null)
2030  {
2031  throw new ArgumentNullException("newSibling");
2032  }
2033  XmlWriter xmlWriter = InsertBefore();
2034  BuildSubtree(newSibling, xmlWriter);
2035  xmlWriter.Close();
2036  }
2037 
2043  public virtual void InsertBefore(XPathNavigator newSibling)
2044  {
2045  if (newSibling == null)
2046  {
2047  throw new ArgumentNullException("newSibling");
2048  }
2049  if (!IsValidSiblingType(newSibling.NodeType))
2050  {
2051  throw new InvalidOperationException(Res.GetString("Xpn_BadPosition"));
2052  }
2053  XmlReader newSibling2 = newSibling.CreateReader();
2054  InsertBefore(newSibling2);
2055  }
2056 
2063  public virtual void InsertAfter(string newSibling)
2064  {
2065  XmlReader newSibling2 = CreateContextReader(newSibling, fromCurrentNode: false);
2066  InsertAfter(newSibling2);
2067  }
2068 
2076  public virtual void InsertAfter(XmlReader newSibling)
2077  {
2078  if (newSibling == null)
2079  {
2080  throw new ArgumentNullException("newSibling");
2081  }
2082  XmlWriter xmlWriter = InsertAfter();
2083  BuildSubtree(newSibling, xmlWriter);
2084  xmlWriter.Close();
2085  }
2086 
2092  public virtual void InsertAfter(XPathNavigator newSibling)
2093  {
2094  if (newSibling == null)
2095  {
2096  throw new ArgumentNullException("newSibling");
2097  }
2098  if (!IsValidSiblingType(newSibling.NodeType))
2099  {
2100  throw new InvalidOperationException(Res.GetString("Xpn_BadPosition"));
2101  }
2102  XmlReader newSibling2 = newSibling.CreateReader();
2103  InsertAfter(newSibling2);
2104  }
2105 
2111  public virtual void DeleteRange(XPathNavigator lastSiblingToDelete)
2112  {
2113  throw new NotSupportedException();
2114  }
2115 
2119  public virtual void DeleteSelf()
2120  {
2121  DeleteRange(this);
2122  }
2123 
2131  public virtual void PrependChildElement(string prefix, string localName, string namespaceURI, string value)
2132  {
2133  XmlWriter xmlWriter = PrependChild();
2134  xmlWriter.WriteStartElement(prefix, localName, namespaceURI);
2135  if (value != null)
2136  {
2137  xmlWriter.WriteString(value);
2138  }
2139  xmlWriter.WriteEndElement();
2140  xmlWriter.Close();
2141  }
2142 
2150  public virtual void AppendChildElement(string prefix, string localName, string namespaceURI, string value)
2151  {
2152  XmlWriter xmlWriter = AppendChild();
2153  xmlWriter.WriteStartElement(prefix, localName, namespaceURI);
2154  if (value != null)
2155  {
2156  xmlWriter.WriteString(value);
2157  }
2158  xmlWriter.WriteEndElement();
2159  xmlWriter.Close();
2160  }
2161 
2169  public virtual void InsertElementBefore(string prefix, string localName, string namespaceURI, string value)
2170  {
2171  XmlWriter xmlWriter = InsertBefore();
2172  xmlWriter.WriteStartElement(prefix, localName, namespaceURI);
2173  if (value != null)
2174  {
2175  xmlWriter.WriteString(value);
2176  }
2177  xmlWriter.WriteEndElement();
2178  xmlWriter.Close();
2179  }
2180 
2188  public virtual void InsertElementAfter(string prefix, string localName, string namespaceURI, string value)
2189  {
2190  XmlWriter xmlWriter = InsertAfter();
2191  xmlWriter.WriteStartElement(prefix, localName, namespaceURI);
2192  if (value != null)
2193  {
2194  xmlWriter.WriteString(value);
2195  }
2196  xmlWriter.WriteEndElement();
2197  xmlWriter.Close();
2198  }
2199 
2207  public virtual void CreateAttribute(string prefix, string localName, string namespaceURI, string value)
2208  {
2209  XmlWriter xmlWriter = CreateAttributes();
2210  xmlWriter.WriteStartAttribute(prefix, localName, namespaceURI);
2211  if (value != null)
2212  {
2213  xmlWriter.WriteString(value);
2214  }
2215  xmlWriter.WriteEndAttribute();
2216  xmlWriter.Close();
2217  }
2218 
2219  internal bool MoveToPrevious(string localName, string namespaceURI)
2220  {
2221  XPathNavigator other = Clone();
2222  localName = ((localName != null) ? NameTable.Get(localName) : null);
2223  while (MoveToPrevious())
2224  {
2225  if (NodeType == XPathNodeType.Element && (object)localName == LocalName && namespaceURI == NamespaceURI)
2226  {
2227  return true;
2228  }
2229  }
2230  MoveTo(other);
2231  return false;
2232  }
2233 
2234  internal bool MoveToPrevious(XPathNodeType type)
2235  {
2236  XPathNavigator other = Clone();
2237  int contentKindMask = GetContentKindMask(type);
2238  while (MoveToPrevious())
2239  {
2240  if (((1 << (int)NodeType) & contentKindMask) != 0)
2241  {
2242  return true;
2243  }
2244  }
2245  MoveTo(other);
2246  return false;
2247  }
2248 
2249  internal bool MoveToNonDescendant()
2250  {
2251  if (NodeType == XPathNodeType.Root)
2252  {
2253  return false;
2254  }
2255  if (MoveToNext())
2256  {
2257  return true;
2258  }
2259  XPathNavigator xPathNavigator = Clone();
2260  if (!MoveToParent())
2261  {
2262  return false;
2263  }
2264  XPathNodeType nodeType = xPathNavigator.NodeType;
2265  if ((nodeType == XPathNodeType.Attribute || nodeType == XPathNodeType.Namespace) && MoveToFirstChild())
2266  {
2267  return true;
2268  }
2269  while (!MoveToNext())
2270  {
2271  if (!MoveToParent())
2272  {
2273  MoveTo(xPathNavigator);
2274  return false;
2275  }
2276  }
2277  return true;
2278  }
2279 
2280  private static XPathExpression CompileMatchPattern(string xpath)
2281  {
2282  bool needContext;
2283  Query query = new QueryBuilder().BuildPatternQuery(xpath, out needContext);
2284  return new CompiledXpathExpr(query, xpath, needContext);
2285  }
2286 
2287  private static int GetDepth(XPathNavigator nav)
2288  {
2289  int num = 0;
2290  while (nav.MoveToParent())
2291  {
2292  num++;
2293  }
2294  return num;
2295  }
2296 
2297  private XmlNodeOrder CompareSiblings(XPathNavigator n1, XPathNavigator n2)
2298  {
2299  int num = 0;
2300  switch (n1.NodeType)
2301  {
2302  case XPathNodeType.Attribute:
2303  num++;
2304  break;
2305  default:
2306  num += 2;
2307  break;
2308  case XPathNodeType.Namespace:
2309  break;
2310  }
2311  switch (n2.NodeType)
2312  {
2313  case XPathNodeType.Namespace:
2314  if (num != 0)
2315  {
2316  break;
2317  }
2318  while (n1.MoveToNextNamespace())
2319  {
2320  if (n1.IsSamePosition(n2))
2321  {
2322  return XmlNodeOrder.Before;
2323  }
2324  }
2325  break;
2326  case XPathNodeType.Attribute:
2327  num--;
2328  if (num != 0)
2329  {
2330  break;
2331  }
2332  while (n1.MoveToNextAttribute())
2333  {
2334  if (n1.IsSamePosition(n2))
2335  {
2336  return XmlNodeOrder.Before;
2337  }
2338  }
2339  break;
2340  default:
2341  num -= 2;
2342  if (num != 0)
2343  {
2344  break;
2345  }
2346  while (n1.MoveToNext())
2347  {
2348  if (n1.IsSamePosition(n2))
2349  {
2350  return XmlNodeOrder.Before;
2351  }
2352  }
2353  break;
2354  }
2355  if (num >= 0)
2356  {
2357  return XmlNodeOrder.After;
2358  }
2359  return XmlNodeOrder.Before;
2360  }
2361 
2362  internal static XmlNamespaceManager GetNamespaces(IXmlNamespaceResolver resolver)
2363  {
2364  XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(new NameTable());
2365  IDictionary<string, string> namespacesInScope = resolver.GetNamespacesInScope(XmlNamespaceScope.All);
2366  foreach (KeyValuePair<string, string> item in namespacesInScope)
2367  {
2368  if (item.Key != "xmlns")
2369  {
2370  xmlNamespaceManager.AddNamespace(item.Key, item.Value);
2371  }
2372  }
2373  return xmlNamespaceManager;
2374  }
2375 
2376  internal static int GetContentKindMask(XPathNodeType type)
2377  {
2378  return ContentKindMasks[(int)type];
2379  }
2380 
2381  internal static int GetKindMask(XPathNodeType type)
2382  {
2383  switch (type)
2384  {
2385  case XPathNodeType.All:
2386  return int.MaxValue;
2387  case XPathNodeType.Text:
2388  return 112;
2389  default:
2390  return 1 << (int)type;
2391  }
2392  }
2393 
2394  internal static bool IsText(XPathNodeType type)
2395  {
2396  return (uint)(type - 4) <= 2u;
2397  }
2398 
2399  private bool IsValidChildType(XPathNodeType type)
2400  {
2401  switch (NodeType)
2402  {
2403  case XPathNodeType.Root:
2404  switch (type)
2405  {
2406  case XPathNodeType.Element:
2407  case XPathNodeType.SignificantWhitespace:
2408  case XPathNodeType.Whitespace:
2409  case XPathNodeType.ProcessingInstruction:
2410  case XPathNodeType.Comment:
2411  return true;
2412  }
2413  break;
2414  case XPathNodeType.Element:
2415  switch (type)
2416  {
2417  case XPathNodeType.Element:
2418  case XPathNodeType.Text:
2419  case XPathNodeType.SignificantWhitespace:
2420  case XPathNodeType.Whitespace:
2421  case XPathNodeType.ProcessingInstruction:
2422  case XPathNodeType.Comment:
2423  return true;
2424  }
2425  break;
2426  }
2427  return false;
2428  }
2429 
2430  private bool IsValidSiblingType(XPathNodeType type)
2431  {
2432  switch (NodeType)
2433  {
2434  case XPathNodeType.Element:
2435  case XPathNodeType.Text:
2436  case XPathNodeType.SignificantWhitespace:
2437  case XPathNodeType.Whitespace:
2438  case XPathNodeType.ProcessingInstruction:
2439  case XPathNodeType.Comment:
2440  switch (type)
2441  {
2442  case XPathNodeType.Element:
2443  case XPathNodeType.Text:
2444  case XPathNodeType.SignificantWhitespace:
2445  case XPathNodeType.Whitespace:
2446  case XPathNodeType.ProcessingInstruction:
2447  case XPathNodeType.Comment:
2448  return true;
2449  }
2450  break;
2451  }
2452  return false;
2453  }
2454 
2455  private XmlReader CreateReader()
2456  {
2457  return XPathNavigatorReader.Create(this);
2458  }
2459 
2460  private XmlReader CreateContextReader(string xml, bool fromCurrentNode)
2461  {
2462  if (xml == null)
2463  {
2464  throw new ArgumentNullException("xml");
2465  }
2466  XPathNavigator xPathNavigator = CreateNavigator();
2467  XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(NameTable);
2468  if (!fromCurrentNode)
2469  {
2470  xPathNavigator.MoveToParent();
2471  }
2472  if (xPathNavigator.MoveToFirstNamespace(XPathNamespaceScope.All))
2473  {
2474  do
2475  {
2476  xmlNamespaceManager.AddNamespace(xPathNavigator.LocalName, xPathNavigator.Value);
2477  }
2478  while (xPathNavigator.MoveToNextNamespace(XPathNamespaceScope.All));
2479  }
2480  XmlParserContext context = new XmlParserContext(NameTable, xmlNamespaceManager, null, XmlSpace.Default);
2481  XmlTextReader xmlTextReader = new XmlTextReader(xml, XmlNodeType.Element, context);
2482  xmlTextReader.WhitespaceHandling = WhitespaceHandling.Significant;
2483  return xmlTextReader;
2484  }
2485 
2486  internal void BuildSubtree(XmlReader reader, XmlWriter writer)
2487  {
2488  string text = "http://www.w3.org/2000/xmlns/";
2489  ReadState readState = reader.ReadState;
2490  if (readState != 0 && readState != ReadState.Interactive)
2491  {
2492  throw new ArgumentException(Res.GetString("Xml_InvalidOperation"), "reader");
2493  }
2494  int num = 0;
2495  if (readState == ReadState.Initial)
2496  {
2497  if (!reader.Read())
2498  {
2499  return;
2500  }
2501  num++;
2502  }
2503  do
2504  {
2505  switch (reader.NodeType)
2506  {
2507  case XmlNodeType.Element:
2508  {
2509  writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
2510  bool isEmptyElement = reader.IsEmptyElement;
2511  while (reader.MoveToNextAttribute())
2512  {
2513  if ((object)reader.NamespaceURI == text)
2514  {
2515  if (reader.Prefix.Length == 0)
2516  {
2517  writer.WriteAttributeString("", "xmlns", text, reader.Value);
2518  }
2519  else
2520  {
2521  writer.WriteAttributeString("xmlns", reader.LocalName, text, reader.Value);
2522  }
2523  }
2524  else
2525  {
2526  writer.WriteStartAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI);
2527  writer.WriteString(reader.Value);
2528  writer.WriteEndAttribute();
2529  }
2530  }
2531  reader.MoveToElement();
2532  if (isEmptyElement)
2533  {
2534  writer.WriteEndElement();
2535  }
2536  else
2537  {
2538  num++;
2539  }
2540  break;
2541  }
2542  case XmlNodeType.EndElement:
2543  writer.WriteFullEndElement();
2544  num--;
2545  break;
2546  case XmlNodeType.Text:
2547  case XmlNodeType.CDATA:
2548  writer.WriteString(reader.Value);
2549  break;
2550  case XmlNodeType.Whitespace:
2551  case XmlNodeType.SignificantWhitespace:
2552  writer.WriteString(reader.Value);
2553  break;
2554  case XmlNodeType.Comment:
2555  writer.WriteComment(reader.Value);
2556  break;
2557  case XmlNodeType.ProcessingInstruction:
2558  writer.WriteProcessingInstruction(reader.LocalName, reader.Value);
2559  break;
2560  case XmlNodeType.EntityReference:
2561  reader.ResolveEntity();
2562  break;
2563  case XmlNodeType.Attribute:
2564  if ((object)reader.NamespaceURI == text)
2565  {
2566  if (reader.Prefix.Length == 0)
2567  {
2568  writer.WriteAttributeString("", "xmlns", text, reader.Value);
2569  }
2570  else
2571  {
2572  writer.WriteAttributeString("xmlns", reader.LocalName, text, reader.Value);
2573  }
2574  }
2575  else
2576  {
2577  writer.WriteStartAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI);
2578  writer.WriteString(reader.Value);
2579  writer.WriteEndAttribute();
2580  }
2581  break;
2582  }
2583  }
2584  while (reader.Read() && num > 0);
2585  }
2586  }
2587 }
virtual XPathNodeIterator Select(string xpath)
Selects a node set, using the specified XPath expression.
static CultureInfo InvariantCulture
Gets the T:System.Globalization.CultureInfo object that is culture-independent (invariant).
Definition: CultureInfo.cs:263
override string ToString()
Gets the text value of the current node.
abstract bool MoveToNextNamespace(XPathNamespaceScope namespaceScope)
When overridden in a derived class, moves the T:System.Xml.XPath.XPathNavigator to the next namespace...
virtual void WriteSubtree(XmlWriter writer)
Streams the current node and its child nodes to the T:System.Xml.XmlWriter object specified.
virtual XPathNodeIterator Select(XPathExpression expr)
Selects a node set using the specified T:System.Xml.XPath.XPathExpression.
object Clone()
Creates a new object that is a copy of the current instance.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
The base class for all simple types and complex types.
Definition: XmlSchemaType.cs:7
The T:System.Xml.Schema.XmlSchemaDatatype class is an abstract class for mapping XML Schema definitio...
virtual XmlWriter InsertBefore()
Returns an T:System.Xml.XmlWriter object used to create a new sibling node before the currently selec...
XPathNamespaceScope
Defines the namespace scope.
abstract string NamespaceURI
When overridden in a derived class, gets the namespace URI of the current node.
Defines the post-schema-validation infoset of a validated XML node.
virtual bool MoveToNext(XPathNodeType type)
Moves the T:System.Xml.XPath.XPathNavigator to the next sibling node of the current node that matches...
XmlSchemaSimpleType MemberType
Gets the dynamic schema type for this validated XML node.
bool OmitXmlDeclaration
Gets or sets a value indicating whether to omit an XML declaration.
virtual void DeleteSelf()
Deletes the current node and its child nodes.
virtual XmlWriter InsertAfter()
Returns an T:System.Xml.XmlWriter object used to create a new sibling node after the currently select...
unsafe override string ToString()
Converts the value of this instance to a T:System.String.
virtual void ReplaceSelf(string newNode)
Replaces the current node with the content of the string specified.
static XmlWriter Create(string outputFileName)
Creates a new T:System.Xml.XmlWriter instance using the specified filename.
Definition: XmlWriter.cs:854
virtual bool MoveToFirst()
Moves the T:System.Xml.XPath.XPathNavigator to the first sibling node of the current node.
Implements a T:System.IO.TextWriter for writing information to a string. The information is stored in...
Definition: StringWriter.cs:13
abstract bool MoveToNext()
When overridden in a derived class, moves the T:System.Xml.XPath.XPathNavigator to the next sibling n...
static IEqualityComparer NavigatorComparer
Gets an T:System.Collections.IEqualityComparer used for equality comparison of T:System....
virtual XPathNavigator SelectSingleNode(string xpath, IXmlNamespaceResolver resolver)
Selects a single node in the T:System.Xml.XPath.XPathNavigator object using the specified XPath query...
bool? Indent
Gets or sets a value indicating whether to indent elements.
virtual void AppendChildElement(string prefix, string localName, string namespaceURI, string value)
Creates a new child element node at the end of the list of child nodes of the current node using the ...
abstract bool MoveToNextAttribute()
When overridden in a derived class, moves the T:System.Xml.XPath.XPathNavigator to the next attribute...
XmlSeverityType
Represents the severity of the validation event.
virtual XPathNodeIterator SelectAncestors(XPathNodeType type, bool matchSelf)
Selects all the ancestor nodes of the current node that have a matching T:System.Xml....
XmlSchemaDatatype Datatype
Gets the post-compilation value for the data type of the complex type.
virtual XPathNavigator SelectSingleNode(string xpath)
Selects a single node in the T:System.Xml.XPath.XPathNavigator using the specified XPath query.
Definition: __Canon.cs:3
virtual bool MoveToNext(string localName, string namespaceURI)
Moves the T:System.Xml.XPath.XPathNavigator to the next sibling node with the local name and namespac...
bool MoveToFirstNamespace()
Moves the T:System.Xml.XPath.XPathNavigator to first namespace node of the current node.
virtual void CreateAttribute(string prefix, string localName, string namespaceURI, string value)
Creates an attribute node on the current element node using the namespace prefix, local name and name...
abstract void WriteEndAttribute()
When overridden in a derived class, closes the previous M:System.Xml.XmlWriter.WriteStartAttribute(Sy...
virtual void PrependChild(XmlReader newChild)
Creates a new child node at the beginning of the list of child nodes of the current node using the XM...
virtual bool Matches(XPathExpression expr)
Determines whether the current node matches the specified T:System.Xml.XPath.XPathExpression.
virtual XPathNodeIterator SelectDescendants(XPathNodeType type, bool matchSelf)
Selects all the descendant nodes of the current node that have a matching T:System....
void WriteStartAttribute(string localName, string ns)
Writes the start of an attribute with the specified local name and namespace URI.
Definition: XmlWriter.cs:199
ValidationType
Specifies the type of validation to perform.
Represents an instant in time, typically expressed as a date and time of day. To browse the ....
Definition: DateTime.cs:13
override object TypedValue
Gets the current node as a boxed object of the most appropriate .NET Framework type.
virtual bool CanEdit
Gets a value indicating whether the T:System.Xml.XPath.XPathNavigator can edit the underlying XML dat...
XmlNodeType
Specifies the type of node.
Definition: XmlNodeType.cs:5
virtual string LookupPrefix(string namespaceURI)
Gets the prefix declared for the specified namespace URI.
abstract void WriteString(string text)
When overridden in a derived class, writes the given text content.
XPathNodeType
Defines the XPath node types that can be returned from the T:System.Xml.XPath.XPathNavigator class.
Definition: XPathNodeType.cs:4
virtual XPathNodeIterator SelectAncestors(string name, string namespaceURI, bool matchSelf)
Selects all the ancestor nodes of the current node that have the specified local name and namespace U...
virtual void AppendChild(string newChild)
Creates a new child node at the end of the list of child nodes of the current node using the XML data...
virtual void ReplaceSelf(XPathNavigator newNode)
Replaces the current node with the contents of the T:System.Xml.XPath.XPathNavigator object specified...
XmlNodeOrder
Describes the document order of a node compared to a second node.
Definition: XmlNodeOrder.cs:4
XmlSchemaValidity Validity
Gets the T:System.Xml.Schema.XmlSchemaValidity value of this validated XML node.
override bool ValueAsBoolean
Gets the current node's value as a T:System.Boolean.
WhitespaceHandling
Specifies how white space is handled.
virtual void SetTypedValue(object typedValue)
Sets the typed value of the current node.
Represents a writer that provides a fast, non-cached, forward-only way to generate streams or files t...
Definition: XmlWriter.cs:12
virtual object Evaluate(XPathExpression expr, XPathNodeIterator context)
Uses the supplied context to evaluate the T:System.Xml.XPath.XPathExpression, and returns the typed r...
XmlNamespaceScope
Defines the namespace scope.
virtual XPathNavigator SelectSingleNode(XPathExpression expression)
Selects a single node in the T:System.Xml.XPath.XPathNavigator using the specified T:System....
Represents an item in the XQuery 1.0 and XPath 2.0 Data Model.
Definition: XPathItem.cs:6
abstract XPathNodeType NodeType
When overridden in a derived class, gets the T:System.Xml.XPath.XPathNodeType of the current node.
Represents a reader that provides fast, noncached, forward-only access to XML data....
Definition: XmlReader.cs:15
virtual void SetValue(string value)
Sets the value of the current node.
virtual bool MoveToFollowing(XPathNodeType type, XPathNavigator end)
Moves the T:System.Xml.XPath.XPathNavigator to the following element of the T:System....
abstract bool MoveNext()
When overridden in a derived class, moves the T:System.Xml.XPath.XPathNavigator object returned by th...
Defines a key/value pair that can be set or retrieved.
Definition: KeyValuePair.cs:10
virtual bool MoveToFollowing(XPathNodeType type)
Moves the T:System.Xml.XPath.XPathNavigator to the following element of the T:System....
abstract XmlNameTable NameTable
When overridden in a derived class, gets the T:System.Xml.XmlNameTable of the T:System....
Provides an accessor to the T:System.Xml.XPath.XPathNavigator class.
Implements a single-threaded T:System.Xml.XmlNameTable.
Definition: NameTable.cs:5
override double ValueAsDouble
Gets the current node's value as a T:System.Double.
abstract string Prefix
When overridden in a derived class, gets the namespace prefix associated with the current node.
internal void SetSourceObject(object sourceObject)
Sets the XML node that causes the error.
StringBuilder Append(char value, int repeatCount)
Appends a specified number of copies of the string representation of a Unicode character to this inst...
override string ToString()
Returns a string containing the characters written to the current StringWriter so far.
XmlSeverityType Severity
Gets the severity of the validation event.
delegate void ValidationEventHandler(object sender, ValidationEventArgs e)
Represents the callback method that will handle XML schema validation events and the T:System....
ConformanceLevel ConformanceLevel
Gets or sets the level of conformance that the XML writer checks the XML output for.
Provides an iterator over a selected set of nodes.
virtual XmlWriter AppendChild()
Returns an T:System.Xml.XmlWriter object used to create one or more new child nodes at the end of the...
XmlSchemaValidity
Represents the validity of an XML item validated by the T:System.Xml.Schema.XmlSchemaValidator class.
ConformanceLevel
Specifies the amount of input or output checking that T:System.Xml.XmlReader and T:System....
override long ValueAsLong
Gets the current node's value as an T:System.Int64.
virtual IDictionary< string, string > GetNamespacesInScope(XmlNamespaceScope scope)
Returns the in-scope namespaces of the current node.
abstract bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope)
When overridden in a derived class, moves the T:System.Xml.XPath.XPathNavigator to the first namespac...
override object ValueAs(Type returnType, IXmlNamespaceResolver nsResolver)
Gets the current node's value as the T:System.Type specified, using the T:System.Xml....
Provides a typed class that represents a compiled XPath expression.
Defines methods to support the comparison of objects for equality.
sealed override bool IsNode
Gets a value indicating if the current node represents an XPath node.
virtual XPathNodeIterator SelectChildren(string name, string namespaceURI)
Selects all the child nodes of the current node that have the local name and namespace URI specified.
bool MoveToNextNamespace()
Moves the T:System.Xml.XPath.XPathNavigator to the next namespace node.
abstract bool IsEmptyElement
When overridden in a derived class, gets a value indicating whether the current node is an empty elem...
abstract string Name
When overridden in a derived class, gets the qualified name of the current node.
Supports cloning, which creates a new instance of a class with the same value as an existing instance...
Definition: ICloneable.cs:7
virtual void DeleteRange(XPathNavigator lastSiblingToDelete)
Deletes a range of sibling nodes from the current node to the node specified.
virtual void ReplaceSelf(XmlReader newNode)
Replaces the current node with the contents of the T:System.Xml.XmlReader object specified.
virtual object Evaluate(string xpath)
Evaluates the specified XPath expression and returns the typed result.
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
virtual string GetNamespace(string name)
Returns the value of the namespace node corresponding to the specified local name.
virtual void InsertElementAfter(string prefix, string localName, string namespaceURI, string value)
Creates a new sibling element after the current node using the namespace prefix, local name and names...
abstract Type ValueType
When overridden in a derived class, gets the Common Language Runtime (CLR) type of the item.
Provides the exception thrown when an error occurs while processing an XPath expression.
virtual void AppendChild(XPathNavigator newChild)
Creates a new child node at the end of the list of child nodes of the current node using the nodes in...
abstract void WriteEndElement()
When overridden in a derived class, closes one element and pops the corresponding namespace scope.
virtual void PrependChildElement(string prefix, string localName, string namespaceURI, string value)
Creates a new child element at the beginning of the list of child nodes of the current node using the...
virtual object UnderlyingObject
Used by T:System.Xml.XPath.XPathNavigator implementations which provide a "virtualized" XML view over...
Table of atomized string objects.
Definition: XmlNameTable.cs:5
static XPathExpression Compile(string xpath)
Compiles the XPath expression specified and returns an T:System.Xml.XPath.XPathExpression object repr...
virtual string GetAttribute(string localName, string namespaceURI)
Gets the value of the attribute with the specified local name and namespace URI.
virtual XPathNodeIterator SelectDescendants(string name, string namespaceURI, bool matchSelf)
Selects all the descendant nodes of the current node with the local name and namespace URI specified.
virtual XmlWriter PrependChild()
Returns an T:System.Xml.XmlWriter object used to create a new child node at the beginning of the list...
ReadState
Specifies the state of the reader.
Definition: ReadState.cs:5
Specifies a set of features to support on the T:System.Xml.XmlWriter object created by the Overload:S...
virtual void PrependChild(XPathNavigator newChild)
Creates a new child node at the beginning of the list of child nodes of the current node using the no...
Represents a mutable string of characters. This class cannot be inherited.To browse the ....
virtual bool Matches(string xpath)
Determines whether the current node matches the specified XPath expression.
virtual string OuterXml
Gets or sets the markup representing the opening and closing tags of the current node and its child n...
virtual object Evaluate(string xpath, IXmlNamespaceResolver resolver)
Evaluates the specified XPath expression and returns the typed result, using the T:System....
virtual void PrependChild(string newChild)
Creates a new child node at the beginning of the list of child nodes of the current node using the XM...
abstract bool IsSamePosition(XPathNavigator other)
When overridden in a derived class, determines whether the current T:System.Xml.XPath....
virtual void InsertAfter(XmlReader newSibling)
Creates a new sibling node after the currently selected node using the XML contents of the T:System....
virtual IXmlSchemaInfo SchemaInfo
Gets the schema information that has been assigned to the current node as a result of schema validati...
virtual void InsertAfter(XPathNavigator newSibling)
Creates a new sibling node after the currently selected node using the nodes in the T:System....
abstract bool Read()
When overridden in a derived class, reads the next node from the stream.
virtual void Close()
When overridden in a derived class, closes this stream and the underlying stream.
Definition: XmlWriter.cs:353
abstract bool MoveToFirstChild()
When overridden in a derived class, moves the T:System.Xml.XPath.XPathNavigator to the first child no...
virtual bool HasChildren
Gets a value indicating whether the current node has any child nodes.
abstract XPathNavigator Current
When overridden in a derived class, gets the T:System.Xml.XPath.XPathNavigator object for this T:Syst...
virtual string LookupNamespace(string prefix)
Gets the namespace URI for the specified prefix.
Represents the element element from XML Schema as specified by the World Wide Web Consortium (W3C)....
virtual void InsertBefore(XPathNavigator newSibling)
Creates a new sibling node before the currently selected node using the nodes in the T:System....
virtual void WriteNode(XmlReader reader, bool defattr)
When overridden in a derived class, copies everything from the reader to the writer and moves the rea...
Definition: XmlWriter.cs:596
virtual bool MoveToNamespace(string name)
Moves the T:System.Xml.XPath.XPathNavigator to the namespace node with the specified namespace prefix...
virtual void InsertBefore(string newSibling)
Creates a new sibling node before the currently selected node using the XML string specified.
virtual bool MoveToChild(string localName, string namespaceURI)
Moves the T:System.Xml.XPath.XPathNavigator to the child node with the local name and namespace URI s...
Provides read-only access to a set of prefix and namespace mappings.
virtual bool MoveToChild(XPathNodeType type)
Moves the T:System.Xml.XPath.XPathNavigator to the child node of the T:System.Xml....
abstract bool MoveToParent()
When overridden in a derived class, moves the T:System.Xml.XPath.XPathNavigator to the parent node of...
virtual XmlReader ReadSubtree()
Returns an T:System.Xml.XmlReader object that contains the current node and its child nodes.
Provides a cursor model for navigating and editing XML data.
virtual bool MoveToFollowing(string localName, string namespaceURI, XPathNavigator end)
Moves the T:System.Xml.XPath.XPathNavigator to the element with the local name and namespace URI spec...
virtual XmlNodeOrder ComparePosition(XPathNavigator nav)
Compares the position of the current T:System.Xml.XPath.XPathNavigator with the position of the T:Sys...
ValidationEventHandler ValidationEventHandler
Specifies an event handler for receiving information about XML Schema definition language (XSD) schem...
virtual void InsertAfter(string newSibling)
Creates a new sibling node after the currently selected node using the XML string specified.
XmlSchemaElement SchemaElement
Gets the compiled T:System.Xml.Schema.XmlSchemaElement that corresponds to this validated XML node.
virtual string XmlLang
Gets the xml:lang scope for the current node.
virtual void InsertElementBefore(string prefix, string localName, string namespaceURI, string value)
Creates a new sibling element before the current node using the namespace prefix, local name,...
The exception that is thrown when a method call is invalid for the object's current state.
virtual bool IsDescendant(XPathNavigator nav)
Determines whether the specified T:System.Xml.XPath.XPathNavigator is a descendant of the current T:S...
override string Get(string value)
Gets the atomized string with the specified value.
Definition: NameTable.cs:118
virtual XPathNodeIterator Select(string xpath, IXmlNamespaceResolver resolver)
Selects a node set using the specified XPath expression with the T:System.Xml.IXmlNamespaceResolver o...
virtual void InsertBefore(XmlReader newSibling)
Creates a new sibling node before the currently selected node using the XML contents of the T:System....
virtual void AppendChild(XmlReader newChild)
Creates a new child node at the end of the list of child nodes of the current node using the XML cont...
abstract bool MoveToFirstAttribute()
When overridden in a derived class, moves the T:System.Xml.XPath.XPathNavigator to the first attribut...
abstract string Value
When overridden in a derived class, gets the string value of the item.
Definition: XPathItem.cs:26
override DateTime ValueAsDateTime
Gets the current node's value as a T:System.DateTime.
abstract bool MoveToPrevious()
When overridden in a derived class, moves the T:System.Xml.XPath.XPathNavigator to the previous sibli...
XmlSpace
Specifies the current xml:space scope.
Definition: XmlSpace.cs:5
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition: CultureInfo.cs:16
The exception that is thrown when an invoked method is not supported, or when there is an attempt to ...
XmlSchemaAttribute SchemaAttribute
Gets the compiled T:System.Xml.Schema.XmlSchemaAttribute that corresponds to this validated XML node.
virtual XmlWriter ReplaceRange(XPathNavigator lastSiblingToReplace)
Replaces a range of sibling nodes from the current node to the node specified.
abstract string BaseURI
When overridden in a derived class, gets the base URI for the current node.
virtual XPathExpression Compile(string xpath)
Compiles a string representing an XPath expression and returns an T:System.Xml.XPath....
XmlSchemaException Exception
Gets the T:System.Xml.Schema.XmlSchemaException associated with the validation event.
virtual XPathNodeIterator SelectChildren(XPathNodeType type)
Selects all the child nodes of the current node that have the matching T:System.Xml....
The P:System.Uri.Query data.
override int ValueAsInt
Gets the current node's value as an T:System.Int32.
abstract bool MoveTo(XPathNavigator other)
When overridden in a derived class, moves the T:System.Xml.XPath.XPathNavigator to the same position ...
override XmlSchemaType XmlType
Gets the T:System.Xml.Schema.XmlSchemaType information for the current node.
abstract string LocalName
When overridden in a derived class, gets the P:System.Xml.XPath.XPathNavigator.Name of the current no...
Returns detailed information related to the ValidationEventHandler.
abstract bool MoveToId(string id)
When overridden in a derived class, moves to the node that has an attribute of type ID whose value ma...
virtual string InnerXml
Gets or sets the markup representing the child nodes of the current node.
Provides the base class for value types.
Definition: ValueType.cs:12
virtual bool HasAttributes
Gets a value indicating whether the current node has any attributes.
virtual bool MoveToAttribute(string localName, string namespaceURI)
Moves the T:System.Xml.XPath.XPathNavigator to the attribute with the matching local name and namespa...
virtual bool CheckValidity(XmlSchemaSet schemas, ValidationEventHandler validationEventHandler)
Verifies that the XML data in the T:System.Xml.XPath.XPathNavigator conforms to the XML Schema defini...
Represents the attribute element from the XML Schema as specified by the World Wide Web Consortium (W...
virtual XPathNavigator CreateNavigator()
Returns a copy of the T:System.Xml.XPath.XPathNavigator.
abstract object ParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr)
When overridden in a derived class, validates the string specified against a built-in or user-defined...
Represents the exception thrown when XML Schema Definition Language (XSD) schema validation errors an...
virtual object Evaluate(XPathExpression expr)
Evaluates the T:System.Xml.XPath.XPathExpression and returns the typed result.
XmlSchemaType SchemaType
Gets the static XML Schema Definition Language (XSD) schema type of this validated XML node.
virtual void MoveToRoot()
Moves the T:System.Xml.XPath.XPathNavigator to the root node that the current node belongs to.
virtual bool MoveToFollowing(string localName, string namespaceURI)
Moves the T:System.Xml.XPath.XPathNavigator to the element with the local name and namespace URI spec...
virtual XmlWriter CreateAttributes()
Returns an T:System.Xml.XmlWriter object used to create new attributes on the current element.
Encodes and decodes XML names, and provides methods for converting between common language runtime ty...
Definition: XmlConvert.cs:11
void WriteStartElement(string localName, string ns)
When overridden in a derived class, writes the specified start tag and associates it with the given n...
Definition: XmlWriter.cs:110
Contains a cache of XML Schema definition language (XSD) schemas.
Definition: XmlSchemaSet.cs:8