You don't normally need to use this Lex module directly - it is
called automatically by the parser. (This interface is only exposed
for debugging purposes.)

This is a hand-written lexer for tokenising the text of an XML
document so that it is ready for parsing. It attaches position
information in (line,column) format to every token. The main
entry point is xmlLex. A secondary entry point, xmlReLex, is
provided for when the parser needs to stuff a string back onto
the front of the text and re-tokenise it (typically when expanding
macros).

As one would expect, the lexer is essentially a small finite
state machine.

reLexEntityValue is used solely within parsing an entityvalue.
Normally, a PERef is logically separated from its surroundings by
whitespace. But in an entityvalue, a PERef can be juxtaposed to
an identifier, so the expansion forms a new identifier.
Thus the need to rescan the whole text for possible PERefs.