title: Replace Commas with SPace using XSLT
body: <p>I am trying to remove commas from my xml file using xslt.
  How can I correctly replace any commas included in node or attribute values with a space?</p>
  
  <p>Here is my xslt file:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wd="urn:com.workday/bsvc"&gt;
      &lt;xsl:output method="text" encoding="utf-8" media-type="text/plain" /&gt;
      &lt;xsl:strip-space  elements="*"/&gt;
  
  &lt;xsl:variable name="newline" select="'&amp;#x0A;'" /&gt;
  &lt;xsl:variable name="tab" select="'&amp;#x09;'" /&gt;
  &lt;xsl:variable name="comma" select="'&amp;#x2C;'" /&gt;
  &lt;xsl:variable name="padding" select="'                              '" /&gt; &lt;!-- 30 spaces for padding --&gt;
  
  &lt;!-- Longest Column Header Text is 39 letters long --&gt;
  &lt;xsl:variable name="FAO" select="concat('FAO', $padding, $padding)" /&gt;
  &lt;xsl:variable name="FAO1" select="concat('FAO REFERENCE ID', '')" /&gt;
  &lt;xsl:variable name="FAO2" select="concat('FAO TYPE', $padding)" /&gt;
  &lt;xsl:variable name="RESP" select="concat('RESPONSIBLE PERSON', $padding, $padding, $padding, $padding)" /&gt;
  
  
  &lt;xsl:template match="/"&gt;
  &lt;!--        &lt;xsl:variable name="textVal" select="*/text()" /&gt;  
          &lt;xsl:value-of select="translate($textVal, ',' ,' ')" /&gt;--&gt;
      &lt;xsl:value-of select="$FAO"/&gt;&lt;xsl:value-of select="$comma"/&gt;
      &lt;xsl:value-of select="$FAO1"/&gt;&lt;xsl:value-of select="$comma"/&gt;
      &lt;xsl:value-of select="$FAO2"/&gt;&lt;xsl:value-of select="$comma"/&gt;
      &lt;xsl:value-of select="$RESP"/&gt;&lt;xsl:value-of select="$comma"/&gt;
  &lt;xsl:value-of select="$newline"/&gt;
  
      &lt;xsl:for-each select="/wd:Report_Data/wd:Report_Entry"&gt;
          &lt;xsl:value-of select="substring(concat(wd:FAO, $padding, $padding, $padding, $padding, $padding), 1, string-length($FAO))" /&gt;&lt;xsl:value-of select="$comma"/&gt;
          &lt;xsl:value-of select="substring(concat(wd:FAO_REFERENCE_ID, $padding, $padding, $padding, $padding, $padding), 1, string-length($FAO1))" /&gt;&lt;xsl:value-of select="$comma"/&gt;
          &lt;xsl:value-of select="substring(concat(wd:FAO_TYPE, $padding, $padding, $padding, $padding, $padding), 1, string-length($FAO2))" /&gt;&lt;xsl:value-of select="$comma"/&gt;
          &lt;xsl:value-of select="substring(concat(wd:RESPONSIBLE_PERSON/@wd:Descriptor, $padding, $padding, $padding, $padding, $padding), 1, string-length($RESP))" /&gt;&lt;xsl:value-of select="$comma"/&gt;
      &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="*"&gt;
      &lt;xsl:variable name="textVal" select="*/text()" /&gt;  
      &lt;xsl:value-of select="translate($textVal, ',' ,' ')" /&gt;
  &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>My output is a CSV file so I want to replace any nodes and attribute values that contain commas with spaces.</p>
  
  <p>The second template that tries to replace commas with a space does not work.
  I also tried placing those 2 statements at the start of the first template but that did not work as well.</p>