XmlElement.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  2. //
  3. // System.Xml.XmlElement
  4. //
  5. // Author:
  6. // Daniel Weber ([email protected])
  7. //
  8. // (C) 2001 Daniel Weber
  9. using System;
  10. namespace System.Xml
  11. {
  12. public class XmlElement : XmlLinkedNode
  13. {
  14. // Private/Protected internal data structures
  15. //===========================================================================
  16. private XmlAttributeCollection _attributes;
  17. private string prefix;
  18. private string localName;
  19. private string namespaceURI;
  20. // Public Properties
  21. //===========================================================================
  22. /// <summary>
  23. /// Return the XmlAttributeCollection on the Element
  24. /// </summary>
  25. public override XmlAttributeCollection Attributes
  26. {
  27. get
  28. {
  29. // TODO - implement Attributes
  30. return _attributes;
  31. }
  32. }
  33. /// <summary>
  34. /// Get/Set the value for this node
  35. /// </summary>
  36. public override string Value
  37. {
  38. get
  39. {
  40. return null;
  41. }
  42. set
  43. {
  44. // Do nothing, can't set value on XmlElement...
  45. }
  46. }
  47. // Implement abstract methods of XmlNode
  48. //=====================================================================
  49. /// <summary>
  50. /// Remove all children and attributes. If
  51. /// </summary>
  52. public override void RemoveAll()
  53. {
  54. // Remove all child nodes
  55. base.RemoveAll();
  56. // Remove all attributes
  57. _attributes.RemoveAll();
  58. // If we have any default attributes, add them back in with the
  59. // appropriate namespace, baseURI, name, localName
  60. // TODO - implement adding default attributes back in XmlElement.RemoveAll()
  61. }
  62. /// <summary>
  63. /// Return a clone of the node
  64. /// </summary>
  65. /// <param name="deep">Make copy of all children</param>
  66. /// <returns>Cloned node</returns>
  67. public override XmlNode CloneNode( bool deep)
  68. {
  69. // TODO - implement CloneNode()
  70. throw new NotImplementedException();
  71. }
  72. /// <summary>
  73. /// Saves all children of the current node to the passed writer
  74. /// </summary>
  75. /// <param name="w"></param>
  76. public override void WriteContentTo(XmlWriter w)
  77. {
  78. // TODO - implement WriteContentsTo(XmlWriter)
  79. throw new NotImplementedException();
  80. }
  81. /// <summary>
  82. /// Saves the current node to writer w
  83. /// </summary>
  84. /// <param name="w"></param>
  85. public override void WriteTo(XmlWriter w)
  86. {
  87. // TODO - implement WriteTo(XmlWriter)
  88. throw new NotImplementedException();
  89. }
  90. /// <summary>
  91. /// Returns the local name of the node with qualifiers removed
  92. /// LocalName of ns:elementName = "elementName"
  93. /// </summary>
  94. public override string LocalName
  95. {
  96. get {
  97. return localName;
  98. }
  99. }
  100. /// <summary>
  101. /// Get the qualified node name
  102. /// derived classes must implement as behavior varies
  103. /// by tag type.
  104. /// </summary>
  105. public override string Name
  106. {
  107. get
  108. {
  109. return prefix != String.Empty ? prefix + ":" + localName : localName;
  110. }
  111. }
  112. public override string NamespaceURI
  113. {
  114. get
  115. {
  116. return namespaceURI;
  117. }
  118. }
  119. public override XmlNodeType NodeType
  120. {
  121. get
  122. {
  123. return XmlNodeType.Element;
  124. }
  125. }
  126. public override string Prefix
  127. {
  128. get
  129. {
  130. return prefix;
  131. }
  132. }
  133. // ============= Internal calls =============================================
  134. // Constructors
  135. // ==========================================================================
  136. protected internal XmlElement(string prefix, string localName, string namespaceURI, XmlDocument doc) : base(doc)
  137. {
  138. this.prefix = prefix;
  139. this.localName = localName;
  140. this.namespaceURI = namespaceURI;
  141. _attributes = new XmlAttributeCollection(doc, this, null);
  142. }
  143. } // class
  144. } //namespace