| |
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:
<s1>, <example>, and <var>.
For example, the source for the tutorial index contains a section
like:
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 '<' -->
<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>
|
Copyright © 1998-2002 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark,
and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc. | |
|