This is a continuation of the Christmas Story in the apocryphal Gospel of James [also sometimes called the “Infancy” Gospel” or the Protoevangelium of James].
The Gospel According to James 15-16.
“Then the Scribe Annas came to him and said to him, “Why didn’t you appear at our assembly?” And Joseph said to him, “Because I was completely worn out from my travel and I had rested only a day.” Then Annas turned and saw the pregnant virgin. Then he left the house quickly and told the top-priest, “Joseph, whom you will witness, has broken the law severely.” And the Priest said, “What is this?” and Annas responded, “The virgin whom he took from the temple of the Lord, he has defiled her. And the priest said to him in response, “Joseph, Joseph did this?” And Annas said, “Send your attendants and you will discover a pregnant virgin.
So the attendants left and they found her, just as he said, and they led her with Joseph to judgment. The priest said, “Mary, why did you do this and lay low your soul and forget the Lord, your God, when you were raised up in the Holiest of Holies and took food from an angel’s hand—you even heard their hymn and you danced among them? Why did you do this?” She wept bitterly, saying, “As the Lord God lives, I am clean before him and I have known no man.”
So then the priest said, “Joseph, why did you do this?” And Joseph responded, “As the Lord, my God lives, I am innocent concerning her.” Then the priest said, “Do not bear false witness, but speak the truth. You hid your marriage and you did not declare it openly to the sons of Israel, and you did not bow your head under the powerful hand so that your seed would be blessed.” Then Joseph was silent.
Then the priest spoke, “Give the virgin whom you took from the temple of the Lord back. And, as he cried, Joseph stood still. Then the Priest said, “I will make you drink the Lord’s water of testing and it will make your sins clear in your eyes.” Then the priest had Joseph drink the water and sent him to the hills. And he came back, whole. He also made the virgin drink and sent her into the hills. She came back too. The whole people wondered at this, that there was no sin revealed among them. And the priest said, “If the Lord God does not make their sin manifest, then I do not judge them and he has freed them.” Then Joseph took Mary and returned to his own home, feeling joy and glorying the god of Israel.”
151 Ἠλθεν δὲ Ἄννας ὁ γραμματεὺς πρὸς αὐτὸν καὶ εἶπεν αὐτῷ: διὰ τί οὐκ ἐφάνης ἐν τῇ συναγωγῇ (συνόδῳ) ἡμῶν; καὶ εἶπεν αὐτῷ Ἰωσήφ: ὅτι κεκμηκὼς ἤμην ἐκ τῆς ὁδοῦ καὶ ἀνεπαυσάμην ἡμέραν μίαν . καὶ ἐστράφη Ἄννας καὶ εἶδεν τὴν παρθένον ὀγκωμένην. 2 καὶ ἀπελθὼν δρομαίως πρὸς τὸν (ἀρχ-)ἱερέα εἶπεν αὐτῷ: Ἰωσήφ, ὅν σὺ μαρτυρεῖς, ἠνόμησε σφόδρα. καὶ εἶπεν ὁ ἱερεύς: τί τοῦτο; καὶ εἶπεν Ἄννας: τὴν παρθένον, ἥν παρέλαβεν ἐκ ναοῦ κυρίου, ἐμίανεν αὐτήν. καὶ ἀποκριθεὶς ὁ ἱερεὺς εἶπεν αὐτῷ: Ἰωσὴφ; Ἰωσὴφ τοῦτο ἐποίησεν; καὶ εἶπεν Ἄννας: ἀπόστειλον ὑπηρέτας καὶ εὑρέσεις τὴν παρθένον ὀγκωμένην. καὶ ἀπῆλθον οἱ ὑπηρέται καὶ εὗρον αὐτήν, καθὼς εἶπεν, καὶ ἀπήγαγον ἅμα τῷ Ἰωσὴφ εἰς τὸ κριτήριον. 3 καὶ εἶπεν ὁ ἱερεύς: Μαριάμ, τί τοῦτο ἐποίησας καὶ ἐταπείνωσας τὴν ψυχήν σου καὶ ἐπελάθου κυρίου τοῦ θεοῦ σου, ἡ ἀνατραφεῖσα εἰς τὰ ἅγια τῶν ἁγίων καὶ λαβοῦσα τροφὴν ἐκ χειρὸς ἀγγέλων, σὺ ἡ ἀκούσασα τὸν ὕμνον αὐτῶν καὶ χορεύσασα ἐνώπιον αὐτῶν; τί τοῦτο ἐποίησας; ἡ δὲ ἔκλαυσε πικρῶς λέγουσα: ζῇ κύριος ὁ θεός, ὅτι καθαρά εἰμι ἐγὼ ἐνώπιον αὐτοῦ καὶ ἄνδρα οὐ γινώσκω. 4 καὶ εἶπεν ὁ ἀρχιερεύς: Ἰωσήφ, τί τοῦτο ἐποίησας; καὶ εἶπεν Ἰωσήφ: ζῇ κύριος ὁ θεός μου, ὅτι καθαρός εἰμι ἐξ αὐτῆς. καὶ εἶπεν ὁ ἀρχιερεύς: μὴ ψευδομαρτύρει, ἀλλὰ λέγε τὸ ἀληθές: ἔκλεψας τοὺς γάμους καὶ οὐκ ἐφανέρωσας τοῖς υἱοῖς Ἰσραήλ, καὶ οὐκ ἔκλινας τὴν κεφαλήν σου ὑπὸ τὴν κραταιὰν χεῖρα, ὅπως εὐλογηθῇ τὸ σπέρμα σου. καὶ Ἰωσὴφ ἐσίγησεν.
16.1 Καὶ εἶπεν ὁ ἱερεύς: ἀπόδος τὴν παρθένον, ἥν παρέλαβες ἐκ ναοῦ κυρίου. καὶ περίδακρυς γενόμενος ὁ Ἰωσὴφ ἔστη. καὶ εἶπεν ὁ ἱερεύς: ποτιῶ ὑμᾶς τὸ ὕδωρ τῆς ἐλέγξεως κυρίου καὶ φανερώσει τὰ ἁμαρτήματα ὑμῶν ἐν ὀφθαλμοῖς ὑμῶν. 2 καὶ λαβὼν ὁ ἱερεὺς ἐπότισε τὸν Ἰωσὴφ καὶ ἔπεμψεν αὐτὸν εἰς τὴν ὀρεινήν: καὶ ἦλθεν ὁλόκληρος. ἐπότισεν δὲ καὶ τὴν παρθένον καὶ ἔπεμψεν καὶ αὐτὴν εἰς τὴν ὀρεινήν: καὶ ἦλθεν ὁλόκληρος, καὶ ἐθαύμασε πᾶς ὁ λαός, ὅτι ἁμαρτία οὐχ εὑρέθη ἐν αὐτοῖς. 3 καὶ εἶπεν ὁ ἱερεύς: εἰ κύριος ὁ θεὸς οὐκ ἐφανέρωσεν τὴν ἁμαρτίαν ὑμῶν, οὐδὲ ἐγὼ κρίνω ὑμᾶς καὶ ἀπέλυσεν αὐτούς. καὶ παρέλαβεν Ἰωσὴφ τὴν Μαριὰμ καὶ ἀπίει εἰς τὸν οἶκον αὐτοῦ χαίρων καὶ δοξάζων τὸν θεὸν τοῦ Ἰσραήλ.