VerifyNCName() public static method

public static VerifyNCName ( string name ) : string
name string
return string
Beispiel #1
0
        internal void WriteQualifiedNameInternal(string localName, string ns)
        {
            if (localName == null || localName == String.Empty)
            {
                throw new ArgumentException();
            }
            if (ns == null)
            {
                ns = String.Empty;
            }

#if NET_2_0
            if (Settings != null)
            {
                switch (Settings.ConformanceLevel)
                {
                case ConformanceLevel.Document:
                case ConformanceLevel.Fragment:
                    XmlConvert.VerifyNCName(localName);
                    break;
                }
            }
            else
            {
                XmlConvert.VerifyNCName(localName);
            }
#else
            XmlConvert.VerifyNCName(localName);
#endif

            string prefix = ns.Length > 0 ? LookupPrefix(ns) : String.Empty;
            if (prefix == null)
            {
                throw new ArgumentException(String.Format("Namespace '{0}' is not declared.", ns));
            }

            if (prefix != String.Empty)
            {
                WriteString(prefix);
                WriteString(":");
                WriteString(localName);
            }
            else
            {
                WriteString(localName);
            }
        }
Beispiel #2
0
 /// <summary>Adds the specified <see cref="T:System.Xml.XmlAttribute" />.</summary>
 /// <returns>The XmlAttribute to add.</returns>
 /// <param name="localName">The local name of the attribute. </param>
 /// <param name="namespaceURI">The namespace URI of the attribute. </param>
 public virtual XmlAttribute SetAttributeNode(string localName, string namespaceURI)
 {
     XmlConvert.VerifyNCName(localName);
     return(this.Attributes.Append(this.OwnerDocument.CreateAttribute(string.Empty, localName, namespaceURI, false, true)));
 }