I have a for-each and when there is nothing output by it I would like to display some default text.
If I have…
<xsl:for-each select='xpath'> Some content for each matching element result. </xsl:for-each>
What I would like is:
<xsl:for-each select='xpath'>
<xsl:output-this-when-there-is-content> Some content for each matching element result. </xsl:output-this-when-there-is-content>
<xsl:no-results-output> Some content for when the for-each finds no matches. </xsl:no-results-output>
</xsl:for-each>
Can anyone tell me how to do this, please?
Thanks,
Matt
Assuming you have:
The you can do something like:
To avoid the double test of the XPath (and duplication) you could probably use an
xsl:variable, something like the following (syntax may be a little wrong, but the rough idea should be right).