📄 templatepage.xslt
字号:
<?xml version="1.0" encoding="UTF-8"?>
<!--
*********************************************************************
** A stylesheet used by every page on a web site. This stylesheet
** defines where the page header and navigation bar are placed.
******************************************************************-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--
*******************************************************************
** The result tree is XHTML
****************************************************************-->
<xsl:output method="xml"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
encoding="UTF-8"/>
<!--
*******************************************************************
** The navigation category is determined by the <meta> tag in the
** source XHTML document. The top navigation bar uses this variable.
****************************************************************-->
<xsl:variable name="global.nav.category">
<xsl:choose>
<xsl:when test="/html/head/meta[@name='navigationCategory']">
<xsl:value-of select="/html/head/meta
[@name='navigationCategory']/@content"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>unknown</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!--
*******************************************************************
** This template produces the XHTML document.
****************************************************************-->
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- copy the <head> from the source document -->
<xsl:copy-of select="html/head"/>
<body>
<!-- this table defines the overall layout of the page -->
<table width="100%" cellpadding="4"
cellspacing="0" border="0">
<tr bgcolor="#f0f0f0">
<td colspan="2">
<xsl:call-template name="createTopNavbar"/>
</td>
</tr>
<tr valign="top">
<td bgcolor="#cccccc" width="150px">
<xsl:call-template name="createLeftNavbar"/>
</td>
<td bgcolor="white">
<!--
*******************************************************
** Copy all contents of the <body> from the source
** XHTML document to the result tree XHTML document.
****************************************************-->
<xsl:copy-of select="html/body/* | html/body/text()"/>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
<!--
*******************************************************************
** This template produces the top navigation bar.
****************************************************************-->
<xsl:template name="createTopNavbar">
<xsl:call-template name="navButton">
<xsl:with-param name="category" select="'home'"/>
<xsl:with-param name="displayName" select="'Home'"/>
<xsl:with-param name="url" select="'home.xml'"/>
</xsl:call-template>
|
<xsl:call-template name="navButton">
<xsl:with-param name="category" select="'company'"/>
<xsl:with-param name="displayName" select="'Company'"/>
<xsl:with-param name="url" select="'company.xml'"/>
</xsl:call-template>
|
<xsl:call-template name="navButton">
<xsl:with-param name="category" select="'products'"/>
<xsl:with-param name="displayName" select="'Products'"/>
<xsl:with-param name="url" select="'products.xml'"/>
</xsl:call-template>
|
<xsl:call-template name="navButton">
<xsl:with-param name="category" select="'jobs'"/>
<xsl:with-param name="displayName" select="'Jobs'"/>
<xsl:with-param name="url" select="'jobs.xml'"/>
</xsl:call-template>
</xsl:template>
<!--
*******************************************************************
** This template produces a "button" in the top navigation bar.
****************************************************************-->
<xsl:template name="navButton">
<xsl:param name="category"/>
<xsl:param name="displayName"/>
<xsl:param name="url"/>
<xsl:choose>
<!-- The current category is displayed as text -->
<xsl:when test="$category = $global.nav.category">
<xsl:value-of select="$displayName"/>
</xsl:when>
<!-- All other categories are displayed as hyperlinks -->
<xsl:otherwise>
<a href="{$url}">
<xsl:value-of select="$displayName"/>
</a>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--
*******************************************************************
** This template creates the left navigation area.
****************************************************************-->
<xsl:template name="createLeftNavbar">
Left Navigation Area
</xsl:template>
</xsl:stylesheet>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -