|
Subject:
|
Problem in displaying "No Dat Available" in a loop
|
|
Posted By:
|
rakesh
|
Post Date:
|
7/28/2008 5:44:43 PM
|
Hello Everyone,
I am looping through "CourtAction" node and displaying the element value simultaneously. At the same time if value is not there it should display "No Data". Now the problem here is if there are more than one node having no values it will display "NO Data" that many number of time which i dont prefer? Can anyone give me a solution for this?
<xsl:for-each select="c:CourtAction"> <xsl:choose> <xsl:when test='c:Disposition/c:DispositionDescriptionText!= " "'> <xsl:value-of select="c:Disposition/c:DispositionDescriptionText"/> <xsl:if test="position()!=last()"> <br></br> </xsl:if> </xsl:when> <xsl:otherwise> <xsl:value-of select="$NoData"></xsl:value-of><br></br> </xsl:otherwise> </xsl:choose> </xsl:for-each>
Also is there a better way of writing the above loop? Say using if else?
Rakesh
|
|
Reply By:
|
mhkay
|
Reply Date:
|
7/28/2008 5:57:43 PM
|
You need to move the conditional outside the loop:
<xsl:choose> <xsl:when test="c:CourtAction/c:Disposition/c:DispositionDescriptionText != ""> <xsl:for-each select="c:CourtAction/c:Disposition/c..... </xsl:for-each> </xsl:when> <xsl:otherwise>No Data</xsl:otherwise> </xsl:choose>
Michael Kay http://www.saxonica.com/ Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
|