Q: MaxCharactersInDocument validation don't work I try to validate maximum characters in xml document:
string xml = "<X><Y><Z></Z><Z></Z><Z></Z></Y></X>";

var settings = new XmlReaderSettings
                {
                    MaxCharactersInDocument = 10
                };

try
{
    using(var sr = new StringReader(xml))
    {
        using(var xr = XmlReader.Create(sr))
        {
            using(var xr2 = XmlReader.Create(xr, settings))
            {
                while(xr2.Read()){} // MaxCharactersInDocument validation do not work
            }
        }
    }
}
catch (XmlException ex)
{
    Console.WriteLine(ex.Message);
}

The porpose is to validate external xml(received with XmlReader) for maximum charcters. Why MaxCharactersInDocument validation don't work for XmlReader created on another XmlReader? How can I do this validation differently?
Also, scheme validation works for second reader but max characters validation don't.

A: Taking a look at a MSDN's working example for MaxCharactersInDocument, 
The following will also work with your input:
        string markup = "<X><Y><Z></Z><Z></Z><Z></Z></Y></X>";

        //string markup = "<Root>Content</Root>";

        XmlReaderSettings settings = new XmlReaderSettings();
        settings.MaxCharactersInDocument = 10;

    try
    {
        XmlReader reader = XmlReader.Create(new StringReader(markup), settings);
        while (reader.Read()) { }
    }
    catch (XmlException ex)
    {
        Console.WriteLine(ex.Message);
    }

Seems the StringReader object should be used as input in the XmlReader.Create method for it to work.

Output:

