Thanks, for sharing these insightful facts.
Particularly, an entity reference within XML PI and its result upon parsing, which I haven't thought about earlier.
Are entities recognized in comments? For example, in this XML document is a comment which contains an entity:
<Document>
<!-- & -->
</Document>
Will an XML parser replace the entity & with its replacement text &, to yield this:
<Document>
<!-- & -->
</Document>
Are entities recognized in processing instructions? For example, in this XML document is a processing instruction which contains an entity:
<Document>
<?foo & ?>
</Document>
Will an XML parser replace the entity & with its replacement text &, to yield this:
<Document>
<?foo & ?>
</Document>
Scroll down to see the answers ........
No. No.
Entities are not recognized in comments nor processing instructions.
Thus, after parsing the comment and processing instruction still have the unaltered entity:
<Document>
<!-- & -->
</Document>
<Document>
<?foo & ?>
</Document>
--