M
Michael Ahlers
Obviously if you're looping or using a template, choosing output based
on the current iteration is easy. For example, if you're walking a
set of elements and you want index % 2 == 0 produce one thing and
another when that is not true. My question is, what if you are not
looping through tags but want to achieve a similar effect without
having to be excessively verbose? Is there any way that I can
simplify the following block?
<!-- ... -->
<dt>
<xsl:attribute name="class"><xsl:text>Even</xsl:text></xsl:attribute>
<xsl:text>Sex</xsl:text>
</dt>
<dd>
<xsl:attribute name="class"><xsl:text>Even</xsl:text></xsl:attribute>
<xsl:value-of select="Sex"/>
</dd>
<dt>
<xsl:attribute name="class"><xsl:text>Odd</xsl:text></xsl:attribute>
<xsl:text>Height</xsl:text>
</dt>
<dd>
<xsl:attribute name="class"><xsl:text>Odd</xsl:text></xsl:attribute>
<xsl:value-of select="Height"/>
</dd>
<!-- ... -->
That's particularly annoying if you want to insert an element anywhere
other than the end of the list. You cannot modify variables, so
incrementing as you walk along is not possible. I can't exactly loop
because the name of the element is not necessarily human-friendly.
Any ideas?
on the current iteration is easy. For example, if you're walking a
set of elements and you want index % 2 == 0 produce one thing and
another when that is not true. My question is, what if you are not
looping through tags but want to achieve a similar effect without
having to be excessively verbose? Is there any way that I can
simplify the following block?
<!-- ... -->
<dt>
<xsl:attribute name="class"><xsl:text>Even</xsl:text></xsl:attribute>
<xsl:text>Sex</xsl:text>
</dt>
<dd>
<xsl:attribute name="class"><xsl:text>Even</xsl:text></xsl:attribute>
<xsl:value-of select="Sex"/>
</dd>
<dt>
<xsl:attribute name="class"><xsl:text>Odd</xsl:text></xsl:attribute>
<xsl:text>Height</xsl:text>
</dt>
<dd>
<xsl:attribute name="class"><xsl:text>Odd</xsl:text></xsl:attribute>
<xsl:value-of select="Height"/>
</dd>
<!-- ... -->
That's particularly annoying if you want to insert an element anywhere
other than the end of the list. You cannot modify variables, so
incrementing as you walk along is not possible. I can't exactly loop
because the name of the element is not necessarily human-friendly.
Any ideas?