title: XSL apply template only to node with children
body: <p>This is my xml input file</p>
  
  <pre><code>&lt;ELEMENTROOT&gt;
    &lt;id&gt;10036&lt;/id&gt;
    &lt;firstName&gt;Marco&lt;/firstName&gt;
    &lt;lastName&gt;Nato&lt;/lastName&gt;
    &lt;addressSet&gt;
       &lt;address&gt;
          &lt;country&gt;
             &lt;displayValue&gt;France&lt;/displayValue&gt;
          &lt;/country&gt;
       &lt;/address&gt;
    &lt;/addressSet&gt;
    &lt;clobMap/&gt;
    &lt;dateMap&gt;
      &lt;entry&gt;
          &lt;key&gt;birthDate&lt;/key&gt;
          &lt;value&gt;1973-11-29T00:00:00&lt;/value&gt;
      &lt;/entry&gt;
     &lt;/dateMap&gt;
    &lt;myMap&gt;
          &lt;entry&gt;
              &lt;key&gt;gender&lt;/key&gt;
              &lt;value&gt;
                  &lt;id&gt;1042&lt;/id&gt;
                  &lt;displayValue&gt;Femminile&lt;/displayValue&gt;
              &lt;/value&gt;
          &lt;/entry&gt;
    &lt;myMap&gt;
   &lt;/ELEMENTROOT&gt;
  </code></pre>
  
  <p>RESULT THAT I WOULD LIKE TO GET</p>
  
  <pre><code> &lt;ELEMENTROOT&gt;
    &lt;id&gt;10036&lt;/id&gt;
    &lt;firstName&gt;Marco&lt;/firstName&gt;
    &lt;lastName&gt;Nato&lt;/lastName&gt;
    &lt;addressSet&gt;
       &lt;address&gt;
          &lt;country&gt;
             &lt;displayValue&gt;France&lt;/displayValue&gt;
          &lt;/country&gt;
       &lt;/address&gt;
    &lt;/addressSet&gt;
    &lt;clobMap/&gt; &lt;!-- Unlikely I don't have this with my xsl--&gt;
    &lt;birthDate&gt;
          1973-11-29T00:00:00
    &lt;/birthDate&gt;
    &lt;gender&gt;
      &lt;id&gt;1042&lt;/id&gt;
      &lt;displayValue&gt;Femminile&lt;/displayValue&gt;
    &lt;/gender&gt;   
   &lt;/ELEMENTROOT&gt;
  </code></pre>
  
  <p>The xsl file that I tried is this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt;
    &lt;xsl:output method="xml" indent="yes"/&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="myMap"&gt;
       &lt;xsl:for-each select="entry"&gt; 
          &lt;xsl:element name="{key}"&gt;
              &lt;xsl:copy-of select="value/*" /&gt;
          &lt;/xsl:element&gt;
        &lt;/xsl:for-each&gt;
    &lt;/xsl:template&gt;
    &lt;xsl:template match="*[contains(name(), 'Map')][not(contains(name(), 'myMap'))]"&gt; 
        &lt;xsl:for-each select="./entry"&gt; 
          &lt;xsl:element name="{key}"&gt;
              &lt;xsl:value-of select="value" /&gt;
          &lt;/xsl:element&gt;
        &lt;/xsl:for-each&gt;
    &lt;/xsl:template&gt;  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>As you can understand I have this problem:
  I have to apply only the template if the map has children otherwise I will lose the node like  in the example above.
  I tried different approach to match only Map that have children but I have two kind of map: "myMap" that for each entry has two values and "dateMap" that has one value for each entry.</p>
  
  <p>Thank you very much for your help!</p>