A test file we wrote to break our own DOCX reader used x:vanish instead of w:vanish. Same namespace, a different prefix. Our rule matched neither, because what it matched was a string.
We were building screenfence, our open-source checker for text hidden inside Word documents. The first version of the reader did the obvious thing: walk the tokens, compare the tag name against the one we cared about, flag it. That holds up right until a document renames its own prefixes, which it is fully allowed to do. The file was hiding text. We passed it.
What changed after that afternoon:
Every element and attribute name now resolves to a pair, namespace URI plus local name, by walking the declared scopes from the innermost outward, binding the reserved xml prefix to its fixed namespace and refusing an undeclared prefix outright instead of guessing. Both spellings of that tag canonicalize to the same name, so we write the rule once.
The second lesson was bigger. The reader expands nothing a document says about itself. A part that opens with a doctype is refused immediately, before an entity table could even exist. Any other declaration is malformed and stops there. In text and in attribute values we resolve the five predefined entities and numeric references, and nothing else, and a numeric reference only if the code point is a legal XML character, which rules out null, control characters, surrogates and anything past the top of Unicode.
Every refusal carries a code and the byte offset where it happened. Depth is capped at 64 before we look at anything else, and the root element has to sit in an allowed namespace set, both the Transitional and the Strict office URIs, or it never gets read at all.
The habit we would pass on from this: when you parse a file someone uploaded, treat the document's own self-description as input to reject, not configuration to obey. A best-effort parse of a hostile file is a security decision made by accident.
For those of you parsing user-supplied XML, you face the choice we did: surface the refusal offset back to the uploader, or only the reason. We went back and forth on how much to reveal.