0

Am having a code like this to translate from & to & which is working fine, but it also removing other characters in the field which is a,m,p because we are translating. I just want this to work to translate & to & not to delete a,m,p characters.

<xsl:when 
test="contains(//column[@name=&quot;Description&quot;]/text(), &quot;&amp;amp;&quot;)">
<xsl:value-of
select="translate(//column[@name=&quot;Description&quot;]/text(),'&amp;amp;','&amp; ')" 
disable-output-escaping="no"/>
</xsl:when>

Input: Input: &amp;amp;wUS &amp;amp;and amptestamp

Current Output: &amp;wUS &amp;nd test

Expected output: &amp;wUS &amp;and amptestamp

Alejandro
  • 1,882
  • 6
  • 13
  • Use the built in replace() function.See http://www.xsltfunctions.com/xsl/fn_replace.html – Christian Mosz Aug 19 '19 at 15:34
  • replace function will work in XSLT1.0? – Tatavarthy Suresh Aug 19 '19 at 15:44
  • 1
    Nope. But in this case just look at: https://stackoverflow.com/questions/7520762/xslt-1-0-string-replace-function There is a solution for it already. – Christian Mosz Aug 19 '19 at 15:51
  • 1
    Is the input you have shown (`&wUS &and amptestamp`) part of an XML document? Is the output you want (`&wUS &and amptestamp`) also part of an XML or HTML document or is that plain text? In XML the ampersand is escaped as `&` but of course as long as you use XML tools to read out data you will get or be able to get a plain `&`. – Martin Honnen Aug 19 '19 at 16:23
  • 1
    What is your code? And what XSLT version are you using? This doesn't sound like a job for the translate() function. – Michael Kay Aug 19 '19 at 20:07
  • Possible duplicate of [xslt 1.0 string replace function](https://stackoverflow.com/questions/7520762/xslt-1-0-string-replace-function) – Alejandro Aug 20 '19 at 16:02

0 Answers0