Reputation: 43
I am fairly new to XSLT. This is my XSLT code:
<xsl:for-each select="/page/articles[@controlid='name']/article[position() < 10]/article_data">
<div class="col-md-4 col-xs-12">
<xsl:if test="/page/articles[@controlid='name']/article[position() = 1]">
<xsl:attribute name="class">
<xsl:text>col-md-8 col-xs-12</xsl:text>
</xsl:attribute>
</xsl:if>
....HTML markup.....
</div>
</xsl:for-each>
I am creating a bootstrap layout with a for-each loop.
And I am trying to change the class of the first div
from 'col-md-4' to 'col-md-8', but the above code changes the classes of all 10 div
s.
Any help is appreciated.
Upvotes: 0
Views: 54
Reputation: 116993
Try:
<xsl:for-each select="/page/articles[@controlid='name']/article[position() < 10]/article_data">
<div class="col-md-4 col-xs-12">
<xsl:if test="position() = 1">
<xsl:attribute name="class">col-md-8 col-xs-12</xsl:attribute>
</xsl:if>
....HTML markup.....
</div>
</xsl:for-each>
Untested, because no code to allow testing was provided.
Upvotes: 1