title: XSLT condition to check if node exists
body: <p>I have below sample XML in which I want to check if the node  exist.</p>
  
  <p>Sample XML is</p>
  
  <pre><code>&lt;document&gt;
  &lt;item&gt;
      &lt;ID&gt;1000909090&lt;/ID&gt;
      &lt;flex&gt;
          &lt;attrGroupMany name="pageinfo"&gt;
              &lt;row&gt;
                  &lt;attr name="pagelength"&gt;10&lt;/attr&gt;
                  &lt;attr name="pagewidth"&gt;20&lt;/attr&gt;
                  &lt;attr name="pageheight"&gt;30&lt;/attr&gt;
              &lt;/row&gt;
              &lt;row&gt;
                  &lt;attr name="pagelength"&gt;10&lt;/attr&gt;
                  &lt;attr name="pagewidth"&gt;20&lt;/attr&gt;
              &lt;/row&gt;
          &lt;/attrGroupMany&gt;
      &lt;/flex&gt;
  &lt;/item&gt;
  &lt;/document&gt;
  </code></pre>
  
  <p>I am using below XSLT but is not getting converted</p>
  
  <pre><code>&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="document"&gt;
      &lt;CatalogItem&gt;
          &lt;RelationshipData&gt;
              &lt;xsl:for-each select="item"&gt;
                  &lt;Relationship&gt;
                      &lt;RelationType&gt;PAGEDETAILSINFO&lt;/RelationType&gt;
                      &lt;RelatedItems&gt;
                          &lt;xsl:attribute name="count"&gt;
                              &lt;xsl:value-of select="count(flex//attrGroupMany[@name = 'pageinfo']/row)"/&gt;
                          &lt;/xsl:attribute&gt;
                          &lt;xsl:for-each select="flex//attrGroupMany[@name = 'pageinfo']/row"&gt;
                              &lt;xsl:choose&gt;
                                  &lt;xsl:when test="not(string-length(attr[@name = 'pageheight'] )) = 0"&gt;
                                      &lt;xsl:variable name="height" select="attr[@name='pageheight']"/&gt;
                                  &lt;/xsl:when&gt;                                                         
                                  &lt;xsl:otherwise&gt;
                                      &lt;xsl:variable name="height" select="'0'"/&gt;
                                  &lt;/xsl:otherwise&gt;
                              &lt;/xsl:choose&gt; 
                              &lt;RelatedItem&gt;
                                  &lt;xsl:attribute name="referenceKey"&gt;
                                      &lt;xsl:value-of select="concat('Food_And_Bev_Allergen_MVL','-',ancestor::item/ID,'-',$height)"/&gt;
                                  &lt;/xsl:attribute&gt;
                              &lt;/RelatedItem&gt;
                          &lt;/xsl:for-each&gt;
                      &lt;/RelatedItems&gt;
                  &lt;/Relationship&gt;
              &lt;/xsl:for-each&gt;
          &lt;/RelationshipData&gt;
      &lt;/CatalogItem&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>I think the choose condition is incorrect. can you please let me know what will be the correct condition.</p>