title: Add code to XSLT before transformation
body: <p>I'm using C# to transform an XML document and it is working fine: </p>
  
  <pre><code>using System;
  using System.IO;
  using System.Xml;
  using System.Xml.Xsl;
  using System.Xml.XPath;
  
  public class XmlTransformUtil
  {
  
  public static void Main(string[] args)
  {
  
      if (args.Length == 2)
      {
  
          Transform(args[0], args[1]);
      }
      else
      {
  
          PrintUsage();
      }
  }
  
  public static void Transform(string sXmlPath, string sXslPath)
  {
      try
      {
          //load the Xml doc
          XPathDocument myXPathDoc = new XPathDocument(sXmlPath);
  
          XslTransform myXslTrans = new XslTransform();
  
          //load the Xsl 
          myXslTrans.Load(sXslPath);
  
          //create the output stream
          XmlTextWriter myWriter = new XmlTextWriter
              ("result.html", null);
  
          //do the actual transform of Xml
          myXslTrans.Transform(myXPathDoc, null, myWriter);
  
          myWriter.Close();
      }
  
      catch (Exception e)
      {
          Console.WriteLine("Exception: {0}", e.ToString());
      }
  }
  
  public static void PrintUsage()
  {
      Console.WriteLine
      ("Usage: XmlTransformUtil.exe &lt;xml path&gt; &lt;xsl path&gt;");
  }
  
  }
  </code></pre>
  
  <p>The above code works perfectly, however what I want to do is, before the XSLT is transformed, I want it to add additional Lines of code to specific parts of the XSLT.</p>
  
  <p>XSLT Code: </p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  
  &lt;xsl:template match="/"&gt;
      &lt;html lang="en-GB"&gt;
          &lt;body style="font-family:'Praxis Com Light'; color:#632423; width:100%; font-size:14px !important;"&gt;
  
  //MAIN BODY OF CODE
  
          &lt;/body&gt;
      &lt;/html&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>How i want the XSLT Code changed in C# Before the transformation:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:include href="HEAD.xslt"/&gt;
  &lt;xsl:include href="FOOT.xslt"/&gt;
  
  &lt;xsl:template match="/"&gt;
      &lt;html lang="en-GB"&gt;
          &lt;body style="font-family:'Praxis Com Light'; color:#632423; width:100%; font-size:14px !important;"&gt;
  
          &lt;xsl:call-template name="Header"/&gt;
  
  //MAIN BODY OF CODE
  
              &lt;xsl:call-template name="Footer"/&gt;
  
              &lt;/body&gt;
          &lt;/html&gt;
      &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>How can this be accomplished?</p>