title: Replace strings in XML file using XSLT
body: <p>An open source project uses <a href="http://cmake.org/" rel="nofollow noreferrer">CMake</a> to build it's project files.</p>
  
  <p>I don't agree with CMake - it's a 10mb installer to create batch files for a few hundred kb of source and even then it hardcodes the developers path to the output.  It does not do relative paths at all, nor does it use the handy macros that Visual Studio provides.</p>
  
  <p>So I decided to look around. <a href="http://code.google.com/p/gyp/" rel="nofollow noreferrer">Gyp</a> looked promising but again it is placing a reliance on the user having Python installed and that is back to the reason why I dislike CMake.  At least it doesn't hard code paths though.</p>
  
  <p>So I thought about using batch files, and simple find and replace but since the project files are xml why not XSLT? So a bit of searching <a href="https://stackoverflow.com/questions/2888880/xslt-change-node-inner-text">ran across this page</a> here on SO which seemed to show what I want to do at a very simplistic level.</p>
  
  <p>So I edited the answer by Dimitre Novatchev to the following:</p>
  
  <pre><code>&lt;xsl:template match="OutDir/text()"&gt;
     &lt;xsl:text&gt;Diferent text&lt;/xsl:text&gt;
   &lt;/xsl:template&gt;
  </code></pre>
  
  <p>Hoping that would find the following and change it: </p>
  
  <pre><code>&lt;OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"&gt;U:\unittest-cpp-pj\vs_projects\vs2012_x86\Debug\&lt;/OutDir&gt;
  </code></pre>
  
  <p>However that didn't work - using the VS2010 xslt debugger it doesn't even break on the line. I don't want to spend months learning how to use XSLT correctly for something as seemingly simple as this. All I need is something that I can fire at 28 xml files and be done with it.</p>
  
  <p>Once I have this working I will expand it to replace the fields with the correct values.</p>
  
  <p><strong>Update</strong>: This is the entire XSLT:</p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
    &lt;xsl:output omit-xml-declaration="yes" indent="yes"/&gt;
    &lt;xsl:strip-space elements="*"/&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="OutDir/text()"&gt;
      &lt;xsl:text&gt;Diferent text&lt;/xsl:text&gt;
    &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>