On the return of the attachment and the production of the body of the defendant, the judge has jurisdiction of the matter. The person charged may purge himself of the contempt in the same way, and the same proceeding shall be had, and the same penalties may be imposed, and the same punishment inflicted as in the case of a witness subpenaed to appear and give evidence on the trial of a civil cause before a superior court.