You are viewing a plain text version of this content. The canonical link for it is here.
Posted to site-cvs@jakarta.apache.org by cr...@apache.org on 2001/07/27 20:54:01 UTC
cvs commit: jakarta-site2/xdocs/stylesheets site.xsl
craigmcc 01/07/27 11:54:01
Modified: . .cvsignore build.xml
Added: xdocs/stylesheets site.xsl
Log:
Add an XSLT stylesheet (site.xsl) that is functionally equivalent to the
"site.vsl" stylesheet that Anakia uses to generate HTML for the web site.
Remaining TODOs are listed at the top. This stylesheet allows use of
XSLT to render HTML pages that are equivalent to those rendered by the
current process - the new Ant "xslt" target does this, using the Ant
<style> tag.
NOTE: There is one important functional difference between running Anakia
and XSLT transformations -- dealing with relative paths. Anakia solves
this problem by predefining the "$relativePath" variable as it recurses
its way down the source directory tree. The simplest way to deal with
this in XSLT is to transform each directory individually, and pass the
appropriate relative path prefix as a parameter to the stylesheet (see the
top-level build.xml for an example of how to do this).
Revision Changes Path
1.2 +1 -0 jakarta-site2/.cvsignore
Index: .cvsignore
===================================================================
RCS file: /home/cvs/jakarta-site2/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .cvsignore 2001/01/26 22:45:25 1.1
+++ .cvsignore 2001/07/27 18:54:01 1.2
@@ -1 +1,2 @@
velocity.log
+xslt
1.7 +53 -2 jakarta-site2/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-site2/build.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- build.xml 2001/07/10 22:39:25 1.6
+++ build.xml 2001/07/27 18:54:01 1.7
@@ -5,6 +5,7 @@
<property name="docs.src" value="./xdocs"/>
<property name="docs.dest" value="./docs"/>
<property name="docs.dest.print" value="./docs_print"/>
+ <property name="xslt.dest" value="./xslt"/>
<!-- Build classpath -->
<path id="classpath">
@@ -27,7 +28,9 @@
</echo>
</target>
- <target name="docs" depends="prepare-error" if="AnakiaTask.present">
+ <!-- This Target is for output of HTML pages for the web site -->
+ <target name="docs" depends="prepare-error" if="AnakiaTask.present"
+ description="Render HTML Pages via Anakia">
<taskdef name="anakia"
classname="org.apache.velocity.anakia.AnakiaTask">
<classpath refid="classpath"/>
@@ -58,7 +61,8 @@
</target>
<!-- This Target is for output of documentation that can be printed -->
- <target name="docs_print" depends="prepare-error" if="AnakiaTask.present">
+ <target name="docs_print" depends="prepare-error" if="AnakiaTask.present"
+ description="Render Printable Pages via Anakia">
<taskdef name="anakia"
classname="org.apache.velocity.anakia.AnakiaTask">
<classpath refid="classpath"/>
@@ -80,5 +84,52 @@
</fileset>
</copy>
</target>
+
+
+ <!-- This target is for output of HTML pages via XSLT -->
+ <!-- Requires JAXP/1.1 (all three JARs) or Xerces+Xalan -->
+ <target name="xslt"
+ description="Render HTML Pages via XSLT">
+
+ <!-- Create destination directory if necessary -->
+ <mkdir dir="${xslt.dest}"/>
+
+ <!-- Transform the top-level directory -->
+ <style basedir="${docs.src}"
+ destdir="${xslt.dest}"
+ extension=".html"
+ style="stylesheets/site.xsl"
+ excludes="empty.xml"
+ includes="*.xml">
+ <param name="relative-path" expression="."/>
+ </style>
+
+ <!-- Transform the "site" subdirectory -->
+ <style basedir="${docs.src}/site"
+ destdir="${xslt.dest}/site"
+ extension=".html"
+ style="../stylesheets/site.xsl"
+ includes="*.xml">
+ <param name="relative-path" expression=".."/>
+ </style>
+
+ <!-- Copy static resource files -->
+ <copy todir="${xslt.dest}/images" filtering="no">
+ <fileset dir="${docs.src}/images">
+ <include name="**/*.gif"/>
+ <include name="**/*.jpeg"/>
+ <include name="**/*.jpg"/>
+ </fileset>
+ </copy>
+
+ <!-- Copy CSS stylesheets -->
+ <copy todir="${xslt.dest}" filtering="no">
+ <fileset dir="${docs.src}">
+ <include name="**/*.css"/>
+ </fileset>
+ </copy>
+
+ </target>
+
</project>
1.1 jakarta-site2/xdocs/stylesheets/site.xsl
Index: site.xsl
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Content Stylesheet for "jakarta-site2" Documentation -->
<!-- NOTE: Changes here should also be reflected in "site.vsl" and vice
versa, so either Anakia or XSLT can be used for document generation. -->
<!-- Outstanding Compatibility Issues (with Anakia-based stylesheets):
* Calculation of the hyperlink for navigation menu items (site.xsl prefixes
with relative path unconditionally; needs conditional logic like the
"projectanchor" macro).
* Handling of the <image> element to insert relative path prefixes
* Special table formatting of the <table>, <tr>, and <td> tags. (I don't
really like this as an approach for styling things, but it's needed
for strict compatibility :-).
* Functional equivalent of "site_printable.vsl" not yet started.
-->
<!-- $Id: site.xsl,v 1.1 2001/07/27 18:54:01 craigmcc Exp $ -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<!-- Output method -->
<xsl:output method="html"
encoding="iso-8859-1"
indent="no"/>
<!-- Defined parameters (overrideable) -->
<xsl:param name="relative-path" select="'.'"/>
<!-- Defined variables (non-overrideable) -->
<xsl:variable name="body-bg" select="'#ffffff'"/>
<xsl:variable name="body-fg" select="'#000000'"/>
<xsl:variable name="body-link" select="'#525D76'"/>
<xsl:variable name="banner-bg" select="'#525D76'"/>
<xsl:variable name="banner-fg" select="'#ffffff'"/>
<xsl:variable name="sub-banner-bg" select="'#828DA6'"/>
<xsl:variable name="sub-banner-fg" select="'#ffffff'"/>
<xsl:variable name="table-th-bg" select="'#039acc'"/>
<xsl:variable name="table-td-bg" select="'#a0ddf0'"/>
<xsl:variable name="source-color" select="'#023264'"/>
<!-- Process an entire document into an HTML page -->
<xsl:template match="document">
<xsl:variable name="project"
select="document('project.xml')/project"/>
<html>
<head>
<title><xsl:value-of select="$project/title"/> - <xsl:value-of select="properties/title"/></title>
<xsl:for-each select="properties/author">
<xsl:variable name="name">
<xsl:value-of select="."/>
</xsl:variable>
<xsl:variable name="email">
<xsl:value-of select="@email"/>
</xsl:variable>
<meta name="author" value="{$name}"/>
<meta name="email" value="{$email}"/>
</xsl:for-each>
</head>
<body bgcolor="{$body-bg}" text="{$body-fg}" link="{$body-link}"
alink="{$body-link}" vlink="{$body-link}">
<table border="0" width="100%" cellspacing="4">
<xsl:comment>PAGE HEADER</xsl:comment>
<tr><td colspan="2">
<xsl:comment>JAKARTA LOGO</xsl:comment>
<a href="http://jakarta.apache.org/">
<img src="http://jakarta.apache.org/images/jakarta-logo.gif"
align="left" alt="The Jakarta Project" border="0"/>
</a>
<xsl:if test="$project/logo">
<xsl:variable name="alt">
<xsl:value-of select="$project/logo"/>
</xsl:variable>
<xsl:variable name="home">
<xsl:value-of select="$project/@href"/>
</xsl:variable>
<xsl:variable name="src">
<xsl:value-of select="$project/logo/@href"/>
</xsl:variable>
<xsl:comment>PROJECT LOGO</xsl:comment>
<a href="{$home}">
<img src="{$src}" align="right" alt="{$alt}" border="0"/>
</a>
</xsl:if>
</td></tr>
<xsl:comment>HEADER SEPARATOR</xsl:comment>
<tr>
<td colspan="2">
<hr noshade="" size="1"/>
</td>
</tr>
<tr>
<xsl:comment>LEFT SIDE NAVIGATION</xsl:comment>
<td width="20%" valign="top" nowrap="true">
<xsl:apply-templates select="$project/body/menu"/>
</td>
<xsl:comment>RIGHT SIDE MAIN BODY</xsl:comment>
<td width="80%" valign="top" align="left">
<xsl:apply-templates select="body/section"/>
</td>
</tr>
<xsl:comment>FOOTER SEPARATOR</xsl:comment>
<tr>
<td colspan="2">
<hr noshade="" size="1"/>
</td>
</tr>
<xsl:comment>PAGE FOOTER</xsl:comment>
<tr><td colspan="2">
<div align="center"><font color="{$body-link}" size="-1"><em>
Copyright © 1999-2001, Apache Software Foundation
</em></font></div>
</td></tr>
</table>
</body>
</html>
</xsl:template>
<!-- Process a menu for the navigation bar -->
<xsl:template match="menu">
<p><strong><xsl:value-of select="@name"/></strong></p>
<ul>
<xsl:apply-templates select="item"/>
</ul>
</xsl:template>
<!-- Process a menu item for the navigation bar -->
<xsl:template match="item">
<xsl:variable name="href">
<xsl:value-of select="$relative-path"/><xsl:value-of select="@href"/>
</xsl:variable>
<li><a href="{$href}"><xsl:value-of select="@name"/></a></li>
</xsl:template>
<!-- Process a documentation section -->
<xsl:template match="section">
<xsl:variable name="name">
<xsl:value-of select="@name"/>
</xsl:variable>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<!-- Section heading -->
<tr><td bgcolor="{$banner-bg}">
<font color="{$banner-fg}" face="arial,helvetica.sanserif">
<a name="{$name}">
<strong><xsl:value-of select="@name"/></strong></a></font>
</td></tr>
<!-- Section body -->
<tr><td><blockquote>
<xsl:apply-templates/>
</blockquote></td></tr>
</table>
</xsl:template>
<!-- Process a documentation subsection -->
<xsl:template match="subsection">
<xsl:variable name="name">
<xsl:value-of select="@name"/>
</xsl:variable>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<!-- Subsection heading -->
<tr><td bgcolor="{$sub-banner-bg}">
<font color="{$sub-banner-fg}" face="arial,helvetica.sanserif">
<a name="{$name}">
<strong><xsl:value-of select="@name"/></strong></a></font>
</td></tr>
<!-- Subsection body -->
<tr><td><blockquote>
<xsl:apply-templates/>
</blockquote></td></tr>
</table>
</xsl:template>
<!-- Process a source code example -->
<xsl:template match="source">
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="{$source-color}" width="1" height="1">
<img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/>
</td>
<td bgcolor="{$source-color}" height="1">
<img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/>
</td>
<td bgcolor="{$source-color}" width="1" height="1">
<img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/>
</td>
</tr>
<tr>
<td bgcolor="{$source-color}" width="1">
<img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/>
</td>
<td bgcolor="#ffffff" height="1"><pre>
<xsl:value-of select="."/>
</pre></td>
<td bgcolor="{$source-color}" width="1">
<img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/>
</td>
</tr>
<tr>
<td bgcolor="{$source-color}" width="1" height="1">
<img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/>
</td>
<td bgcolor="{$source-color}" height="1">
<img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/>
</td>
<td bgcolor="{$source-color}" width="1" height="1">
<img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/>
</td>
</tr>
</table>
</div>
</xsl:template>
<!-- Process everything else by just passing it through -->
<xsl:template match="*|@*">
<xsl:copy>
<xsl:apply-templates select="@*|*|text()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>