internal static XmlDocument PreProcessDocumentInput( XmlDocument document, XmlResolver xmlResolver, string baseUri) { if (document == null) { throw new ArgumentNullException(nameof(document)); } Exml exml = new Exml(); exml.PreserveWhitespace = document.PreserveWhitespace; using (TextReader input = (TextReader) new StringReader(document.OuterXml)) { XmlReader reader = XmlReader.Create(input, new XmlReaderSettings() { XmlResolver = xmlResolver, DtdProcessing = DtdProcessing.Parse, MaxCharactersFromEntities = 10000000L, MaxCharactersInDocument = 0 }, baseUri); exml.Load(reader); } return((XmlDocument)exml); }