caucho
Resin
FAQ
Reference Guide
Demo
Tutorial

JSP page
Config
URLs
Database Forms
XTP Copy
Hello Tag
Vary Filter
HardCore
Mailing Forms
Beans
Cache
XSL Filter
run-at
jndi app config

Formatting
XTP Page
JSP Tag Libraries with XTP
JSP Tag Libraries with StyleScript
 XTP Identity

Database Config
Tutorial
Formatting

XTP (XML template pages) lets you ease into XML and XSLT (XML Stylesheet Tranformations). Your Serif pages can be almost identical to JSP pages and just use XSLT to eliminate repetitious error-prone patterns.

XTP transforms XML or HTML documents into a XML or HTML output. In other words, it's an XML transformation. So each XTP page has four parts:

  1. The input XML (the XTP file)
  2. The transformation stylesheet (the XSL file)
  3. The generated JSP
  4. The generated output (the result of executing the JSP)

The easiest transformation is the identity transformation. The following stylesheet copies the input into the output.

default.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

  <!-- make sure '<' is not printed as '&lt;' -->
  <xsl:output disable-output-escaping='true'/>

  <!-- copy input to output -->
  <xsl:template match='*|@*'>
    <xsl:copy>
      <xsl:apply-templates select='node()|@*'/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

Each template contains a match pattern and a replacement tree. The match pattern is an XPath expression. In the above example, the match pattern *|@* matches any element and any attribute. The replacement xsl:copy copies the current node and calls xsl:apply-templates to recursively evaluate any children of the current node.

You can put default.xsl in the same directory as the xtp file, or you can put in WEB-INF/xsl, or you can put it in the classpath like WEB-INF/classes. The last option is useful if you want to create a jar of useful stylesheets and beans.

Your XTP page may look something like:

test.xtp
<h1>My test</h1>

Adding: 2 + 2 = <%= 2 + 2 %>

The generated JSP is identical to the input, and the generated HTML just executes the JSP.

<h1>My test</h1>

Adding: 2 + 2 = 4


Database Config
Tutorial
Formatting
Copyright © 1998-2002 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.