Use AutoPtr for a Document re #8485

Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk>
Tidy up code a little re #8485

Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk>
Merge branch 'feature/8485_poco_xml_autoptr' into develop