My code generates the following XML:
<person_app>
<person_data>
<person>
...person details here...
</person>
</person_data>
</person_app>
Using XSLT, I parse the person records as follows:
<xsl:template match="/person_app/person_data">
<xsl:for-each select="person">
...generate person HTML...
</xsl:for-each>
</xsl:template>
However, in cases when I receive zero people, I'd like to display "No records found" (or something similar). When the app returns zero records, the XML resembles the following:
<person_app/>
Long story short, how can I test for an empty result set when I use <xsl:for-each/> to parse my Person records? I've tried the following with no success:
<xsl:if test="not(person)">
<div style="font-size:18pt"><xsl:text>No records found</xsl:text></div>
</xsl:if>
Something like this:
<xsl:choose>
<xsl:when test="person">
<xsl:for-each select="person">
...generate person HTML...
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<div style="font-size:18pt"><xsl:text>No records found</xsl:text></div>
</xsl:otherwise>
</xsl:choose>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With