OAKLAND — A 36-year-old man was charged with week with attacking two UC Berkeley police officers, one of whom suffered a sliced hand, allegedly while attempting to take a 12-inch knife from the suspect, according to court records.

Xavier Shirley, of Oakland, was charged with assaulting a police officer, a felony, possessing a dangerous weapon at school, and a misdemeanor count of battery upon another peace officer. The charging records allege that on Nov. 12, Shirley sliced one officer’s hand with a 12-inch knife, and that another officer suffered a tiny cut while attempting to wrestle the weapon away.

During the arrest, police say they fire a less-lethal launcher at Shirley, sprayed him with pepper spray, hit him with a baton, and used a stun gun on them. In a police report, the arresting officer described all these weapons as “ineffective.”

At Shirley’s first court appearance on Tuesday, he was released from jail and ordered to stay away from UC Berkeley campus. He was also referred to mental health diversion and ordered to “continue treatment” at a local hospital, court records show.

The injured officers were identified in court documents as Eduardo Perez and Weilun Zhao.