A judge has ruled that a sex offender who infected at least 13 women with the AIDS virus will get a trial on the state's efforts to have him confined beyond his prison term.