Setting count for each section in an accordion



I'm very new to xslt and I seem to have got stuck. I'm creating an accordion of posts on a site, where the information is coming from an xml file. Within my xml file, I have multiple blog posts, but there is no set number of posts - this is where I'm stuck. I believe I want to assign each section in my xsl file with a number such as a count, but I'm unsure how to set a counter. My xml file outline just in case it's of any use is



<blog>
<blogPost>
<information></information>
</blogPost>
<blogPost>
<information></information>
</blogPost>
<blog>


I use a template to pull the information, which is working, but to form the 'accordion' I need to set an id for each section.



<xsl:template match="blogPost">


<article>

<div class="accordion vertical">
<section id="">

<h2><xsl:apply-templates select="postTitle"/></h2>
<p><xsl:apply-templates select="postText"/></p>
<p><xsl:apply-templates select="postImage"/></p>
<p><xsl:apply-templates select="postQuote"/></p>
<p><xsl:apply-templates select="postLink"/></p>
<p><xsl:apply-templates select="postAudio"/></p>
<p><xsl:apply-templates select="postVideo"/></p>
<p><xsl:apply-templates select="postChat"/></p>

<b><p><xsl:apply-templates select="postDate"/></p>
<p><xsl:apply-templates select="postTags"/></p></b>
</section>
</div>
</article>
</xsl:template>


Any help of how to set a $count or just set a number variable would be greatly appreciated, as when I've tried googling I can't work out how to apply it to what I have done. Thanks in advance.


No comments:

Post a Comment