Exemplo n.º 1
0
        public static bool IsValidNCName(string ncName, out Exception err)
        {
            err = null;
            if (ncName.Length == 0)
            {
                err = new XmlException("NCName can not be an empty string", null);
                return(false);
            }
            char c = ncName[0];

            if (!XmlConstructs.IsNCNameStart(c))
            {
                err = new XmlException("The character '" + c + "' cannot start a NCName", null);
                return(false);
            }
            for (int i = 1; i < ncName.Length; i++)
            {
                c = ncName[i];
                if (!XmlConstructs.IsNCNameChar(c))
                {
                    err = new XmlException("The character '" + c + "' is not allowed in a NCName", null);
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 2
0
 public static bool IsWhitespace(string str)
 {
     for (int i = 0; i < str.Length; i++)
     {
         if (!XmlConstructs.IsWhitespace(str[i]))
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
0
 public static bool IsInvalid(int c)
 {
     return(!XmlConstructs.IsValid(c));
 }