public static string VerifyTOKEN(string token) { if (token == null) { throw new ArgumentNullException("token"); } if (token.Length == 0) { return(token); } if (XmlChar.IsWhitespace(token [0]) || XmlChar.IsWhitespace(token [token.Length - 1])) { throw new XmlException("Whitespace characters (#xA, #xD, #x9, #x20) are not allowed as leading or trailing whitespaces of xs:token."); } for (int i = 0; i < token.Length; i++) { if (XmlChar.IsWhitespace(token [i]) && token [i] != ' ') { throw new XmlException("Either #xA, #xD or #x9 are not allowed inside xs:token."); } } return(token); }
public virtual XmlWhitespace CreateWhitespace(string text) { if (!XmlChar.IsWhitespace(text)) { throw new ArgumentException("Invalid whitespace characters."); } return(new XmlWhitespace(text, this)); }
private int SkipIgnorableBase64Chars(char [] chars, int charsLength, int i) { while (chars [i] == '=' || XmlChar.IsWhitespace(chars [i])) { if (charsLength == ++i) { break; } } return(i); }
public static string VerifyWhitespace(string content) { if (content == null) { throw new ArgumentNullException("content"); } if (XmlChar.IsWhitespace(content)) { return(content); } throw new XmlException(string.Format("'{0}' is not whitespace", content)); }
private int SkipWhitespace(string input, int index) { while (index < input.Length) { if (XmlChar.IsWhitespace(input [index])) { index++; } else { break; } } return(index); }
public static bool IsWhitespaceChar(char ch) { return(XmlChar.IsWhitespace(ch)); }
void ParseInput(string input) { int index = SkipWhitespace(input, 0); if (index + 7 > input.Length || input.IndexOf("version", index, 7) != index) { throw new XmlException("Missing 'version' specification."); } index = SkipWhitespace(input, index + 7); char c = input [index]; if (c != '=') { throw new XmlException("Invalid 'version' specification."); } index++; index = SkipWhitespace(input, index); c = input [index]; if (c != '"' && c != '\'') { throw new XmlException("Invalid 'version' specification."); } index++; int end = input.IndexOf(c, index); if (end < 0 || input.IndexOf("1.0", index, 3) != index) { throw new XmlException("Invalid 'version' specification."); } index += 4; if (index == input.Length) { return; } if (!XmlChar.IsWhitespace(input [index])) { throw new XmlException("Invalid XML declaration."); } index = SkipWhitespace(input, index + 1); if (index == input.Length) { return; } if (input.Length > index + 8 && input.IndexOf("encoding", index, 8) > 0) { index = SkipWhitespace(input, index + 8); c = input [index]; if (c != '=') { throw new XmlException("Invalid 'version' specification."); } index++; index = SkipWhitespace(input, index); c = input [index]; if (c != '"' && c != '\'') { throw new XmlException("Invalid 'encoding' specification."); } end = input.IndexOf(c, index + 1); if (end < 0) { throw new XmlException("Invalid 'encoding' specification."); } Encoding = input.Substring(index + 1, end - index - 1); index = end + 1; if (index == input.Length) { return; } if (!XmlChar.IsWhitespace(input [index])) { throw new XmlException("Invalid XML declaration."); } index = SkipWhitespace(input, index + 1); } if (input.Length > index + 10 && input.IndexOf("standalone", index, 10) > 0) { index = SkipWhitespace(input, index + 10); c = input [index]; if (c != '=') { throw new XmlException("Invalid 'version' specification."); } index++; index = SkipWhitespace(input, index); c = input [index]; if (c != '"' && c != '\'') { throw new XmlException("Invalid 'standalone' specification."); } end = input.IndexOf(c, index + 1); if (end < 0) { throw new XmlException("Invalid 'standalone' specification."); } string tmp = input.Substring(index + 1, end - index - 1); switch (tmp) { case "yes": case "no": break; default: throw new XmlException("Invalid standalone specification."); } Standalone = tmp; index = end + 1; index = SkipWhitespace(input, index); } if (index != input.Length) { throw new XmlException("Invalid XML declaration."); } }