Fix invalid xml

Replace invalid characters with entities.
Fix "--" inside XML comments.
Enclose attribute values in quotes.
Fix invalid <iref> and <sref> elements.