Rajinder Sidhu, of Crathie Avenue, Dumfries, was on a petition before Sheriff Brian Mahon in private.
The appearance follows an alleged attack at the Tesco car park in Dumfries earlier this month.
A spokesperson for the procurator fiscal said that no plea or declaration was made and Mr Sidhu was committed for further examination.
He was remanded in custody.

The six-time major winner from England, who would be 59 when the event is staged, designed the course in County Fermanagh, Northern Ireland.
"I wouldn't mind giving it a go - I'd love to, that would be a cool thing to do," said Faldo.
Faldo has fond memories of competing in the Irish Open, winning three titles in a row from 1991.
He also won the Open Championship three times while his third victory in the US Masters came in 1996.
Media playback is not supported on this device
The former European Ryder Cup captain now works as a television analyst in the United States.
"I might tee it up and I'll only be 59. I'll see if I can get my TV schedules worked out and get in a bit of practice," added Faldo, speaking after the US Masters finished on Sunday.
George O'Grady, European Tour chief executive, said Faldo would be given a place in the tournament.
"You know he wouldn't just pitch up to make up the numbers - he would go and work on his game to make sure he is a competitor," added O'Grady.
"You don't make rules for players like Nick Faldo."
The Lough Erne course will be staging the Irish Open for the first time, two years after the tournament is held at Royal County Down.
The Irish Open returned to Northern Ireland after a 59-year absence in a hugely-successful staging of the event at Royal Portrush in 2012.
A 30-year-old man has made a brief appearance in court at Dumfries on a charge of rape.
[NEXT_CONCEPT]
Sir Nick Faldo wants to compete in the Irish Open when it comes to Lough Erne for the first time in 2017.