title: Node count and occurence - XSL
body: <p>I need to write generic xsl that would take in an xml document and output the count of nodes and their names.  So if I have a file like the following:</p>
  
  <pre><code>   &lt;assets&gt;
      &lt;asset&gt;
          &lt;type&gt;hardware&lt;/type&gt;
          &lt;item&gt;
              &lt;name&gt;HP laptop&lt;/name&gt;
              &lt;value&gt;799&lt;/value&gt;
          &lt;/item&gt;
          &lt;item&gt;
              &lt;name&gt;server&lt;/name&gt;
              &lt;value&gt;1000&lt;/value&gt;
          &lt;/item&gt;
          &lt;item&gt;
              &lt;name&gt;ViewSonic Monitor&lt;/name&gt;
              &lt;value&gt;399&lt;/value&gt;
          &lt;/item&gt;
      &lt;/asset&gt;
      &lt;asset&gt;
          &lt;type&gt;software&lt;/type&gt;
          &lt;item&gt;
              &lt;name&gt;Windows Vista&lt;/name&gt;
              &lt;value&gt;399&lt;/value&gt;
          &lt;/item&gt;
          &lt;item&gt;
              &lt;name&gt;Office XP&lt;/name&gt;
              &lt;value&gt;499&lt;/value&gt;
          &lt;/item&gt;
          &lt;item&gt;
              &lt;name&gt;Windows 7&lt;/name&gt;
              &lt;value&gt;399&lt;/value&gt;
          &lt;/item&gt;
            &lt;item&gt;
              &lt;name&gt;MS Project Professional 2007&lt;/name&gt;
              &lt;value&gt;299&lt;/value&gt;
            &lt;/item&gt;
         &lt;/asset&gt;
      &lt;/assets&gt;
  </code></pre>
  
  <p>The output would be:</p>
  
  <pre><code>   &lt;output&gt;
      &lt;node name="assets" count="1"/&gt;
      &lt;node name="asset" count="2"/&gt;
      &lt;node name= "type" count="??"/&gt;
      &lt;node name="item" count=??/&gt;
      &lt;node name="name" count=??/&gt;
      &lt;node name="value" count=??/&gt;
      &lt;/output&gt;
  </code></pre>