XSL if the contents of the test screen when it matters

I have an if test where I want to display the contents of the year property with a comma when the property has values. This does not work, so I will be grateful for the suggestions.

 <xsl:if test="year != null"> <xsl:value-of select="year"/>, </xsl:if> 
+7
source share
2 answers

You can check for the presence of the year element simply by using this expression:

 <xsl:if test="year"> 

If you want to check that the year element is not empty:

 <xsl:if test="year != ''"> 
+8
source
 <xsl:if test="year != null"> <xsl:value-of select="year"/>, </xsl:if> 

This will be true() if there is at least one child year current node and one null child of the current node whose string values ​​are not equal.

Most likely, the XML document does not have a null element that you did not specify ...

Using

 <xsl:if test="year"> <xsl:value-of select="concat(year, ',')"/> </xsl:if> 
0
source

All Articles