Montessorisam - I have experience of these cases (as an advocate). Advocates are not monsters, they are also not stupid, and "taking apart" a victim is a really good way to get a guilty verdict. If you know which court it is in advance, go in and have a look round to familiarise yourself with it. When you get there, go straight to Victim Support / Witness Support and explain how nervous you are. They will help.
In court, don't look at your ex and talk to the judge not the advocate. Direct your answers to the magistrates / district judge - so the advocate says "What is your name?" - you turn slightly away from him / her so you are facing the bench and respond "Montessorisam, sir / madam / your worships." If you have a district judge, they are sir or madam. If you have a panel of three magistrates you either use sir / madam (depending on the one in the middle who is the chair) or 'your worships.'
Don't be afraid to disagree with the advocate. They say "This text was nothing more than a polite enquiry into your health, wasn't it Ms Sam?" - it is perfectly acceptable to say "No, you're completely wrong. Even seeing his name come up on my phone screen terrifies me and he knows that, I felt it was an attempt to intimidate me."
It is also quite okay to say "Sorry, I'm nervous, let me rephrase that," to ask for a tissue or a drink of water, or even to ask for a 5 minute break to compose yourself. (Although beware ham acting, obviously.)
Forget everything you have ever seen on TV about courtroom dramas. It is unlikely that the advocate will try to rip you apart - it is far more likely that they will drown you with sympathy and then gently suggest that you're mistaken, as they are more likely to get what they want that way.
However with harassment cases it's often a matter of evidence - the text messages / Facebook posts etc. It is not at all uncommon for a defendant to wait and see if the victim turns up, and plead guilty if she does.
Retraction statements: treat with care, because they can potentially lay you open to a charge of wasting police time (or perjury depending on where the case has got to). If you retract you are basically telling the court you lied to the police. It could also make it difficult to get a conviction if it happens again.
Joy5 - good luck with the family court :)
[none of this should be interpreted as legal advice as I don't know the ins and outs of your situation, and you don't know who I am, if in doubt speak to a lawyer in person etc etc]