title: XSL replace space with caret
body: <p>UPDATED CODE:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt;
    &lt;xsl:output method="xml" indent="no"/&gt;
    &lt;!-- overwritten by application with actual values --&gt;
    &lt;xsl:param name="calling" select="'SAMPLE_MOD'"/&gt;
    &lt;xsl:param name="called" select="'SERVER1'"/&gt;
    &lt;xsl:param name="date" select="'20051206'"/&gt;
    &lt;xsl:param name="time" select="'115600.000'"/&gt;
    &lt;xsl:param name="PatName" select="attr[@tag='00100010']"/&gt;
    &lt;xsl:template match="/dataset"&gt;
       &lt;dataset&gt;
       &lt;xsl:variable name="PerfProcStepDesc" select="attr[@tag='00400254']"/&gt;
       &lt;xsl:variable name="StudyDesc" select="attr[@tag='00081030']"/&gt;
         &lt;xsl:if test="string-length($StudyDesc)=0"&gt;
           &lt;xsl:if test="$PerfProcStepDesc"&gt;
              &lt;!-- (0008,1030) Study Description --&gt;
             &lt;attr tag="00081030" vr="LO"&gt;
               &lt;xsl:value-of select="$PerfProcStepDesc"/&gt;
             &lt;/attr&gt;
           &lt;/xsl:if&gt;
         &lt;/xsl:if&gt;
       &lt;/dataset&gt;
       &lt;dataset&gt;
          &lt;xsl:variable name="caret" select="'^'"/&gt;
          &lt;xsl:if test="contains($PatName, ' ')"&gt;
              &lt;xsl:value-of select="translate($PatName, ' ','^')"/&gt;
          &lt;/xsl:if&gt;   
       &lt;/dataset&gt;
    &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>The variable 'PatName' could come across as 'DOE JOHN' and I need it be transformed to 'DOE^JOHN'  There could also be multiple spaces in the name, so I would like all 'spaces' changed to carets and to keep their current place in the name.</p>
  
  <p>I need to do the same with commas that are in the name.</p>
  
  <p>Currently the output coming out just as it went in, so my test is not working as it should.</p>
  
  <p>thanks for looking!</p>
  
  <p>EDIT #2:</p>
  
  <p>I have changed my code to apply a identity transform (hopefully I have it correct!)  Also I have the XSL input and XSL output for when it processed my XSL stylesheet.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt;
    &lt;xsl:output method="xml" indent="no"/&gt;
    &lt;!-- overwritten by application with actual values --&gt;
    &lt;xsl:param name="calling" select="'SAMPLE_MOD'"/&gt;
    &lt;xsl:param name="called" select="'SERVER1'"/&gt;
    &lt;xsl:param name="date" select="'20051206'"/&gt;
    &lt;xsl:param name="time" select="'115600.000'"/&gt;
    &lt;xsl:param name="PatName" select="attr[@tag='00100010']"/&gt;
  &lt;!-- IdentityTransform --&gt;
  &lt;xsl:template match="/ | @* | node()"&gt;
      &lt;xsl:copy&gt;
          &lt;xsl:apply-templates select="@* | node()" /&gt;
      &lt;/xsl:copy&gt;
  &lt;/xsl:template&gt;
    &lt;xsl:template match="/dataset"&gt;
       &lt;dataset&gt;
       &lt;xsl:variable name="PerfProcStepDesc" select="attr[@tag='00400254']"/&gt;
       &lt;xsl:variable name="StudyDesc" select="attr[@tag='00081030']"/&gt;
         &lt;xsl:if test="string-length($StudyDesc)=0"&gt;
           &lt;xsl:if test="$PerfProcStepDesc"&gt;
              &lt;!-- (0008,1030) Study Description --&gt;
             &lt;attr tag="00081030" vr="LO"&gt;
               &lt;xsl:value-of select="$PerfProcStepDesc"/&gt;
             &lt;/attr&gt;
           &lt;/xsl:if&gt;
         &lt;/xsl:if&gt;
       &lt;/dataset&gt;
       &lt;dataset&gt;
          &lt;xsl:variable name="caret" select="'^'"/&gt;
          &lt;xsl:if test="contains($PatName, ' ')"&gt;
              &lt;xsl:value-of select="translate($PatName, ' ','^')"/&gt;
          &lt;/xsl:if&gt;   
       &lt;/dataset&gt;
    &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>XSL Input <a href="http://www.pastebin.ca/2655849" rel="nofollow">here</a></p>
  
  <p>XSL Output is below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;dataset/&gt;
  </code></pre>
  
  <p>in the XSL input, 'Patient Name' there is 'SMPTE PATTERN' and I am expecting 'SMPTE^PATTERN'.</p>
  
  <p>I hope this of some help and I hope I have the identity transformer correct. </p>
  
  <p>thanks for everybodys time</p>