xml - Reducing the need for xsl:if and code duplications -
i have xslt code differs single class element. however, of internal div content.
i attempted separate out starting tag such:
<xsl:if test="position() = 1"> <div class="position first"> </xsl:if> <xsl:if test="position() != 1"> <div class="position"> </xsl:if>
but ofcourse produces invalid xslt code. [the div's must closed within scope].
is there way add optional class keyword without have reduplicate internal contents?
try this:
<div class="position"> <xsl:if test="position() = 1"> <xsl:attribute name="class">position first</xsl:attribute> </xsl:if> </div>
the xsl:attribute
instruction should override literal attribute.
Comments
Post a Comment