Well I do not know what are the correct numbers ;).

I perform my tests on small test.xml file and for this file everything is calculated correctly. But I do not know if I do not miss some edge cases in XML.