/// <summary> /// Creates a new XmlNamespace element. /// </summary> /// <param name="prefix">The prefix for the namespace.</param> /// <param name="xmlNamespace">The namespace.</param> /// <returns>A new XmlAttribute representing the namespace.</returns> private DynaXmlAttribute CreateNamespace(string prefix, string xmlNamespace) { DynaXmlAttribute namespaceDefinition = new DynaXmlAttribute() { Prefix = "xmlns", LocalName = prefix, XmlNamespace = Xmlns }; this.CurrentNamespaceContext.AliasTable.Add(prefix, xmlNamespace); namespaceDefinition.Value = xmlNamespace; return namespaceDefinition; }
/// <summary> /// Creates an Xml Attribute. /// </summary> /// <param name="name"> /// The name of the attribute. /// </param> /// <param name="value"> /// The value of the attribute. /// </param> /// <returns> /// The new attribute. /// </returns> private DynaXmlAttribute CreateAttribute(string name, string value) { DynaXmlAttribute retval; var currentAlias = this.CurrentNamespaceContext.CurrentAlias; if (!this.CurrentNamespaceContext.ApplyCurrentToAttributes) { retval = new DynaXmlAttribute() { LocalName = name }; } else { retval = new DynaXmlAttribute() { Prefix = currentAlias, LocalName = name, XmlNamespace = this.CurrentNamespaceContext.AliasTable[currentAlias] }; // We've used the current alias so remove it as it is a (use once state) this.CurrentNamespaceContext.CurrentAlias = string.Empty; this.CurrentNamespaceContext.ApplyCurrentToAttributes = false; } retval.Value = value; return retval; }