If I have an IF condition, I dont seem to be able to conditionally create a DIV eg..
<xsl:if test="position() mod 2 =1">
<div class="row">
<div class="first">
</xsl:if>
<xsl:if test="position() mod 2 != 1">
<div>
</xsl:if>
It complains that there is no matching DIV. This is because I need to create a ROW div every odd record (1, 3 etc). I will close the DIV every even record or if the current record is the same as the count (e.g. the last).
XSLT conditions and DIVs
If I have an IF condition, I dont seem to be able to conditionally create a DIV eg..
<xsl:if test="position() mod 2 =1">
<div class="row">
<div class="first">
</xsl:if>
<xsl:if test="position() mod 2 != 1">
<div>
</xsl:if>
It complains that there is no matching DIV. This is because I need to create a ROW div every odd record (1, 3 etc). I will close the DIV every even record or if the current record is the same as the count (e.g. the last).
Got it. ..
this is my end row code
<xsl:if test="position() mod 2 = 1 ">
<xsl:text disable-output-escaping="yes"></div></xsl:text>
</xsl:if>
<xsl:if test="position() mod 2 != 1 or (position() mod 2 = 1 and position() = count()) ">
<xsl:text disable-output-escaping="yes"></div></xsl:text>
<xsl:text disable-output-escaping="yes"></div></xsl:text>
</xsl:if>
You could also approach this using templates. Take a look at:
<xsl:call-template name=""></xsl:call-template>
This way you can call different tempaltes base on the results of your mod. Makes for a cleaner and more readable XSLT.
HTH
is working on a reply...