caucho
Resin
FAQ
Reference Guide
JavaDoc
Demo
Tutorial

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

Formatting
XTP Page
Strict XSL
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 XTP 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.

The following syntax uses Resin's StyleScript as the stylesheet language. StyleScript is semantically equivalent to strict XSL, but it less verbose and more readable. A following page uses strict XSL.

default.xsl
<!-- make sure '<' is not printed as '&lt;' -->
$output(disable-output-escaping=>true);

<!-- copy input to output -->
*|@* <<
  $copy() <<
    $apply-templates(node()|@*);
  >>
>>

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 $copy() copies the current node and calls $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-2001 Caucho Technology. All rights reserved.
Copyright © 1998-2001 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.