This here is pretty strange.
You state that crr.contextRegistration has an entityIdVector present when it is not true.
I guess you have your reasons but I don't get it.

If you waited with this statement until after a vector of entity ids is added to crr.contextRegistration I would find it easier to understand ...

Just for info: the field entityIdVectorPresent is used to catch that a '<entityIdList>' has been parsed.
Later, a check is done to see if any entity ids are present in the vector.
If entityIdVectorPresent is true and the number of entity ids present in the vector is zero, then we have parsed the following non-XSD statement:

        <entityIdList></entityIdList>