XmlAttribute.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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 FOwner;
  18. private XmlNode FOwnerElement;
  19. string FelementName;
  20. string FattrName;
  21. string FattrValue;
  22. //==== Public Properties ====================================================
  23. /// <summary>
  24. /// Saves all children of the current node to the passed writer
  25. /// </summary>
  26. /// <param name="w"></param>
  27. public override void WriteContentTo(XmlWriter w)
  28. {
  29. // TODO - implement XmlAttribute.WriteContentsTo(XmlWriter)
  30. throw new NotImplementedException();
  31. }
  32. /// <summary>
  33. /// Saves the current node to writer w
  34. /// </summary>
  35. /// <param name="w"></param>
  36. public override void WriteTo(XmlWriter w)
  37. {
  38. // TODO - implement XmlAttribute.WriteTo(XmlWriter)
  39. throw new NotImplementedException();
  40. }
  41. /// <summary>
  42. /// Returns the local name of the attribute. For attributes, this is the same as Name
  43. /// </summary>
  44. public override string LocalName
  45. {
  46. get
  47. {
  48. return Name;
  49. }
  50. }
  51. /// <summary>
  52. /// Get the XmlNode representing the owning document
  53. /// </summary>
  54. public override XmlDocument OwnerDocument
  55. {
  56. get
  57. {
  58. if (FOwner.NodeType == XmlNodeType.Document)
  59. return FOwner as XmlDocument;
  60. else
  61. return null;
  62. }
  63. }
  64. /// <summary>
  65. /// Retrieve the XmlElement owner of this attribute, or null if attribute not assigned
  66. /// </summary>
  67. public virtual XmlElement OwnerElement
  68. {
  69. get
  70. {
  71. if (FOwnerElement.NodeType == XmlNodeType.Element)
  72. return FOwnerElement as XmlElement;
  73. else
  74. return null;
  75. }
  76. }
  77. /// <summary>
  78. /// Get the qualified attribute name. Attributes do not have an associated namespace.
  79. /// </summary>
  80. public override string Name
  81. {
  82. get
  83. {
  84. return Name;
  85. }
  86. }
  87. //============== Public Methods =============================================
  88. /// <summary>
  89. /// Override. Returns the node type.
  90. /// </summary>
  91. public override XmlNodeType NodeType
  92. {
  93. get
  94. {
  95. return XmlNodeType.Attribute;
  96. }
  97. }
  98. /// <summary>
  99. /// Return a clone of the node
  100. /// </summary>
  101. /// <param name="deep">Make copy of all children</param>
  102. /// <returns>Cloned node</returns>
  103. public override XmlNode CloneNode( bool deep)
  104. {
  105. // TODO - implement XmlAttribute.CloneNode()
  106. throw new NotImplementedException();
  107. }
  108. // ============ Internal methods ====================================
  109. internal void setOwnerElement( XmlElement newOwnerElement)
  110. {
  111. FOwnerElement = newOwnerElement;
  112. }
  113. // ============ Constructors =========================================
  114. public XmlAttribute(XmlDocument aOwnerDoc) : base(aOwnerDoc)
  115. {
  116. //
  117. // TODO: Add constructor logic here
  118. //
  119. }
  120. internal XmlAttribute ( XmlDocument aOwner, // owner document
  121. string elementName, // can be ""
  122. string attributeName, // cannot be ""
  123. // attType,
  124. // defaultDecl,
  125. string attValue) : base(aOwner)
  126. {
  127. if (aOwner == null)
  128. throw new ArgumentException("Null OwnerDocument passed to XmlAttribute constructor");
  129. if (attributeName.Length == 0)
  130. throw new ArgumentException("Empty string passed to XmlAttribute constructor");
  131. FOwner = aOwner;
  132. FOwnerElement = null;
  133. FelementName = elementName;
  134. FattrName = attributeName;
  135. FattrValue = attValue;
  136. }
  137. }
  138. }