/// <summary> /// Returns the result of GetPrefixOfNamespace on the current node. /// </summary> /// <param name="ns">The namespaceURI to lookup the associated prefix for.</param> /// <returns>The prefix or <see langword="null"/> if no matching namespaceURI is in scope.</returns> public override string LookupPrefix(string ns) { /* applied fixes from www.gotdotnet.com * return current.GetPrefixOfNamespace(ns); */ string prefix = current.GetPrefixOfNamespace(ns); if (prefix == string.Empty && current.GetNamespaceOfPrefix(prefix) != ns) { return(null); } return(prefix); }
public override string LookupPrefix(string ns) { CheckState(); if (current == null) { throw new InvalidOperationException(); } return(current.GetPrefixOfNamespace(ns)); }
public static XmlNode AddElement( XmlNode node, MemberInfo member) { string prefix = ""; if( member.NamespaceURI != null ) { prefix = node.GetPrefixOfNamespace( member.NamespaceURI ); if( prefix.Length > 0 ) prefix += ":"; } XmlDocument doc = node.OwnerDocument; if (doc == null) doc = (XmlDocument)node; XmlNode newNode = doc.CreateElement(prefix + member.LocalName, member.NamespaceURI); node.AppendChild(newNode); return newNode; }
static string FindPrefixForNamespace(XmlNode node, string uri) { if (uri == "http://www.w3.org/XML/1998/namespace") return "xml"; return node.GetPrefixOfNamespace(uri); }
public static void SetValue(XmlNode node, MemberInfo member, Altova.Types.QName qn) { if (qn.Uri == null) { SetValue(node, member, qn.LocalName); return; } string prefix = node.GetPrefixOfNamespace(qn.Uri); if (prefix == null || prefix.Length == 0) { prefix = FindUnusedPrefix(node, qn.Prefix); ((XmlElement)node).SetAttribute("xmlns:" + prefix, qn.Uri); } SetValue(node, member, prefix + ":" + qn.LocalName); }
public static void SetValue( XmlNode node, MemberInfo member, string value) { if (member.LocalName != "") { string prefix = ""; if( member.NamespaceURI != "" ) { prefix = node.GetPrefixOfNamespace( member.NamespaceURI ); if( prefix.Length > 0 ) prefix += ":"; else prefix = FindUnusedPrefix(node) + ":"; } XmlElement el = (XmlElement) node; XmlAttribute attr = node.OwnerDocument.CreateAttribute(prefix + member.LocalName, member.NamespaceURI); attr.Value = value; el.SetAttributeNode(attr); } else node.InnerText = value; }
public static void SetAttribute(XmlNode node, string localName, string namespaceURI, XmlQualifiedName value) { XmlAttribute att = node.OwnerDocument.CreateAttribute(localName, namespaceURI); if (value.Namespace == null || value.Namespace == "") { att.Value = value.Name; } else { string prefix = node.GetPrefixOfNamespace(value.Namespace); if (prefix == null || prefix == "") { prefix = FindUnusedPrefix(node); XmlAttribute nsatt = node.OwnerDocument.CreateAttribute("xmlns", prefix, "http://www.w3.org/2000/xmlns/"); nsatt.Value = value.Namespace; node.Attributes.Append(nsatt); } att.Value = prefix + ":" + value.Name; } node.Attributes.Append(att); }