legal part is just that, a contract. Its the religious ceremony that means whatever to the participants. If the religion allows bob to marry rex, then they are married and the rest of the world can get over it