XSLT-lite examples
Resin

Change Log
Documentation

Orientation
Features
Installation
Configuration
Web Applications
JSP
Servlets and Filters
Databases
Admin (JMX)
Security
XML and XSLT
XTP
Resources (JNDI)
Performance
Protocols
Third-party
Troubleshooting

Introduction
User's Guide
Reference
Scrapbook

XML Path Language (XPath)
XSLT-lite examples
XSLT Filter
XML Path Language (XPath)
User's Guide
XSLT Filter

  1. Counter
  2. JSP flow control

Counter

XTP pages can use the counter just by adding the tag:

counter.xtp
A counter example: <ct:counter id='test'/>

Here the patterns to do it. For efficiency, we've added the cache directive. The cache directive tells XTP to execute the stylesheet only once and cache the generated JSP file.

default.xsl
<#@ cache #>

counter[@id] <<
<%=
application.attribute["<{@id}>"]
%>
>>

counter <<
<%= application.attribute.counter++ %>
>>

JSP flow control

  • ct:get prints the value of a variable
  • ct:if generates an if statement
  • ct:iter loops

definition of ct:get

ct:get <<
<%= <{@expr}> %>
>>

definition of ct:if
ct:if <<
<% if (<{@expr}>) { %>
  <xsl:apply-templates/>
<% } %>
>>

definition of ct:iter
ct:iter[@index] <<
<% for (var <{@index}> in <{@expr}>) { %>
  <xsl:apply-templates/>
<% } %>
>>

ct:iter <<
<% for (var i in <{@expr}>) { %>
  <xsl:apply-templates/>
<% } %>
>>


XML Path Language (XPath)
User's Guide
XSLT Filter
Copyright © 1998-2003 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.