Here's the link to the Swedish Act of Succession:
The bullet points are as follows:
Only children born in wedlock may inherit the Throne
Only the descendants of Carl XVI Gustaf may inherit the Throne.
A prince or princess in the line of succession shall belong to and profess the "pure evangelical faith", as defined in the Unaltered Augsburg Confession and the Uppsala Meeting of 1591, i.e. by implication the Church of Sweden.
The offspring of an approved marriage must be brought up within Sweden.
A prince or princess may not marry and remain in the line of succession without having received consent, upon application of the Monarch, from the Government of Sweden.
A prince or princess is also prevented from becoming monarch of another country, either by election or marriage, without the consent of the Monarch and the Government.
If any of these provisions are violated: all rights of succession for the person concerned and all descendants are lost.
It's not clear what constitute "legitimate"? Does the child have to be conceived and born in wedlock?