Check to see if nodes are blank or not
<xsl:variable name="volume" select="../volume[. !='']"/> <xsl:variable name="number" select="../number[. !='']"/> <xsl:variable name="pages" select="../pages[. !='']"/>
[ ] brackets mean “when”
!=” means is not equal to nothing (is not null)
eg variable name=”pages” select=”../pages when .(current node) Is not null
The following code concatenates the nodes depending on whether or not they exist and places some intro text before and a comma after each one providing there is another coming after it.
<xsl:if test="$volume or $number or $pages">
<xsl:if test="$volume">Vol. <xsl:value-of select="$volume"/></xsl:if>
<xsl:if test="$number or $pages">, </xsl:if>
<xsl:if test="$number">no. <xsl:value-of select="$number"/>
</xsl:if><xsl:if test="$pages">, </xsl:if>
<xsl:if test="$pages"><xsl:value-of select="$pages"/></xsl:if>
</xsl:if></marc:subfield>
