XSLT-lite examples
Resin 3.0

Features
Installation
Configuration
Web Applications
IOC/AOP
Resources
JSP
Quercus
Servlets and Filters
Databases
Admin (JMX)
CMP
EJB
Amber
EJB 3.0
Security
XML and XSLT
XTP
JMS
Performance
Protocols
Third-party
Troubleshooting/FAQ

Introduction
JAXP
User's Guide
Reference
FAQ
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-2006 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.