public virtual void SetAttribute(string name, string value) { XmlAttribute attribute = OwnerDocument.CreateAttribute(name); attribute.Value = value; Attributes.SetNamedItem(attribute); }
protected override DomObject SetNameCore(DomName name) { var newAttr = OwnerDocument.CreateAttribute(name); newAttr.DomValue = DomValue.Clone(); newAttr.CopyAnnotationsFrom(AnnotationList); return(ReplaceWith(newAttr)); }
protected virtual DomAttribute CloneCore() { var result = OwnerDocument.CreateAttribute(Name, Value); result.DomValue = DomValue.Clone(); result.CopyAnnotationsFrom(AnnotationList); return(result); }
public virtual XmlAttribute SetAttributeNode(string localName, string namespaceURI) { // Note that this constraint is only for this method. // SetAttribute() allows prefixed name. XmlConvert.VerifyNCName(localName); return(Attributes.Append(OwnerDocument.CreateAttribute(String.Empty, localName, namespaceURI, false, true))); }
// Clone this node in either shallow or deep mode. public override XmlNode CloneNode(bool deep) { XmlAttribute attr = OwnerDocument.CreateAttribute (Prefix, LocalName, NamespaceURI); attr.CloneChildrenFrom(this, true); return(attr); }
/// <include file='doc\XmlAttribute.uex' path='docs/doc[@for="XmlAttribute.CloneNode"]/*' /> /// <devdoc> /// <para> /// Creates a duplicate of this node. /// </para> /// </devdoc> public override XmlNode CloneNode(bool deep) { // CloneNode for attributes is deep irrespective of parameter 'deep' value Debug.Assert(OwnerDocument != null); XmlAttribute attr = OwnerDocument.CreateAttribute(Prefix, LocalName, NamespaceURI); attr.CopyChildren(this, true); return(attr); }
// Adds the specified XmlAttribute. public virtual XmlAttribute SetAttributeNode(string localName, string namespaceURI) { XmlAttribute attr = GetAttributeNode(localName, namespaceURI); if (attr == null) { attr = OwnerDocument.CreateAttribute(string.Empty, localName, namespaceURI); Attributes.InternalAppendAttribute(attr); } return(attr); }
public IAttribute Add(string name, string @namespace) { XmlAttribute nativeAttribute = OwnerDocument.CreateAttribute(name, @namespace); Attributes.Append(nativeAttribute); IAttribute attribute = new Attribute(nativeAttribute); if (_attributes != null) { _attributes.Add(attribute); } return(attribute); }
public override XmlNode CloneNode(bool deep) { XmlNode node = OwnerDocument.CreateAttribute(name.Prefix, name.LocalName, name.NS, true, false); if (deep) { for (XmlNode n = FirstChild; n != null; n = n.NextSibling) { node.AppendChild(n.CloneNode(deep), false); } } return(node); }
// Sets the value of the attribute // with the specified name. public virtual void SetAttribute(string name, string?value) { XmlAttribute?attr = GetAttributeNode(name); if (attr == null) { attr = OwnerDocument.CreateAttribute(name); attr.Value = value; Attributes.InternalAppendAttribute(attr); } else { attr.Value = value; } }
public virtual void SetAttribute(string name, string value) { XmlAttribute attr = Attributes [name]; if (attr == null) { attr = OwnerDocument.CreateAttribute(name); attr.Value = value; Attributes.SetNamedItem(attr); } else { attr.Value = value; } }
// Create a new attribute node and return it. public virtual XmlAttribute SetAttributeNode (String localName, String namespaceURI) { XmlAttribute attr = GetAttributeNode(localName, namespaceURI); if (attr != null) { attr = OwnerDocument.CreateAttribute (localName, namespaceURI); /* TODO : figure out if this is better done lower down */ attr.parent = this; Attributes.Append(attr); } return(attr); }
public virtual string SetAttribute(string localName, string namespaceURI, string value) { XmlAttribute attr = Attributes [localName, namespaceURI]; if (attr == null) { attr = OwnerDocument.CreateAttribute(localName, namespaceURI); attr.Value = value; Attributes.SetNamedItem(attr); } else { attr.Value = value; } return(attr.Value); }
public virtual string?SetAttribute(string localName, string?namespaceURI, string?value) { XmlAttribute?attr = GetAttributeNode(localName, namespaceURI); if (attr == null) { attr = OwnerDocument.CreateAttribute(string.Empty, localName, namespaceURI); attr.Value = value; Attributes.InternalAppendAttribute(attr); } else { attr.Value = value; } return(value); }
// Set an attribute to a specific value. public virtual void SetAttribute(String name, String value) { XmlAttribute attr = GetAttributeNode(name); if (attr != null) { attr.Value = value; } else { attr = OwnerDocument.CreateAttribute(name); attr.Value = value; /* TODO : figure out if this is better done lower down */ attr.parent = this; Attributes.Append(attr); } }
// Set an attribute to a specific value. public virtual String SetAttribute (String localName, String namespaceURI, String value) { XmlAttribute attr = GetAttributeNode(localName, namespaceURI); if (attr != null) { attr.Value = value; } else { attr = OwnerDocument.CreateAttribute (localName, namespaceURI); attr.Value = value; Attributes.Append(attr); } return(attr.Value); }
public DomAttribute CreateAttribute(DomName name) { return(OwnerDocument.CreateAttribute(name)); }
public DomAttribute CreateAttribute(DomName name, IDomValue value) { return(OwnerDocument.CreateAttribute(name, value)); }
public DomAttribute CreateAttribute(string name, string value) { return(OwnerDocument.CreateAttribute(name, value)); }
public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc) { Hashtable nsLocallyDeclared = new Hashtable(); SortedList nsListToRender = new SortedList(new NamespaceSortOrder()); SortedList attrListToRender = new SortedList(new AttributeSortOrder()); UTF8Encoding utf8 = new UTF8Encoding(false); byte[] rgbData; XmlAttributeCollection attrList = Attributes; if (attrList != null) { foreach (XmlAttribute attr in attrList) { if (((CanonicalXmlAttribute)attr).IsInNodeSet || Utils.IsNamespaceNode(attr) || Utils.IsXmlNamespaceNode(attr)) { if (Utils.IsNamespaceNode(attr)) { anc.TrackNamespaceNode(attr, nsListToRender, nsLocallyDeclared); } else if (Utils.IsXmlNamespaceNode(attr)) { anc.TrackXmlNamespaceNode(attr, nsListToRender, attrListToRender, nsLocallyDeclared); } else if (IsInNodeSet) { attrListToRender.Add(attr, null); } } } } if (!Utils.IsCommittedNamespace(this, Prefix, NamespaceURI)) { string name = ((Prefix.Length > 0) ? "xmlns" + ":" + Prefix : "xmlns"); XmlAttribute nsattrib = (XmlAttribute)OwnerDocument.CreateAttribute(name); nsattrib.Value = NamespaceURI; anc.TrackNamespaceNode(nsattrib, nsListToRender, nsLocallyDeclared); } if (IsInNodeSet) { anc.GetNamespacesToRender(this, attrListToRender, nsListToRender, nsLocallyDeclared); rgbData = utf8.GetBytes("<" + Name); hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0); foreach (object attr in nsListToRender.GetKeyList()) { (attr as CanonicalXmlAttribute).WriteHash(hash, docPos, anc); } foreach (object attr in attrListToRender.GetKeyList()) { (attr as CanonicalXmlAttribute).WriteHash(hash, docPos, anc); } rgbData = utf8.GetBytes(">"); hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0); } anc.EnterElementContext(); anc.LoadUnrenderedNamespaces(nsLocallyDeclared); anc.LoadRenderedNamespaces(nsListToRender); XmlNodeList childNodes = ChildNodes; foreach (XmlNode childNode in childNodes) { CanonicalizationDispatcher.WriteHash(childNode, hash, docPos, anc); } anc.ExitElementContext(); if (IsInNodeSet) { rgbData = utf8.GetBytes("</" + Name + ">"); hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0); } }
public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc) { Hashtable nsLocallyDeclared = new Hashtable(); SortedList nsListToRender = new SortedList(new NamespaceSortOrder()); SortedList attrListToRender = new SortedList(new AttributeSortOrder()); XmlAttributeCollection attrList = Attributes; if (attrList != null) { foreach (XmlAttribute attr in attrList) { if (((CanonicalXmlAttribute)attr).IsInNodeSet || Utils.IsNamespaceNode(attr) || Utils.IsXmlNamespaceNode(attr)) { if (Utils.IsNamespaceNode(attr)) { anc.TrackNamespaceNode(attr, nsListToRender, nsLocallyDeclared); } else if (Utils.IsXmlNamespaceNode(attr)) { anc.TrackXmlNamespaceNode(attr, nsListToRender, attrListToRender, nsLocallyDeclared); } else if (IsInNodeSet) { attrListToRender.Add(attr, null); } } } } if (!Utils.IsCommittedNamespace(this, Prefix, NamespaceURI)) { string name = ((Prefix.Length > 0) ? "xmlns" + ":" + Prefix : "xmlns"); XmlAttribute nsattrib = (XmlAttribute)OwnerDocument.CreateAttribute(name); nsattrib.Value = NamespaceURI; anc.TrackNamespaceNode(nsattrib, nsListToRender, nsLocallyDeclared); } if (IsInNodeSet) { anc.GetNamespacesToRender(this, attrListToRender, nsListToRender, nsLocallyDeclared); strBuilder.Append('<').Append(Name); foreach (object attr in nsListToRender.GetKeyList()) { (attr as CanonicalXmlAttribute).Write(strBuilder, docPos, anc); } foreach (object attr in attrListToRender.GetKeyList()) { (attr as CanonicalXmlAttribute).Write(strBuilder, docPos, anc); } strBuilder.Append('>'); } anc.EnterElementContext(); anc.LoadUnrenderedNamespaces(nsLocallyDeclared); anc.LoadRenderedNamespaces(nsListToRender); XmlNodeList childNodes = ChildNodes; foreach (XmlNode childNode in childNodes) { CanonicalizationDispatcher.Write(childNode, strBuilder, docPos, anc); } anc.ExitElementContext(); if (IsInNodeSet) { strBuilder.Append("</" + Name + ">"); } }