📄 xslt-lite.xtp
字号:
<title>StyleScript</title> 'StyleScript' adds some syntactic sugar to XSLT to make stylesheets morereadable. It lets authors cut down on XSL's verbosity, without losingany of the power. Stylesheets are also freed from the constraints ofXML, like entity references ('&amp;').<p/>StyleScript can treat unknown elements as text, like JSP. Settingthe xsl:stylesheet attribute parsed-content to false will treatelements as text. By default, StyleScript uses XSLT behaviour.StyleScript templates can create the HTML '<br>', even though it'sillegal XML. It doesn't expand entities in templates. '&lt;'produces 4 characters. <p/>StyleScript doesn't expand entities in templates. '&lt;'produces 4 characters. To escape in StyleScript, use the backslash asin JSP.<objsummary/><section name='directives' title='directives'><defun name=page title='<#@ page attributes #>'><sum>Sets page directives</sum><deftable><tr><th>name<th>meaning<tr><td>language<td>script language, default Java<tr><td>session<td>use sessions, default false<tr><td>errorPage<td>page to display for errors<tr><td>errorPage<td>page to display for errors<tr><td>import<td>imports Java packages <tr><td>contentType<td>content-type of the generated page</deftable>Equivalent to:<def><xtp:directive.page <var/attributes/>/></def></defun><defun name=cache title='<#@ cache attributes #>'><sum>Caches the generated JSP file by default.</sum><p>Caching for XSL is more complicated than for JSP because only sometemplates may be used in a page. Caching is based on the generatedpage, not simply on the stylesheet.<p/>A page that just uses statictemplates is automatically cached. Pages that use scripts just forsimple calculation can also be cached. But pages that use scriptsbased on the request cannot be cached.<deftable><tr><th>name<th>meaning<tr><td>file<td>the JSP file depends on <var/file/>.<tr><td>no-cache<td>do not cache the generated JSP.</deftable>Equivalent to:<def><xtp:directive.cache <var/attributes/>/></def>The following example caches by default, but disables caching whenusing the counter:<example><#@ cache #>ct:counter <<<#@ cache no-cache #><#= out.page.application.attribute.counter++ #>>></example>Or programmatically:<example><#@ cache #>ct:counter <#out.setNotCacheable();out.write(out.page.application.attribute.counter++)#></example></defun></section><section name='templates' title='templates'><defun name=short-content title='pattern << xsl-content >>' index='template'><sum>Short form of xsl:template.</sum> <var/xsl-content/> is anynormal xsl content including text and the StyleScript actions.<p/>The short template syntax is equivalent to:<def><xsl:template match='<var/pattern/>'><var/xsl-content/></xsl:template></def></defun><defun name=temp-expr title='pattern <#= expression #>'index='template, expression'><sum>Templates which just print an expression.</sum> <var/expression/> isa Java or JavaScript expression.<p/>The syntax is equivalent to:<def><xsl:template match='<var/pattern/>'><xtp:expression> <var/expression/></xtp:expression></xsl:template></def></defun><defun name=temp-script title='pattern <# scriptlet #>'index='template, expression'><sum>Templates which are generated by JavaScript or Java.</sum><p/>The syntax is equivalent to:<def><xsl:template match='<var/pattern/>'><xtp:scriptlet> <var/scriptlet/></xtp:scriptlet></xsl:template></def></defun></section><section name='actions' title='actions'><defun name=value-of title='$(expression)' index='value-of'><sum>Prints the value of the XSL <var/expression/>.</sum> This syntaxis a short cut for the xsl:value-of tag.<p/>The value-of syntax is equivalent to:<def><xsl:value-of select="<var/expression/>"/></def></defun><defun name=expression title='<#= expression #>' index='expression'><sum>Prints the value of <var/expression/> using the page's language.</sum><p/>The expression syntax is equivalent to:<def><xtp:expression><var/expression/></xtp:expression></def>For example, to print the request URL using JavaScript:<example><example>ct:url <<url: <#= out.page.request.requestURL #>>></example><results>url: /test/url.xtp</results></example></defun><defun name=scriptlet title='<# scriptlet #>' index='scriptlets'><sum>Executes the statements in <var/scriptlet/> using the page's<a href='jsp-directives.xtp#language'>language</a>.</sum><p>The <var/scriptlet/> is any statement list in the language,e.g. Java.<p/>The scriptlet syntax is equivalent to <def><xtp:scriptlet><var/scriptlet/></xtp:scriptlet></def>For example, to print all headers:<example>ct:headers <<Headers: <# for (var header in out.page.request.header) { out.println(header, ":", out.page.request.header[header]); }#>>></example></defun><defun name=declaration title='<#! declaration #>' index='declaration'><sum>Adds declaration code, i.e. code outside of any function.</sum><p/>The declaration syntax is equivalent to:<def><xtp:declaration><var/declaration/></xtp:declaration></def><example><example><#!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)#>>></example><example><ct:dist x1='0' y1='0' x2='5' y2='12'/></example><results>(0,0) to (5,12) = 13</results></example></defun></section>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -