Formatting
Resin 3.0

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

Introduction
User's Guide
Reference
Tutorials

How it works
XTP Copy
Formatting
Link Rewriting
JSP tag libraries
XTP Copy
User's Guide
Link Rewriting

A major advantage of XTP is its separation of content from formatting. Your source documents can use meaningful markup tags letting the stylesheet format the output.

The XTP source of this tutorial uses a few tags for basic formatting: <section>, <example>, and <var>.

For example, the source for the tutorial index contains a section like:

TODO: new example

index.xtp
<s1 title="XTP">
<ul>
<li><a href="xtp-copy.xtp">XTP copy</a> treats XTP pages exactly like JSP.
<li><a href="xtp-format.xtp">Format</a> sections, splitting style from content
<li><a href="xtp-page.xtp">Encode links</a> for sessions automatically
<li><a href="xtp-strict.xtp">Strict XSL</a> equivalent to StyleScript
</ul>
</s1>

The stylesheet contains a new rule for s1. In this example, the rule only works when there is a title attribute. In the replacement code, <xsl:value-of select="@title"/> inserts the value of the title attribute.

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>

  <!-- s1 format -->
  <xsl:template match="s1[@title]">
    <table width="100%" cellpadding="5" border="0">
    <tr bgcolor="#ccddff"><td>
      <font size="+2"><b><value-of select="@title"/></b></font>
    </td></tr>
    </table>

    <xsl:apply-templates/>
  </xsl:template>
</xsl:stylesheet>


XTP Copy
User's Guide
Link Rewriting
Copyright © 1998-2005 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.