Resin 1.1
FAQ
Reference
JavaDoc
Demo
Java Tutorial
Getting Started
Configuration
Servlet
JSP
XTP/XSL
JavaScript
JS Library
XTP intro
XTP to JSP
XPath
XPath Fun
XSL
XSL lite
XSL lite examples
XSL lite
'XSLT-lite' adds some syntactic sugar to XSLT to make stylesheets more readable. It lets authors cut down on XSL's verbosity, without losing any of the power. Stylesheets are also freed from the constraints of XML, like entity references ('&amp;'). XSLT-lite can treat unknown elements as text, like JSP. Setting the xsl:stylesheet attribute parsed-content to false will treat elements as text. By default, XSLT-lite uses XSLT behaviour. XSLT-lite templates can create the HTML ' ', even though it's illegal XML. It doesn't expand entities in templates. '&lt;' produces 4 characters. XSLT-lite doesn't expand entities in templates. '&lt;' produces 4 characters. To escape in XSLT-lite, use the backslash as in JSP.
directives
<#@ page attributes #> | Sets page directives
<#@ cache attributes #> | Caches the generated JSP file by default.
templates
pattern << xsl-content >> | Short form of xsl:template.
pattern <#= expression #> | Templates which just print an expression.
pattern <# scriptlet #> | Templates which are generated by JavaScript or Java.
actions
<{expression}> | Prints the value of the XSL expression.
<#= expression #> | Prints the value of expression using the page's language.
<# scriptlet #> | Executes the statements in scriptlet using the page's language.
<#! declaration #> | Adds declaration code, i.e. code outside of any function.
directives
### <#@ page attributes #>
Sets page directives
name | meaning
--- | ---
language | script language, default Java
session | use sessions, default false
errorPage | page to display for errors
errorPage | page to display for errors
import | imports Java packages
contentType | content-type of the generated page
Equivalent to:
<xtp:directive.page attributes/>
### <#@ cache attributes #>
Caches the generated JSP file by default. Caching for XSL is more complicated than for JSP because only some templates may be used in a page. Caching is based on the generated page, not simply on the stylesheet. A page that just uses static templates is automatically cached. Pages that use scripts just for simple calculation can also be cached. But pages that use scripts based on the request cannot be cached.
name | meaning
--- | ---
file | the JSP file depends on file.
no-cache | do not cache the generated JSP.
Equivalent to:
<xtp:directive.cache attributes/>
The following example caches by default, but disables caching when using the counter:
<#@ cache #> ct:counter << <#@ cache no-cache #> <#= out.page.application.attribute.counter++ #> >>
Or programmatically:
<#@ cache #> ct:counter <# out.setNotCacheable(); out.write(out.page.application.attribute.counter++) #>
templates
### pattern << xsl-content >>
Short form of xsl:template. xsl-content is any normal xsl content including text and the XSLT-lite actions. The short template syntax is equivalent to:
<xsl:template match='pattern'> xsl-content </xsl:template>
### pattern <#= expression #>
Templates which just print an expression. expression is a Java or JavaScript expression. The syntax is equivalent to:
<xsl:template match='pattern'> <xtp:expression> expression </xtp:expression> </xsl:template>
### pattern <# scriptlet #>
Templates which are generated by JavaScript or Java. The syntax is equivalent to:
<xsl:template match='pattern'> <xtp:scriptlet> scriptlet </xtp:scriptlet> </xsl:template>
actions
### <{expression}>
Prints the value of the XSL expression. This syntax is a short cut for the xsl:value-of tag. The value-of syntax is equivalent to:
<xsl:value-of select="expression"/>
### <#= expression #>
Prints the value of expression using the page's language. The expression syntax is equivalent to:
<xtp:expression> expression </xtp:expression>
For example, to print the request URL using JavaScript:
ct:url << url: <#= out.page.request.requestURL #> >>
url: /test/url.xtp
### <# scriptlet #>
Executes the statements in scriptlet using the page's language. The scriptlet is any statement list in the language, e.g. Java. The scriptlet syntax is equivalent to
<xtp:scriptlet> scriptlet </xtp:scriptlet>
For example, to print all headers:
ct:headers << Headers: <# for (var header in out.page.request.header) { out.println(header, ":", out.page.request.header[header]); } #> >>
### <#! declaration #>
Adds declaration code, i.e. code outside of any function. The declaration syntax is equivalent to:
<xtp:declaration> declaration </xtp:declaration>
<#! function dist(x1, y1, x2, y2) { return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } #> ct:dist << (<{@x1}>,<{@y1}>) to (<{@x2}>,<{@y2}>) = <#= dist(node.attribute.x1, node.attribute.y1, node.attribute.x2, node.attribute.y2) #> >>
<ct:dist x1='0' y1='0' x2='5' y2='12'/>
(0,0) to (5,12) = 13
XSL |  | XSL lite examples
Copyright © 1998-2000 Caucho Technology. All rights reserved. Last modified: Thu, 16 Sep 1999 14:56:49 -0700 (PDT)