Jump to content

Trying to get to write out text when no results are found from xml feed


prichardson

Recommended Posts

My search function presents the results fine but when there are no results then rather than having the blank white screen, I would like to have it to say, "Sorry, there are no results.".I tried put an Choose - When & Otherwise on the property name - so if property name empty then write "Sorry, ..." otherwise display name. I thought that would work, but maybe i need to do it around the entire template? Would putting something around the entire block of code (what would i use- when & otherwise ? or something else? )

<xsl:template match="/">	<xsl:for-each select="xxx/xxx/property">  ................................................	</xsl:for-each></xsl:template>

Cheers

Link to comment
Share on other sites

I thought that would work, but maybe i need to do it around the entire template?
If you need to do that, split your template in two and only apply the template when needed. For example:
<xsl:template match="/">	<xsl:choose>		<xsl:when test="/xxx/xxx/property">			<xsl:apply-templates/>		</xsl:when>		<xsl:otherwise>Sorry, no properties.		</xsl:otherwise>	</xsl:choose></xsl:template><xsl:template match="/xxx/xxx/property">................................................</xsl:template>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...