I'm trying to pass a parameter to xalan. It works just fine until there is an ampersand in the string. Then I get:

Caused by: javax.xml.transform.TransformerException: The entity name must immediately follow the '&' in the entity reference.
    at org.apache.xalan.transformer.TransformerImpl.fatalError(TransformerImpl.java:739)
    at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:715)
    at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1129)
    at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1107)

I tried using & and that works, but it transforms it to '&'
I tried using <![CDATA[ & ]]> and that gives me &lt;![CDATA[ &amp; ]]&gt;

So it is obviously trying to translate what I send to escaped values, just not when it is an ampersand on its own.

Is there some other way of escaping a lone ampersand?

My java code looks like this:
Transformer transformer = templates.newTransformer();
String n = fetchClientName();
n = replaceAmpersandsWithEscapes(n);

and in the xsl file I have the param declared at the top and  down in the templates I use this:
                <xsl:value-of select="$ClientName"/>                       

Thanks for any help
Roger Parkinson