**** Merged from MCS ****
[mono-project.git] / mcs / class / System.XML / Mono.Xml.XPath / XPathDocument2.cs
blobc50ede67c6903b3f96747979b2dbaf45d0d053be
1 //
2 // Mono.Xml.XPath.XPathDocument2.cs
3 //
4 // Author:
5 // Atsushi Enomoto <atsushi@ximian.com>
6 //
7 // (C)2004 Novell Inc.
8 //
9 // Another Document tree model.
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 #if NET_2_0
33 using System;
34 using System.Collections;
35 using System.Collections.Specialized;
36 using System.IO;
37 using System.Text;
38 using System.Xml;
39 using System.Xml.XPath;
41 namespace Mono.Xml.XPath
45 public class Driver
47 public static void Main ()
49 try {
50 DateTime start = DateTime.Now;
51 Console.WriteLine (DateTime.Now.Ticks);
52 #if false
53 XmlDocument doc = new XmlDocument ();
54 doc.PreserveWhitespace = true;
55 doc.Load (new XmlTextReader ("../TestResult.xml"));
56 #else
57 XPathDocument2 doc = new XPathDocument2 ();
58 doc.Load (new XmlTextReader ("../TestResult.xml"));
59 // XPathDocument doc = new XPathDocument ("../TestResult.xml", XmlSpace.Preserve);
60 // XPathDocument doc = new XPathDocument ("test.xml", XmlSpace.Preserve);
61 #endif
62 // doc.Load (new XmlTextReader ("test.xml"));
64 // doc.WriteTo (new XmlTextWriter (Console.Out));
65 //return;
66 Console.WriteLine (DateTime.Now.Ticks);
68 XPathNavigator nav = doc.CreateNavigator ();
69 //Console.WriteLine (nav.MoveToFirstChild ());
70 //Console.WriteLine (nav.LocalName + nav.NodeType);
71 //Console.WriteLine (nav.MoveToNext ());
72 //Console.WriteLine (nav.LocalName + nav.NodeType);
73 //Console.WriteLine (nav.MoveToNext ());
74 //Console.WriteLine (nav.LocalName + nav.NodeType);
75 //Console.WriteLine (nav.MoveToNext ());
76 //Console.WriteLine (nav.LocalName + nav.NodeType);
77 //nav.MoveToRoot ();
80 XmlReader reader = nav.ReadSubtree ();
81 XmlTextWriter w = new XmlTextWriter (new StringWriter ());
82 // XmlTextWriter w = new XmlTextWriter (Console.Out);
83 w.WriteNode (reader, false);
84 Console.WriteLine (DateTime.Now.Ticks);
85 Console.WriteLine (DateTime.Now.Ticks - start.Ticks);
86 } catch (Exception ex) {
87 Console.WriteLine (ex);
93 // Wrapper
95 public class XPathDocument2 : IXPathNavigable
97 XomRoot root;
99 public XPathDocument2 ()
100 : this (new NameTable ())
104 public XPathDocument2 (XmlNameTable nameTable)
106 root = new XomRoot (nameTable);
109 public XmlNameTable NameTable {
110 get { return root.NameTable; }
113 public void LoadXml (string xml)
115 Load (new XmlTextReader (xml, XmlNodeType.Document, null));
118 public void Load (TextReader reader)
120 Load (new XmlTextReader (reader));
123 public void Load (XmlReader reader)
125 Load (reader, XmlSpace.None);
128 public void Load (XmlReader reader, XmlSpace space)
130 root.Load (reader, space);
133 public void Save (TextWriter writer)
135 XmlTextWriter xtw = new XmlTextWriter (writer);
136 xtw.Formatting = Formatting.Indented;
137 WriteTo (xtw);
140 public void Save (XmlWriter writer)
142 WriteTo (writer);
145 public void WriteTo (XmlWriter writer)
147 root.WriteTo (writer);
150 public XPathNavigator CreateNavigator ()
152 return new XomNavigator (root);
156 // Xom part
158 public struct XmlName
160 public string Prefix;
161 public string LocalName;
162 public string Namespace;
163 string fullName;
165 public XmlName (string prefix, string name, string ns)
167 this.Prefix = prefix == null ? "" : prefix;
168 this.LocalName = name;
169 this.Namespace = ns == null ? "" : ns;
170 fullName = null;
173 public override bool Equals (object o)
175 if ( !(o is XmlName))
176 return false;
177 XmlName other = (XmlName) o;
178 return LocalName == other.LocalName && Namespace == other.Namespace;
181 public static bool operator == (XmlName n1, XmlName n2)
183 return n1.LocalName == n2.LocalName && n1.Namespace == n2.Namespace;
186 public static bool operator != (XmlName n1, XmlName n2)
188 return n1.LocalName != n2.LocalName || n1.Namespace != n2.Namespace;
191 public override int GetHashCode ()
193 if (fullName == null)
194 fullName = String.Concat (LocalName, "/", Namespace);
195 return fullName.GetHashCode ();
198 public override string ToString ()
200 if (fullName == null)
201 fullName = String.Concat (LocalName, "/", Namespace);
202 return fullName;
206 public abstract class XomNode
208 XomParentNode parent;
209 string prefixedName;
210 XomNode previousSibling;
211 XomNode nextSibling;
213 public XomRoot Root {
214 get {
215 XomNode n = this;
216 while (n.parent != null)
217 n = n.parent;
218 return (XomRoot) n;
222 public string PrefixedName {
223 get {
224 if (prefixedName == null) {
225 if (Prefix.Length > 0)
226 prefixedName = Prefix + ':' + LocalName;
227 else
228 prefixedName = LocalName;
230 return prefixedName;
234 public virtual string BaseURI {
235 get { return Root.BaseURI; }
238 public virtual string XmlLang {
239 get { return String.Empty; }
242 public XomParentNode Parent {
243 get { return parent; }
246 public XomNode PreviousSibling {
247 get { return previousSibling; }
250 public XomNode NextSibling {
251 get { return nextSibling; }
254 internal void SetParent (XomParentNode parent)
256 this.parent = parent;
259 internal void SetPreviousSibling (XomNode previous)
261 if (previous.parent != parent || this == previous)
262 throw new InvalidOperationException ();
263 nextSibling = previous.nextSibling;
264 previousSibling = previous;
265 previous.nextSibling = this;
268 internal void SetNextSibling (XomNode next)
270 if (next.parent != parent || this == next)
271 throw new InvalidOperationException ();
272 previousSibling = next.previousSibling;
273 nextSibling = next;
274 next.previousSibling = this;
277 internal void RemoveItself ()
279 if (previousSibling != null)
280 previousSibling.nextSibling = nextSibling;
281 if (nextSibling != null)
282 nextSibling.previousSibling = previousSibling;
283 parent = null;
286 public string LookupPrefix (string ns)
288 XomElement n = this as XomElement;
289 if (n == null)
290 n = Parent as XomElement;
291 while (n != null) {
292 int len = n.NamespaceCount;
293 for (int i = 0; i < len; i++) {
294 XomNamespace nn = n.GetLocalNamespace (i);
295 if (nn.Value == ns)
296 return nn.LocalName;
299 return null;
302 public string LookupNamespace (string ns)
304 XomElement n = this as XomElement;
305 if (n == null)
306 n = Parent as XomElement;
307 while (n != null) {
308 int len = n.NamespaceCount;
309 for (int i = 0; i < len; i++) {
310 XomNamespace nn = n.GetLocalNamespace (i);
311 if (nn.Namespace== ns)
312 return nn.Prefix;
315 return null;
318 public virtual bool IsEmptyElement {
319 get { return false; }
322 public abstract string LocalName { get; }
324 public abstract string Namespace { get; }
326 public abstract string Prefix { get; }
328 public abstract string Value { get; set; }
330 public abstract XPathNodeType NodeType { get; }
332 public abstract int ChildCount { get; }
334 public virtual XomNode FirstChild { get { return null; } }
336 public virtual XomNode LastChild { get { return null; } }
338 internal abstract void BuildValue (StringBuilder sb);
340 public string OuterXml {
341 get {
342 StringWriter sw = new StringWriter ();
343 XmlTextWriter xtw = new XmlTextWriter (sw);
344 WriteTo (xtw);
345 return sw.ToString ();
349 public string InnerXml {
350 get {
351 StringWriter sw = new StringWriter ();
352 XmlTextWriter xtw = new XmlTextWriter (sw);
353 for (XomNode n = FirstChild; n != null; n = n.NextSibling)
354 n.WriteTo (xtw);
355 return sw.ToString ();
359 public abstract void WriteTo (XmlWriter writer);
362 public interface IHasXomNode
364 XomNode GetNode ();
367 public abstract class XomParentNode : XomNode
369 XomNode firstChild;
370 XomNode lastChild;
371 int childCount;
373 public void ReadNode (XmlReader reader, XmlSpace space)
375 switch (reader.ReadState) {
376 case ReadState.Initial:
377 reader.Read ();
378 break;
379 case ReadState.Error:
380 case ReadState.Closed:
381 case ReadState.EndOfFile:
382 throw new ArgumentException ("Argument XmlReader is not readable.");
385 switch (reader.NodeType) {
386 case XmlNodeType.Element:
387 XomElement el = new XomElement (reader.Prefix, reader.LocalName, reader.NamespaceURI, this);
388 if (reader.MoveToFirstAttribute ()) {
389 do {
390 new XomAttribute (reader.Prefix, reader.LocalName, reader.NamespaceURI, reader.Value, el);
391 } while (reader.MoveToNextAttribute ());
392 reader.MoveToContent ();
394 if (reader.IsEmptyElement) {
395 el.SetIsEmpty (true);
396 reader.Read ();
398 else {
399 reader.Read ();
400 while (reader.NodeType != XmlNodeType.EndElement)
401 el.ReadNode (reader, space);
402 reader.ReadEndElement ();
404 return;
405 case XmlNodeType.Text:
406 case XmlNodeType.CDATA:
407 XomText text = new XomText (reader.Value, this);
408 reader.Read ();
409 return;
410 case XmlNodeType.SignificantWhitespace:
411 XomSignificantWhitespace sws = new XomSignificantWhitespace (reader.Value, this);
412 reader.Read ();
413 return;
414 case XmlNodeType.Whitespace:
415 if (space == XmlSpace.Default) {
416 reader.Skip ();
417 return;
419 XomWhitespace ws = new XomWhitespace (reader.Value, this);
420 reader.Read ();
421 return;
422 case XmlNodeType.ProcessingInstruction:
423 XomPI pi = new XomPI (reader.LocalName, reader.Value, this);
424 reader.Read ();
425 return;
426 case XmlNodeType.Comment:
427 XomComment comment = new XomComment (reader.Value, this);
428 reader.Read ();
429 return;
430 default:
431 reader.Skip ();
432 return;
436 public void AppendChild (XomNode child)
438 InsertBefore (child, null);
441 public void InsertBefore (XomNode child, XomNode nextNode)
443 if (child.Parent != null)
444 throw new InvalidOperationException ("The child already has a parent.");
445 if (nextNode == null) {
446 child.SetParent (this);
447 if (firstChild == null)
448 firstChild = lastChild = child;
449 else {
450 child.SetPreviousSibling (lastChild);
451 lastChild = child;
453 } else {
454 if (nextNode.Parent != this)
455 throw new ArgumentException ("Argument nextNode is not a child of this node.");
456 child.SetNextSibling (nextNode);
458 childCount++;
461 public abstract void Clear ();
463 public override XomNode FirstChild {
464 get { return firstChild; }
467 public override XomNode LastChild {
468 get { return lastChild; }
471 public override int ChildCount {
472 get { return childCount; }
475 internal void ClearChildren ()
477 firstChild = lastChild = null;
478 childCount = 0;
481 public void RemoveChild (XomNode child)
483 if (child == firstChild)
484 firstChild = child.NextSibling;
485 if (child == lastChild)
486 lastChild = child.PreviousSibling;
487 child.RemoveItself ();
488 childCount--;
491 public override string Value {
492 get {
493 StringBuilder sb = new StringBuilder ();
494 BuildValue (sb);
495 return sb.ToString ();
497 set {
498 ClearChildren ();
499 AppendChild (new XomText (value));
503 internal override void BuildValue (StringBuilder sb)
505 for (XomNode n = FirstChild; n != null; n = n.NextSibling)
506 n.BuildValue (sb);
510 public class XomRoot : XomParentNode
512 XmlNameTable nameTable;
513 Hashtable identicalElements;
514 string baseUri;
516 public XomRoot (XmlNameTable nameTable)
518 this.nameTable = nameTable;
519 identicalElements = new Hashtable ();
522 public override string BaseURI {
523 get { return baseUri; }
526 public void Load (XmlReader reader)
528 Load (reader, XmlSpace.None);
531 public void Load (XmlReader reader, XmlSpace space)
533 baseUri = reader.BaseURI;
534 while (!reader.EOF)
535 ReadNode (reader, space);
538 public XmlNameTable NameTable {
539 get { return nameTable; }
542 public override string Prefix {
543 get { return ""; }
546 public override string LocalName {
547 get { return ""; }
550 public override string Namespace {
551 get { return ""; }
554 public override XPathNodeType NodeType {
555 get { return XPathNodeType.Root; }
558 public override void Clear ()
560 ClearChildren ();
563 public override void WriteTo (XmlWriter writer)
565 for (XomNode n = FirstChild; n != null; n = n.NextSibling)
566 n.WriteTo (writer);
569 public XomElement GetIdenticalNode (string id)
571 return identicalElements [id] as XomElement;
574 internal void GetIdenticalNode (string id, XomElement element)
576 identicalElements.Add (id, element);
580 public class XomElement : XomParentNode
582 XmlName qname;
583 bool isEmptyElement;
585 ArrayList attributes;
586 ArrayList namespaces;
588 public XomElement (string name)
589 : this ("", name, "", null)
593 public XomElement (string name, XomRoot root)
594 : this ("", name, "", root)
598 public XomElement (string name, string ns)
599 : this ("", name, ns, null)
603 public XomElement (string name, string ns, XomRoot root)
604 : this ("", name, ns, root)
608 public XomElement (string prefix, string name, string ns)
609 : this (prefix, name, ns, null)
613 public XomElement (string prefix, string name, string ns, XomParentNode parent)
615 qname.LocalName = name;
616 qname.Namespace = ns == null ? "" : ns;
617 qname.Prefix = prefix == null ? "" : prefix;
618 if (parent != null)
619 parent.AppendChild (this);
622 public override bool IsEmptyElement {
623 get { return isEmptyElement; }
626 internal void SetIsEmpty (bool value)
628 isEmptyElement = value;
631 public override string Prefix {
632 get { return qname.Prefix; }
635 public override string LocalName {
636 get { return qname.LocalName; }
639 public override string Namespace {
640 get { return qname.Namespace; }
643 public override XPathNodeType NodeType {
644 get { return XPathNodeType.Element; }
647 public override void Clear ()
649 if (attributes != null)
650 attributes.Clear ();
651 if (namespaces != null)
652 namespaces.Clear ();
653 ClearChildren ();
656 public void AppendAttribute (XomAttribute attr)
658 if (attr.Parent != null)
659 throw new InvalidOperationException ("The argument attribute already have another element owner.");
660 attr.SetParent (this);
661 if (attributes == null)
662 attributes = new ArrayList ();
663 attributes.Add (attr);
667 public void UpdateAttribute (XomAttribute attr)
669 if (attr.Parent != null)
670 throw new InvalidOperationException ("The argument attribute already have another element owner.");
671 XomAttribute existing = GetAttribute (attr.LocalName, attr.Namespace);
672 if (existing != null)
673 RemoveAttribute (existing);
674 if (attributes == null)
675 attributes = new ArrayList ();
676 attr.SetParent (this);
677 attributes.Add (attr);
681 public XomAttribute GetAttribute (int index)
683 return attributes == null ? null : attributes [index] as XomAttribute;
686 public XomAttribute GetAttribute (string name, string ns)
688 if (attributes == null)
689 return null;
690 for (int i = 0; i < attributes.Count; i++) {
691 XomAttribute a = attributes [i] as XomAttribute;
692 if (a.LocalName == name && a.Namespace == ns)
693 return a;
695 return null;
698 public XomAttribute GetNextAttribute (XomAttribute attr)
700 if (attributes == null || attributes.Count == 0)
701 return null;
702 if (attributes [attributes.Count - 1] == attr)
703 return null;
704 // It is not efficient, but usually there won't be so many attributes in an element.
705 int index = attributes.IndexOf (attr);
706 if (index < 0)
707 return null;
708 return attributes [index + 1] as XomAttribute;
711 public int AttributeCount {
712 get { return attributes == null ? 0 : attributes.Count; }
715 public void RemoveAttribute (XomAttribute attr)
717 if (attributes == null)
718 return;
719 attributes.Remove (attr);
720 attr.SetParent (null);
723 public void AppendNamespace (string prefix, string ns)
725 if (namespaces == null)
726 namespaces = new ArrayList ();
727 namespaces.Add (new XomNamespace (prefix, ns));
730 public XomNamespace GetLocalNamespace (int index)
732 if (namespaces == null || namespaces.Count <= index)
733 return null;
734 return namespaces [index] as XomNamespace;
737 public XomNamespace GetLocalNamespace (string prefix)
739 if (namespaces == null)
740 return null;
741 for (int i = 0; i < namespaces.Count; i++) {
742 XomNamespace qname = namespaces [i] as XomNamespace;
743 if (qname.LocalName == prefix)
744 return qname;
746 return null;
749 public XomNamespace GetNextLocalNamespace (XomNamespace n)
751 if (namespaces == null || namespaces.Count == 0)
752 return null;
753 if (namespaces [namespaces.Count - 1] == n)
754 return null;
755 // It is not efficient, but usually there won't be so many attributes in an element.
756 int index = namespaces.IndexOf (n);
757 if (index < 0)
758 return null;
759 return namespaces [index + 1] as XomNamespace;
762 public int NamespaceCount {
763 get { return namespaces == null ? 0 : namespaces.Count; }
766 public void RemoveNamespace (string prefix)
768 if (namespaces == null)
769 return;
770 for (int i = 0; i < namespaces.Count; i++) {
771 XomNamespace qname = namespaces [i] as XomNamespace;
772 if (qname.LocalName == prefix) {
773 namespaces.RemoveAt (i);
774 return;
779 public override void WriteTo (XmlWriter writer)
781 writer.WriteStartElement (Prefix, LocalName, Namespace);
782 if (namespaces != null) {
783 foreach (XomNamespace n in namespaces)
784 n.WriteTo (writer);
786 if (attributes != null) {
787 foreach (XomAttribute a in attributes)
788 a.WriteTo (writer);
791 for (XomNode n = FirstChild; n != null; n = n.NextSibling)
792 n.WriteTo (writer);
794 writer.WriteEndElement ();
798 public class XomAttribute : XomNode
800 XmlName qname;
801 string value;
803 public XomAttribute (string name, string value)
804 : this ("", name, "", value, null)
808 public XomAttribute (string name, string value, XomElement owner)
809 : this ("", name, "", value, owner)
813 public XomAttribute (string name, string ns, string value)
814 : this ("", name, ns, value, null)
818 public XomAttribute (string name, string ns, string value, XomElement owner)
819 : this ("", name, ns, value, owner)
823 public XomAttribute (string prefix, string name, string ns, string value)
824 : this ("", name, ns, value, null)
828 public XomAttribute (string prefix, string name, string ns, string value, XomElement owner)
830 qname.LocalName = name;
831 qname.Namespace = ns;
832 qname.Prefix = prefix;
833 this.value = value;
834 if (owner != null)
835 owner.AppendAttribute (this);
838 public override string Prefix {
839 get { return qname.Prefix; }
842 public override string LocalName {
843 get { return qname.LocalName; }
846 public override string Namespace {
847 get { return qname.Namespace; }
850 public override XPathNodeType NodeType {
851 get { return XPathNodeType.Attribute; }
854 public override int ChildCount { get { return 0; } }
856 public override string Value {
857 get { return value; }
858 set { this.value = value; }
861 internal override void BuildValue (StringBuilder sb)
863 sb.Append (value);
866 public override void WriteTo (XmlWriter writer)
868 writer.WriteAttributeString (Prefix, LocalName, Namespace, Value);
872 public class XomNamespace : XomNode
874 #region static members
875 static XomNamespace xml;
877 static XomNamespace ()
879 xml = new XomNamespace ("xml", "http://www.w3.org/XML/1998/namespace");
882 public static XomNamespace Xml {
883 get { return xml; }
885 #endregion
887 XmlName qname;
889 public XomNamespace (string prefix, string ns)
891 qname.LocalName = prefix;
892 qname.Namespace = ns;
895 public override int ChildCount {
896 get { return 0; }
899 public override string LocalName {
900 get { return qname.LocalName; }
903 public override string Prefix {
904 get { return LocalName; }
907 public override string Namespace {
908 get { return Value; }
911 public override string Value {
912 get { return qname.Namespace; }
913 set { qname.Namespace = value; }
916 public override XPathNodeType NodeType {
917 get { return XPathNodeType.Namespace; }
920 public override void WriteTo (XmlWriter writer)
922 if (LocalName != "")
923 writer.WriteAttributeString ("xmlns", LocalName, "http://www.w3.org/2000/xmlns/", Namespace);
924 else
925 writer.WriteAttributeString ("", "xmlns", "http://www.w3.org/2000/xmlns/", Namespace);
928 internal override void BuildValue (StringBuilder sb)
930 sb.Append (Value);
934 public class XomComment : XomNode
936 string value;
938 public XomComment (string value)
939 : this (value, null)
943 public XomComment (string value, XomParentNode parent)
945 this.value = value;
946 if (parent != null)
947 parent.AppendChild (this);
950 public override string Prefix {
951 get { return ""; }
954 public override string LocalName {
955 get { return ""; }
958 public override string Namespace {
959 get { return ""; }
962 public override XPathNodeType NodeType {
963 get { return XPathNodeType.Comment; }
966 public override string Value {
967 get { return value; }
968 set { this.value += value; }
971 internal override void BuildValue (StringBuilder sb)
973 sb.Append (value);
976 public override int ChildCount { get { return 0; } }
978 public override void WriteTo (XmlWriter writer)
980 writer.WriteComment (Value);
984 public class XomPI : XomNode
986 string value;
987 string name;
989 public XomPI (string name, string value)
990 : this (name, value, null)
994 public XomPI (string name, string value, XomParentNode parent)
996 this.name = name;
997 if (value == null)
998 value = "";
999 this.value = value;
1000 if (parent != null)
1001 parent.AppendChild (this);
1004 public override string Prefix {
1005 get { return ""; }
1008 public override string LocalName {
1009 get { return name; }
1012 public override string Namespace {
1013 get { return ""; }
1016 public override XPathNodeType NodeType {
1017 get { return XPathNodeType.ProcessingInstruction; }
1020 public override string Value {
1021 get { return value; }
1022 set { this.value += value; }
1025 internal override void BuildValue (StringBuilder sb)
1027 sb.Append (value);
1030 public override int ChildCount { get { return 0; } }
1032 public override void WriteTo (XmlWriter writer)
1034 writer.WriteProcessingInstruction (LocalName, Value);
1038 public class XomText : XomNode
1040 string value;
1042 public XomText (string value)
1043 : this (value, null)
1047 public XomText (string value, XomParentNode parent)
1049 this.value = value;
1050 if (parent != null)
1051 parent.AppendChild (this);
1054 public override string Prefix {
1055 get { return ""; }
1058 public override string LocalName {
1059 get { return ""; }
1062 public override string Namespace {
1063 get { return ""; }
1066 public override string Value {
1067 get { return value; }
1068 set { this.value += value; }
1071 public override XPathNodeType NodeType {
1072 get { return XPathNodeType.Text; }
1075 internal override void BuildValue (StringBuilder sb)
1077 sb.Append (value);
1080 public override int ChildCount { get { return 0; } }
1082 public override void WriteTo (XmlWriter writer)
1084 writer.WriteString (Value);
1088 public class XomWhitespace : XomNode
1090 string value;
1092 public XomWhitespace (string value)
1093 : this (value, null)
1097 public XomWhitespace (string value, XomParentNode parent)
1099 this.value = value;
1100 if (parent != null)
1101 parent.AppendChild (this);
1104 public override string Prefix {
1105 get { return ""; }
1108 public override string LocalName {
1109 get { return ""; }
1112 public override string Namespace {
1113 get { return ""; }
1116 public override string Value {
1117 get { return value; }
1118 set { this.value += value; }
1121 public override XPathNodeType NodeType {
1122 get { return XPathNodeType.Whitespace; }
1125 internal override void BuildValue (StringBuilder sb)
1127 sb.Append (value);
1130 public override int ChildCount { get { return 0; } }
1132 public override void WriteTo (XmlWriter writer)
1134 writer.WriteString (Value);
1138 public class XomSignificantWhitespace : XomNode
1140 string value;
1142 public XomSignificantWhitespace (string value)
1143 : this (value, null)
1147 public XomSignificantWhitespace (string value, XomParentNode parent)
1149 this.value = value;
1150 if (parent != null)
1151 parent.AppendChild (this);
1154 public override string Prefix {
1155 get { return ""; }
1158 public override string LocalName {
1159 get { return ""; }
1162 public override string Namespace {
1163 get { return ""; }
1166 public override string Value {
1167 get { return value; }
1168 set { this.value += value; }
1171 public override XPathNodeType NodeType {
1172 get { return XPathNodeType.SignificantWhitespace; }
1175 internal override void BuildValue (StringBuilder sb)
1177 sb.Append (value);
1180 public override int ChildCount { get { return 0; } }
1182 public override void WriteTo (XmlWriter writer)
1184 writer.WriteString (Value);
1188 #endif