How to output ampersand (&) from XSLT
How to output &
as &
in XSLT
In general, here are the alternative output methods &
as &
:
-
Globally:
<xsl:output method="html"/> or <xsl:output method="text"/>`
-
For ampersands originating from XSLT:
<xsl:text disable-output-escaping="yes"><![CDATA[&]]></xsl:text>
-
For ampersands coming from input XML:
<xsl:value-of select="XPATH EXPRESSION" disable-output-escaping="yes"/>
Now, in your specific case, you say what &
appears in the text boxes as " &
". I don't see that. Apart from XML or XSLT, in which I show above how to generate &
rather than &
, HTML itself really has no problem with &
...
Consider this simple HTML test:
<html>
<body>
<h3>No &amp; is displayed in any of these cases:</h3>
<div>
In an input box:
<input type="text" value="Ampersand: &"/>
</div>
<div>
In a text area:
<textarea>Ampersand: &</textarea>
</div>
<div>In a div: Ampersand: &</div>
</body>
</html>
This is displayed in browsers like this:
As you can see, there is no problem with rendering &
like &
.
source to share