creates a JSP file from an XTP file. XTP pages can
separate the content (in XML) from the scripting (in XSL). The XSL
stylesheets now become a palette of JSP actions you can use just by
adding tags.
- Parse XTP file as HTML
- Find and parse XSL stylesheet
- Applying the stylesheet to the XTP, creating a JSP file
- Execute the JSP file
A trivial example is a named counter. If the counter has an 'id'
attribute, we'll use it at the value of the application variable.
XTP pages can use the counter just by adding the tag:
counter.xtp
A counter example: <ct:counter id='test'/>
|
Here the patterns to do it. For efficiency, we've added the
cache directive. The cache directive tells XTP to execute the
stylesheet only once and cache the generated JSP file.
default.xsl
<xtp:directive.cache/>
<xsl:template match='counter[@id]'>
<jsp:expression>
<xsl:text>application.attribute["</xsl:text>
<xsl:value-of select='@id'/>
<xsl:text>"]<xsl:text>
</jsp:expression>
</xsl:template>
<xsl:template match='counter'>
<jsp:expression>
application.attribute.counter++
</jsp:expression>
</xsl:template>
|
The following JSP file is the result.
will
execute the generated JSP file to process HTTP requests. Because
default.xsl was marked as cached, on following requests
will
merely reexecute 'gen438.jsp'.
gen438.jsp
A counter example: <jsp:expression>
application.attribute["test"]++
<jsp:expression>
|