Reputation: 28
Im trying to edit a mail being formatted with XSL 1 to display one line if my template conditions are met and information is displayed in the mail. The mail has the current format:
People attending:
person1
-someinfo
person2
-someinfo
People not attending:
person3
-someinfo
The problem is when there are nothing displayed for people not attending, the mail will still show "People not attending:" as i currently have it before running the apply-template.
Is there any good way to display the paragraph before the information about people not attending, only if there are people not attending? The reason for two templates is that in my original code i check for changes in the xml.
Code:
<p>People not attending</p>
<xsl:apply-templates select="1_type/2_group/1_type_f" mode="pn"/>
<xsl:template match="1_type_f" mode="pn">
<xsl:if test="((1_type_f_v/@old_selected='Selected') and (1_type_f_v/@selected!='Selected'))">
<xsl:apply-templates select="t1_type_f_v" mode="pn"/>
</xsl:if>
</xsl:template>
<xsl:template match="1_type_f_v" mode="pn">
<xsl:if test="((@old_selected='Selected') and (@selected!='Selected'))">
<p><xsl:value-of select="../nameOfPerson"/></p>
<ul>
<li><xsl:value-of select="someInfo"/></li>
<p><xsl:value-of select="someInfo2"/></p>
</ul>
</xsl:if>
</xsl:template>
Upvotes: 0
Views: 26
Reputation: 167716
Instead of outputting
<p>People not attending</p>
<xsl:apply-templates select="1_type/2_group/1_type_f" mode="pn"/>
unconditionally you need to use xsl:if
<xsl:if test="1_type/2_group/1_type_f">
<p>People not attending</p>
<xsl:apply-templates select="1_type/2_group/1_type_f" mode="pn"/>
</xsl:if>
I am not quite sure if the xsl:if test
condition I have used above suffices, I suppose it might not, so you will need to see whether you can adapt it to check whether the input has any elements you will output there.
Another option would be to run the apply-templates into a variable, convert it to a node-set with exsl:node-set
or similar and then check whether it has any relevant content and only then to output the heading (or in your case p
) and the contents of the variablee.
Upvotes: 1