A Sydney man who bound, choked and then filmed himself raping a seven-year-old girl in the bathroom of a dance studio in Kogarah, in southern Sydney, will die in jail.

Key points: Anthony Sampieri sexually assaulted the young girl for 40 minutes

Anthony Sampieri sexually assaulted the young girl for 40 minutes He slashed people who tried to save the girl in 2018 with a knife

He slashed people who tried to save the girl in 2018 with a knife He was on parole at the time of his attack

Judge Paul Conlon sentenced Anthony Sampieri, 56, to life in prison for the brutal attack and sexual assault of the primary school girl in November, 2018.

In sentencing, the judge said the rape was "marked by a complete lack of empathy" and described it as "every parent's worst nightmare".

Sampieri, who was asked by the judge to stand for his sentencing, was told his crimes were "so grave" they warranted the maximum penalty.

Anthony Sampieri raped a girl in a dance studio toilet cubicle. ( ABC News )

The 56-year-old pleaded guilty to 10 charges related to the rape, including three counts of having sexual intercourse with a child and seven charges related to sexually explicit and harassing phone calls he made to women in the weeks before the attack.

In November 2018, he was out on parole and high on ice when he wandered into the Kogarah dance studio and grabbed the young girl.

He punched her in the face, threatened her with a knife, tied a cord around her neck and then raped her in the men's toilet cubicle for 40 minutes.

A court heard Sampieri filmed at least four-and-a-half minutes of the attack on a mobile phone.

Parents attending a class down the hall searched for the girl and eventually saved her after bashing down the door of the toilet.

Judge Conlon said Sampieri attacked them with his knife and managed to cut the victim's mother's hand as she tried to pry her daughter, whose wrists were bound, away from him.

Police at the Kogarah dance studio where a seven-year-old girl was raped. ( ABC News )

Nick Gilio, a diesel mechanic and father of another child at the studio, was stabbed in the stomach and neck during the scuffle and said he was left traumatised by the ordeal.

Outside court, he said it was an "honour to have ... freed [the victim] from the hands of evil."

In court, Acting Judge Conlon praised Mr Gilio for his efforts to save the girl while injured.

"To you sir, I would say this: the victim, her family, everyone at the dance school and indeed the whole community are indebted to you for the courage you displayed in the face of a person wielding a knife and in successfully subduing and detaining the offender."

Nick Gilio, who was stabbed several times by Sampieri, spoke outside the court after the sentencing. ( AAP: Bianca De Marchi )

The court heard from the notes of a psychiatrist who assessed Sampieri, that claimed he couldn't remember the assault.

The convicted paedophile apologised for the attack during a hearing in the NSW District Court on Friday.

"I am so sorry for what I did," he said.

Sampieri also blamed the "insanity" of his actions on the drug ice.

Judge Conlon rejected characterisations the crime was "spontaneous", "opportunistic" or was an extension of Sampieri's long history of drug abuse.

The court heard Sampieri used a cord from his shorts and another cord he found in a bin in Kogarah to restrain the girl's hands to give himself time to escape.

"He had prepared himself to seize an opportunity to act out one of his fantasies, which he did," the judge said.

He said the young victim would have to struggle with lifelong trauma and could even be triggered by entering the toilets in her own home.

Sampieri is being treated for liver cancer and is being held in isolation at Long Bay Prison Hospital.

At a sentencing hearing on Friday, he was asked if he expected doctors would be able to cure him.

"I don't think so," he said.