private void CheckWhitespace(string value) { int i; if ((i = _xmlCharType.IsOnlyWhitespaceWithPos(value)) != -1) { Throw(ResXml.Xml_InvalidWhitespaceCharacter, XmlException.BuildCharExceptionArgs(value, i)); } }
// Verification method for XML whitespace characters as defined in XML spec production [3] S. // Throws XmlException if invalid character is found, otherwise returns the input string. public static string VerifyWhitespace(string content) { if (content == null) { throw new ArgumentNullException(nameof(content)); } // returns the position of invalid character or -1 int pos = s_xmlCharType.IsOnlyWhitespaceWithPos(content); if (pos != -1) { throw new XmlException(SR.Xml_InvalidWhitespaceCharacter, XmlException.BuildCharExceptionArgs(content, pos), 0, pos + 1); } return(content); }
public override void WriteWhitespace(string ws) { if (ws == null) { ws = string.Empty; } // "checkNames" is intentional here; if false, the whitespaces are checked in XmlWellformedWriter if (_checkNames) { int i; if ((i = _xmlCharType.IsOnlyWhitespaceWithPos(ws)) != -1) { throw new ArgumentException(string.Format(ResXml.Xml_InvalidWhitespaceCharacter, XmlException.BuildCharExceptionArgs(ws, i))); } } if (_replaceNewLines) { ws = ReplaceNewLines(ws); } writer.WriteWhitespace(ws); }