<document>
<localtoc/>

The filter must be configured in the web.xml:

<example> <web-app xmlns="http://caucho.com/ns/resin"> <filter filter-name='xslt' filter-class='com.caucho.filters.XsltFilter'/> <filter-mapping url-pattern='*.jsp' filter-name='xslt'/> </web-app> </example> <%@ page session=false contentType='x-application/xslt' %> <?xml-stylesheet href='xml.xsl'?> <top> <title>Hello, world</title> <count><%= 1 + 1 %></count> </top>

Stylesheets belong in WEB-INF/xsl. If no stylesheet is selected, Resin will use default.xsl.

The xml.xsl stylesheet just copies the input to the output. Many stylesheets will use this rule as a default rule.

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

The HTML example is slightly more complicated. When it matches a top, it generates the HTML header information. The count tag just writes out the count.

<xsl:stylesheet> <xsl:output media-type='text/html'/> <xsl:template match='top'> <html> <head> <title><xsl:value-of select='title'/></title> </head> <body bgcolor='white'> <h3><xsl:value-of select='title'/></h3> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match='count'> Count: <xsl:apply-templates/><br/> </xsl:template> <xsl:template match='title'/> </xsl:stylesheet>
</document>