title: XSLT how to check if the current node has any attribute or not
body: <p>I have xml files which are dynamic. There are many elements and some may have attributes or may not have. This is defined in the xsd file. </p>
  
  <p>I am using the recursive method(for-each) to display the node contents one by one. But if any tag has any attribute then the condition does not match and that tag's contents are not displayed.</p>
  
  <p>I want to check if current element has any attribute or not. If has then also display the contents otherwise also display the tag's contents.</p>
  
  <p>Piece of code of my xslt:</p>
  
  <pre><code>&lt;xsl:template match="node()" mode="chapter"&gt;
      &lt;xsl:for-each select="node()"&gt;
         &lt;xsl:if test="current()[name() = 'CHAPTER']"&gt;
            &lt;fo:block&gt;
               &lt;xsl:apply-templates select="current()[name() = 'CHAPTER']" mode="chapter" /&gt;
            &lt;/fo:block&gt;
        &lt;/xsl:if&gt;
     &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>In the above code, in one of xml inputs, CHAPTER tag has an attribute. Hence the if condition becomes false and it does not enter the if block though the current node is CHAPTER. </p>
  
  <p>I want to check if CHAPTER has any attribute or not.
  Please suggest.</p>
  
  <p>Thank you in advance.</p>