It strains credulity that an empire wherein the bloodline of the ruler is critical would have laws which both allowed an inevitably infertile match and which prevented alternative parentage. Bastards were traditionally a problem in noble lines precisely because they could inherit, and it was a sticky question as to whether they could inherit ahead of younger legitimate half-siblings. It was generally - though not always - considered binding if the noble in question recognized one of his bastard children and declared him in the line of succession. (Female nobility had it a little easier; it's clearly her kid, and whether it's a bastard or not is not provable pre-DNA unless she's known to not be married.)

But they did consider the bloodline to be sufficient to make a case. In this empire, the bloodline is literally the source of the protective magic. So the laws would be carefully written to ensure that, whatever happened, the Emperor's blood progeny (and relatives) would be eligible for the throne.

Therefore, even if the laws allow for same-sex unions with legal force equal to marriage, they would NOT be written to preclude a heterosexual union between the Emperor and a fertile mate from producing an heir in the event that the Emperor's designated Queen or Prince-Consort were unable to produce one (for any reason).

In fact, if anything, this would be a strong reason to have a law which, even if this is normally not permitted, gave the Emperor a legal right (and perhaps responsibility) to have a harem of wives and concubines, the children of which are all considered legitimate. Even if nobody else is permitted this, it makes sense due to the national security concerns surrounding the imperial bloodline. If the Emperor (or Empress) happens to ALSO fill it with members of his (or her) own sex for his...personal taste...that's his (or her) prerogative. Though that would open sticky questions of the parentage of the harem-produced children, since the mixed-sex harem could be *ahem* entertaining itself. At least with a male Emperor. A female Empress obviously is going to know which kids are hers.