XmlAttribute.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. // -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  2. //
  3. // System.Xml.XmlAttribute
  4. //
  5. // Author:
  6. // Daniel Weber ([email protected])
  7. //
  8. // (C) 2001 Daniel Weberusing System;
  9. namespace System.Xml
  10. {
  11. /// <summary>
  12. /// Summary description for XmlAttribute.
  13. /// </summary>
  14. public class XmlAttribute : XmlNode
  15. {
  16. // ============ private data structures ==============================
  17. private XmlNode FOwnerElement;
  18. string FattrName;
  19. string FattrValue;
  20. //==== Public Properties ====================================================
  21. /// <summary>
  22. /// Returns the local name of the attribute. For attributes, this is the same as Name
  23. /// </summary>
  24. public override string LocalName
  25. {
  26. get
  27. {
  28. return Name;
  29. }
  30. }
  31. /// <summary>
  32. /// Get the qualified attribute name. Attributes do not have an associated namespace.
  33. /// </summary>
  34. public override string Name
  35. {
  36. get
  37. {
  38. return Name;
  39. }
  40. }
  41. /// <summary>
  42. /// Override. Returns the node type.
  43. /// </summary>
  44. public override XmlNodeType NodeType
  45. {
  46. get
  47. {
  48. return XmlNodeType.Attribute;
  49. }
  50. }
  51. /// <summary>
  52. /// Retrieve the XmlElement owner of this attribute, or null if attribute not assigned
  53. /// </summary>
  54. public virtual XmlElement OwnerElement
  55. {
  56. get
  57. {
  58. if (FOwnerElement.NodeType == XmlNodeType.Element)
  59. return FOwnerElement as XmlElement;
  60. else
  61. return null;
  62. }
  63. }
  64. /// <summary>
  65. /// Get/Set the value for this node
  66. /// </summary>
  67. public override string Value
  68. {
  69. get
  70. {
  71. return FattrValue;
  72. }
  73. set
  74. {
  75. FattrValue = value;
  76. }
  77. }
  78. //============== Public Methods =============================================
  79. /// <summary>
  80. /// Return a clone of the node
  81. /// </summary>
  82. /// <param name="deep">Make copy of all children</param>
  83. /// <returns>Cloned node</returns>
  84. public override XmlNode CloneNode( bool deep)
  85. {
  86. // TODO - implement XmlAttribute.CloneNode()
  87. throw new NotImplementedException();
  88. }
  89. /// <summary>
  90. /// Saves all children of the current node to the passed writer
  91. /// </summary>
  92. /// <param name="w"></param>
  93. public override void WriteContentTo(XmlWriter w)
  94. {
  95. // TODO - implement XmlAttribute.WriteContentsTo(XmlWriter)
  96. throw new NotImplementedException();
  97. }
  98. /// <summary>
  99. /// Saves the current node to writer w
  100. /// </summary>
  101. /// <param name="w"></param>
  102. public override void WriteTo(XmlWriter w)
  103. {
  104. // TODO - implement XmlAttribute.WriteTo(XmlWriter)
  105. throw new NotImplementedException();
  106. }
  107. // ============ Internal methods ====================================
  108. internal void setOwnerElement( XmlElement newOwnerElement)
  109. {
  110. FOwnerElement = newOwnerElement;
  111. }
  112. // ============ Constructors =========================================
  113. internal XmlAttribute ( XmlDocument aOwner, // owner document
  114. string attributeName, // cannot be ""
  115. string attValue) : base(aOwner)
  116. {
  117. if (aOwner == null)
  118. throw new ArgumentException("Null OwnerDocument passed to XmlAttribute constructor");
  119. if (attributeName.Length == 0)
  120. throw new ArgumentException("Empty string passed to XmlAttribute constructor");
  121. FOwnerElement = null;
  122. FattrName = attributeName;
  123. FattrValue = attValue;
  124. }
  125. }
  126. }