A hit very early in a text may include text from the very start of the text. If that includes the XML declaration then the hit text will not be valid XML. The first scope marker must be output after the XML declaration.