コード例 #1
0
        public static bool IsValidName(string name, out Exception err)
        {
            err = null;
            if (name.Length == 0)
            {
                err = new XmlException("Name can not be an empty string", null);
                return(false);
            }
            char c = name[0];

            if (!XmlConstructs.IsFirstNameChar(c))
            {
                err = new XmlException("The character '" + c + "' cannot start a Name", null);
                return(false);
            }
            for (int i = 1; i < name.Length; i++)
            {
                c = name[i];
                if (!XmlConstructs.IsNameChar(c))
                {
                    err = new XmlException("The character '" + c + "' is not allowed in a Name", null);
                    return(false);
                }
            }
            return(true);
        }
コード例 #2
0
 public static bool IsNmToken(string str)
 {
     if (str.Length == 0)
     {
         return(false);
     }
     for (int i = 0; i < str.Length; i++)
     {
         if (!XmlConstructs.IsNameChar(str[i]))
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #3
0
 public static bool IsValidNmtoken(string nmtoken, out Exception err)
 {
     err = null;
     if (nmtoken.Length == 0)
     {
         err = new XmlException("NMTOKEN can not be an empty string", null);
         return(false);
     }
     foreach (char c in nmtoken)
     {
         if (!XmlConstructs.IsNameChar(c))
         {
             err = new XmlException("The character '" + c + "' is not allowed in a NMTOKEN", null);
             return(false);
         }
     }
     return(true);
 }
コード例 #4
0
 public static int IsValidName(string name)
 {
     if (name.Length == 0)
     {
         return(0);
     }
     if (!XmlConstructs.IsFirstNameChar(name[0]))
     {
         return(0);
     }
     for (int i = 1; i < name.Length; i++)
     {
         if (!XmlConstructs.IsNameChar(name[i]))
         {
             return(i);
         }
     }
     return(-1);
 }