Пример #1
0
        /// <summary>
        /// Adds new attribute node to the element.
        /// </summary>
        /// <param name="attribute">The attribute node.</param>
        /// <returns>Old node if the attribute has been replaced or <B>null</B>.</returns>
        public virtual DOMAttr setAttributeNodeNS(DOMAttr attribute)
        {
            if (!IsAssociated)
            {
                DOMException.Throw(ExceptionCode.DomModificationNotAllowed);
                return(null);
            }

            attribute.Associate(XmlElement.OwnerDocument);

            if (XmlNode.OwnerDocument != attribute.XmlNode.OwnerDocument)
            {
                DOMException.Throw(ExceptionCode.WrongDocument);
                return(null);
            }

            XmlAttribute attr = XmlElement.Attributes[attribute.localName, attribute.namespaceURI];

            if (attr != null)
            {
                XmlElement.Attributes.Remove(attr);
                XmlElement.Attributes.Append(attribute.XmlAttribute);
                return(new DOMAttr(attr));
            }
            else
            {
                XmlElement.Attributes.Append(attribute.XmlAttribute);
                return(null);
            }
        }
Пример #2
0
 protected override DOMNode CloneObjectInternal(bool deepCopyFields)
 {
     if (IsAssociated)
     {
         return(new DOMAttr(XmlAttribute));
     }
     else
     {
         DOMAttr copy = new DOMAttr();
         copy.__construct(this._name, this._value);
         return(copy);
     }
 }
Пример #3
0
        /// <summary>
        /// Removes an attribute node from the element.
        /// </summary>
        /// <param name="attribute">The attribute node.</param>
        /// <returns>Old node if the attribute has been removed or <B>null</B>.</returns>
        public virtual DOMAttr removeAttributeNode(DOMAttr attribute)
        {
            if (!IsAssociated)
            {
                DOMException.Throw(ExceptionCode.DomModificationNotAllowed);
                return(null);
            }

            XmlAttribute attr = XmlElement.Attributes[attribute.nodeName];

            if (attr == null)
            {
                DOMException.Throw(ExceptionCode.NotFound);
                return(null);
            }

            XmlElement.Attributes.Remove(attr);

            return(attribute);
        }
Пример #4
0
 /// <summary>
 /// Not implemented in PHP 5.1.6.
 /// </summary>
 public virtual void setIdAttributeNode(DOMAttr attribute, bool isId)
 {
     throw new NotImplementedException();
 }