XTP pages can use the counter just by adding the tag: A counter example: <ct:counter id='test'/> Here the patterns to do it. For efficiency, we've added the directive. The cache directive tells XTP to execute the stylesheet only once and cache the generated JSP file. <#@ cache #> counter[@id] << <%= application.attribute[""] %> >> counter << <%= application.attribute.counter++ %> >> ct:get prints the value of a variable ct:if generates an if statement ct:iter loops ct:get << <%= <{@expr}> %> >> ct:if << <% if (<{@expr}>) { %> <xsl:apply-templates/> <% } %> >> ct:iter[@index] << <% for (var <{@index}> in <{@expr}>) { %> <xsl:apply-templates/> <% } %> >> ct:iter << <% for (var i in <{@expr}>) { %> <xsl:apply-templates/> <% } %> >>