In "XML serialization of the attributes" (https://w3c.github.io/DOM-Parsing/#serializing-an-element-s-attributes), step 3.5.2.4 reads:
the attr's prefix matches the string "xmlns", then let candidate prefix be the string "xmlns".
I believe this is missing an "If" at the start, based on the structure of the step.