XSL Displaying a message to the user if an element's count is 0



I have an element called channels which has been given values in the XML files. what i want to do is that when the XML file doesn't have any channel , display a message to the user. here is my code.



<h2>Channels Subscription:</h2>
<xsl:template>
<xsl:if test=" <xsl:value-of select="count(subscription/channels)"/>
==0)">
<p>You have no channels</p>
</xsl:if>

</xsl:template>


the code above doesn't work after that comes the other part wich is table.. when a user has a channel or more it gets displayed



<xsl:for-each select="subscription/channels">

<xsl:choose>
<xsl:when test="@favourite='true'">


<h3 >Channel Name:</h3> <h3 style="color:green;"><xsl:value-of select="@name"/></h3>

</xsl:when>
<xsl:otherwise>
<h3 >Channel Name: </h3><h3 style="color:black; "><xsl:value-of select="@name"/></h3>
</xsl:otherwise>
</xsl:choose>
<p>ID: <xsl:value-of select="@id"/></p>
<h3>Programs:</h3>
<xsl:for-each select="programs">
<table ID="gradient-style">
<tbody>
<tr>
<th>Program Name:</th>
<td><xsl:value-of select="name"/></td>
</tr>
<tr>
<th>Broadcast Time:</th>
<td>
<xsl:value-of select="@broadcastFrequency"/> at <xsl:value-of select="@broadcastTime"/>
</td>
</tr>
<tr>
<th>Description:</th>
<td><xsl:value-of select="description"/></td>
</tr>
</tbody>
</table>
</xsl:for-each>


and it works


No comments:

Post a Comment