Alleged sex offender collapses in dock