title: XSLT: use multiple or'd template matches to apply-templates
body: <p>I have an XML with multiple nodes with similar data in each.  I want to delete a specific attribute from each node (USER:IPADDRESS).  I've figured out how to chain together a number of elements using ors, simply leaving out the User="{@User}" match so it doesn't show up in the results:</p>
  
  <p>XSL Snippet:</p>
  
  <pre><code>&lt;xsl:template match="Creation | Test | Assignment | Modification | Repair | Termination"&gt;
  &lt;Creation CommitID="{@CommitID}" Date="{@Date}" BoardID="{@BoardID}"&gt;
  &lt;xsl:apply-templates/&gt;
  &lt;/Creation&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>Unsurprisingly, all of the node names after "Creation" get re-named to Creation because that's what I'm telling it to do.  How do I pass in the various matches so they're applied in the proper order in the results?  I know I can do a brute force way using identical XSL statements for each of the various matches (that's how I did it the first time), but there must be a more elegant method, it's just evading me.  I have millions &amp; millions of lines of XML to process and this is just the first of many transforms I'm going to have to make.</p>
  
  <p>I'm using msxsl V4.0 on a Win7 box to do my transforms if that's of any consequence.</p>
  
  <p>XML:  </p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;BoardDatabase&gt;
  &lt;Board_Data BoardID="1035"&gt;
      &lt;Creation CommitID="12b" Date="2007-12-07T15:43:51" BoardID="1035" User="CSAGAN:192.168.1.177"&gt;
          &lt;BoardDrawing&gt;3B&lt;/BoardDrawing&gt;
          &lt;AssemblyDrawing&gt;2010F&lt;/AssemblyDrawing&gt;
          &lt;Notes&gt;PO Num 1959&lt;/Notes&gt;
      &lt;/Creation&gt;
      &lt;Test CommitID="117" Date="2007-12-10T10:39:43" BoardID="1035" User="CSAGAN:192.168.1.183"&gt;
          &lt;ElectricalTestData Result="FAIL" Version="IMM STD REVF"&gt;
              &lt;AutomatedTest ReportVersion="1.0"&gt;
                  &lt;TestSetup&gt;
                      &lt;TestAppBuildDate&gt;Dec 07 2007&lt;/TestAppBuildDate&gt;
                      &lt;VersionPath&gt;c:\tests\versions\v12.txt&lt;/VersionPath&gt;
                      &lt;VersionNumber&gt;1.2&lt;/VersionNumber&gt;
                      &lt;OperatorName&gt;CSAGAN&lt;/OperatorName&gt;
                      &lt;StationID&gt;PC-191-NDGrasse&lt;/StationID&gt;
                      &lt;JigSN&gt;12345&lt;/JigSN&gt;
                      &lt;JigAssembly&gt;42&lt;/JigAssembly&gt;
                      &lt;TestStartTime&gt;2007-12-10 10:34:17&lt;/TestStartTime&gt;
                  &lt;/TestSetup&gt;
              &lt;/AutomatedTest&gt;
          &lt;/ElectricalTestData&gt;
      &lt;/Test&gt;
      &lt;Assignment CommitID="1c1f" User="JRandi:192.168.1.162" Date="2008-09-30T07:36:52" BoardID="1035"&gt;
          &lt;Notes&gt;Boardset failed etest twice, no problem log entry/repair attempts made.&lt;/Notes&gt;
      &lt;/Assignment&gt;
      &lt;Modification CommitID="2bb7" User="JRandi:192.168.1.162" Date="2009-03-11T13:31:21" BoardID="1035"&gt;
          &lt;AssemblyDrawing&gt;2001G&lt;/AssemblyDrawing&gt;
          &lt;Notes&gt;Cornelius upgraded boardset to rev. G&lt;/Notes&gt;
      &lt;/Modification&gt;
  &lt;/Board_Data&gt;
  &lt;/BoardDatabase&gt;
  </code></pre>
  
  <p>XSL:</p>
  
  <pre><code>&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt;
  
  &lt;xsl:template match="Creation | Test | Assignment | Modification | Repair | Termination"&gt;
  &lt;Creation CommitID="{@CommitID}" Date="{@Date}" BoardID="{@BoardID}"&gt;
  &lt;xsl:apply-templates/&gt;
  &lt;/Creation&gt;
  &lt;/xsl:template&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:stylesheet&gt;
  </code></pre>
  
  <p>Latest XSL using @DevNull's solution that doubles size of original file:</p>
  
  <pre><code>&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt;
  
  &lt;!-- Answer from Stack Overflow that only strips out the IP Address from the User attribute. --&gt;
  &lt;xsl:template match="@User"&gt;
    &lt;xsl:attribute name="User"&gt;
      &lt;xsl:value-of select="substring-before(.,':')"/&gt;
    &lt;/xsl:attribute&gt;
  &lt;/xsl:template&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:stylesheet&gt;
  </code></pre>
  
  <p>Latest XSL from @Dimitre's solution that takes a very long time to process (still running after more than 30 minutes, but file is still growing):</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=
    "*[contains('|Creation|Test|Assignment|Modification|Repair|Termination|',concat('|', name(), '|'))
  ]/@user"/&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>