Fix checking doctype for documents with xml declaration