title: Rename nodes with XSLT
body: <p>I am trying something very simple, but for some reason it does not work. Basically, I need to rename some nodes in an XML document. Thus, I created an XSLT file to do the transformation.</p>
  
  <p>Here is an example of the XML:</p>
  
  <p>EDIT: Addresses and Address elements occur at many levels. This is what caused me to have to try and apply an XSLT. The Visual Studio typed dataset feature, which creates typed datasets from XSD files does not permit you to have nested references to the same table. Thus, having Businesses/Business/Addresses and Businesses/Business/Contact/Addresses causes the Load() to fail. This is a known issue, and all they tell you is something like "Don't have nested table references...edit your XSD to stop having that." Unfortunately, this means that we have to apply XSLT to make the XML conform to the "hacked" XSD, since the files are coming from a third party vendor.</p>
  
  <p>So, we are very close with the help rendered here. The last couple of things are these:</p>
  
  <p>1.) How can I use the namespace reference in the match attribute of the xsl:template in order to specify that I want to rename Businesses/Business/Addresses to BusinessAddresses, but rename Businesses/Business/Contacts/Contact/Addresses to ContactAddresses?</p>
  
  <p>2.) How can I stop the XSLT from cluttering every new element with explicit namespace references? It is causing extreme bloat in the output.</p>
  
  <p>I created a namespace called "steel", and was having good success with:</p>
  
  <pre><code>&lt;xsl:template match="steel:Addresses&gt;
    &lt;xsl:element name="BusinessAddresses&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>The obvious problem here is that it renames <strong>ALL</strong> of the Addresses elements to BusinessAddresses, even though I want some of them named ContactAddresses, and so on. The needless addition of explicit namespace references to all of the renamed nodes is also troublesome.</p>
  
  <p>I tried this sort of thing, but as soon as I add slashes to the match attribute, it is a a syntax error in the XSLT, like so:</p>
  
  <pre><code>&lt;xsl:template match="steel:/Businesses/Business/Addresses"&gt;
  </code></pre>
  
  <p>I feel very close, but need some guidance on how to mix both the namespace usage and a way to use the slashes to select <strong>ANY</strong> nodes under specific paths.</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;Businesses&gt;
    &lt;Business&gt;
      &lt;BusinessName&gt;Steel Stretching&lt;/BusinessName&gt;
      &lt;Addresses&gt;
        &lt;Address&gt;
          &lt;City&gt;Pittsburgh&lt;/City&gt;
        &lt;/Address&gt;
        &lt;Address&gt;
          &lt;City&gt;Philadelphia&lt;/City&gt;
        &lt;/Address&gt;
      &lt;/Addresses&gt;
      &lt;Contacts&gt;
        &lt;Contact&gt;
          &lt;FirstName&gt;Paul&lt;/FirstName&gt;
          &lt;LastName&gt;Jones&lt;/LastName&gt;
          &lt;Addresses&gt;
            &lt;Address&gt;
              &lt;City&gt;Pittsburgh&lt;/City&gt;
            &lt;/Address&gt;
          &lt;/Addresses&gt;
        &lt;/Contact&gt;
      &lt;/Contacts&gt;
    &lt;/Business&gt;
    &lt;Business&gt;
      &lt;BusinessName&gt;Iron Works&lt;/BusinessName&gt;
      &lt;Addresses&gt;
        &lt;Address&gt;
          &lt;City&gt;Harrisburg&lt;/City&gt;
        &lt;/Address&gt;
        &lt;Address&gt;
          &lt;City&gt;Lancaster&lt;/City&gt;
        &lt;/Address&gt;
      &lt;/Addresses&gt;
    &lt;/Business&gt;
  &lt;/Businesses&gt;
  </code></pre>
  
  <p>I need to rename Addresses to BusinessAddresses, and I need to rename Address to BusinessAddress, for every instance of Addresses and Address directly under a Business node. I also need to rename Addresses to ContactAddresses, and I need to rename Address to ContactAddress, for every instance of Addresses and Address directly under a Contact Node.</p>
  
  <p>I have tried several solutions, but none seem to work. They all end up producing the same XML as the original file.</p>
  
  <p>Here is an example of what I have tried:</p>
  
  <pre><code>  &lt;xsl:template match="/"&gt;
      &lt;xsl:apply-templates select="@*|node()" /&gt;
    &lt;/xsl:template&gt;
  
    &lt;xsl:template match="@*|*"&gt;
      &lt;xsl:copy&gt;
        &lt;xsl:apply-templates select="@*|node()" /&gt;
      &lt;/xsl:copy&gt;
    &lt;/xsl:template&gt;
  
    &lt;xsl:template match="Addresses"&gt;
      &lt;BusinessAddresses&gt;
        &lt;xsl:apply-templates select="@*|node()" /&gt;
      &lt;/BusinessAddresses&gt;
    &lt;/xsl:template&gt;
  </code></pre>
  
  <p>This has been tried in at least 6 different flavors, complete with stepping through the XSLT debugger in VB.Net. It never executes the template match for Addresses.</p>
  
  <p>Why?</p>