Fix XMLSCHEMA-64

`visitedElements` prevents infinite recursion, but assumes all elements
have unique names. This assumption is wrong for non-toplevel elements,
causing elements not to be walked when they should.

But at any start of infinite recursion, the type instance has been
previously visited: either because we've seen the element, or because a
different element refers to the same type.
And as type references resolve the target instance (not a copy, unlike
elements!), we can use type instances to detect infinite recursion.
3 files changed