Login   Register  
PHP Classes
elePHPant
Icontem

File: xmlSiteMaker/content/xslt/site-page.xsl

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Ilya Nemihin  >  xmlSiteMaker  >  xmlSiteMaker/content/xslt/site-page.xsl  >  Download  
File: xmlSiteMaker/content/xslt/site-page.xsl
Role: Auxiliary data
Content type: text/plain
Description: xslt transformation
Class: xmlSiteMaker
Offline site generator based on XML
Author: By
Last change: remove encoding line
Date: 2003-02-18 11:25
Size: 9,309 bytes
 

Contents

Class file image Download
<?xml version="1.0"?>

<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  >
<xsl:output
method="html"
/>


<xsl:template match="page-of-site">
<html>
<head>
  <title><xsl:value-of select="/page-of-site/pages//page[ @id = /page-of-site/pageId ]/@name"/></title>
  <link rel="stylesheet" href="style.css"/>
</head>
<body>
  <xsl:call-template name="top"/>
  <xsl:call-template name="header"/>
  <xsl:call-template name="content"/>
  <xsl:call-template name="bottom"/>
</body>
</html>
</xsl:template>

<!-- ========================[ top ]======================== -->

<xsl:template name="top">
<a name="top"/>
  <table align="center" width="700" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td><a href="index.html" title="Home"><span class="top">xmlSiteMaker</span></a></td>
    </tr>
    <tr>
      <td bgcolor="#000"></td>
    </tr>
    <tr>
      <td><xsl:call-template name="menu-bar"/></td>
    </tr>
  </table>
</xsl:template>

<!-- ========================[ menu-bar ]======================== -->

<xsl:template name="menu-bar">
  <xsl:for-each select="/page-of-site/pages/page">
    <xsl:choose>
      <xsl:when test="/page-of-site/pages//page[ @id = /page-of-site/pageId ]/ancestor-or-self::page[ @id = current()/@id]">
        <b><xsl:value-of select="@name"/></b>
      </xsl:when>
      <xsl:otherwise>
        <a href="{@id}.html" title="{@descr}"><xsl:value-of select="@name"/></a>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:if test="position() != last()">
      <xsl:text> | </xsl:text>
    </xsl:if>
  </xsl:for-each>
</xsl:template>

<!-- ========================[ header ]======================== -->

<xsl:template name="header">
<p/>
<xsl:variable name="pageId" select="/page-of-site/pageId"/>
<table align="center" width="700" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="4" bgcolor="#000"></td>
  </tr>
  <tr>
    <td width="1" bgcolor="#000"></td>
    <td>
      <!-- -->
      <xsl:for-each select="/page-of-site/pages//page[ @id = $pageId ]/ancestor::page">
        <a href="{@id}.html"><xsl:value-of select="@name"/></a><xsl:text> &gt; </xsl:text>
      </xsl:for-each>

      <!-- current page name -->
      <b><xsl:value-of select="/page-of-site/pages//page[ @id = $pageId ]/@name"/></b>

      <!--  subpages list -->
      <xsl:if test="/page-of-site/pages//page[ @id = $pageId ]/page and not(/page-of-site/pages//page[ @id = $pageId ]/@show-sub-menu = 'no')">
        <br/>
        &#160;[ <small>
        <xsl:for-each select="/page-of-site/pages//page[ @id = $pageId ]/page">
        <a href="{@id}.html"><xsl:value-of select="@name"/></a>
        <xsl:if test="position() != last()"> | </xsl:if>
        </xsl:for-each>
        </small> ]
      </xsl:if>
      <!--  /subpages list -->
    </td>
    <td width="1" bgcolor="#000"></td>
  </tr>
</table>
</xsl:template>

<!-- ========================[ content ]======================== -->

<xsl:template name="content">
  <table align="center" width="700" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="1" bgcolor="#000"></td>
      <td>&#160;</td>
      <td width="700">
      <table width="100%" border="0" cellpadding="5" cellspacing="0">
      <tr>
      <td>
        <br/>
        <xsl:apply-templates select="/page-of-site/page-content/node()" mode="content"/>
        <div align="right">
        <small>
  <xsl:for-each select="/page-of-site/pages//page[ @id = /page-of-site/pageId ]">
     <xsl:if test="@id = /page-of-site/pageId">
       <xsl:if test="preceding-sibling::page">
         <a href="{preceding-sibling::page[1]/@id}.html">&lt; <xsl:value-of select="preceding-sibling::page[1]/@name"/></a>
       </xsl:if>
       <xsl:if test="preceding-sibling::page and  following-sibling::page">
       <xsl:text> | </xsl:text>
       </xsl:if>
       <xsl:if test="following-sibling::page">
         <a href="{following-sibling::page[1]/@id}.html"><xsl:value-of select="following-sibling::page[1]/@name"/> &gt;</a>
       </xsl:if>
     </xsl:if>
  </xsl:for-each>
        </small>
        </div>
      </td>
      </tr>
      </table>
    </td>
    <td>&#160;</td>
    <td width="1" bgcolor="#000"></td>
  </tr>
</table>
<table align="center" width="700" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#000"></td>
  </tr>
</table>
</xsl:template>

<!-- ========================[ bottom ]======================== -->

<xsl:template name="bottom">
<p/>

<table align="center" width="700" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#000"></td>
  </tr>
  <tr>
    <td><xsl:call-template name="bottom-text"/></td>
  </tr>
</table>
</xsl:template>

<!-- ========================[ bottom-text ]======================== -->

<xsl:template name="bottom-text">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
  <tr>
    <td><small>
    <!-- (c) -->
    <xsl:value-of select="/page-of-site/common/year"/>,
    <xsl:value-of select="/page-of-site/common/name"/>,
    <a href="mailto:{/page-of-site/common/email}"><xsl:value-of select="/page-of-site/common/email"/></a>
    </small></td>
    <td align="right"><small><a href="#top" title="On top page">on top page</a>
    <xsl:call-template name="next-page"/>
    </small></td>
  </tr>
</table>
</xsl:template>

<!-- ========================[ next-page ]======================== -->

<xsl:template name="next-page">
  <xsl:variable name="pageIdRoot" select="/page-of-site/pages//page[ @id = /page-of-site/pageId ]/ancestor-or-self::page[ last() ]/@id"/>
  <xsl:if test="/page-of-site/pages/page[ @id = $pageIdRoot ]/following-sibling::page">
    <xsl:variable name="pageIdNext" select="/page-of-site/pages/page[ @id = $pageIdRoot ]/following-sibling::page[1]/@id"/>
    <xsl:variable name="pageNameNext" select="/page-of-site/pages/page[ @id = $pageIdRoot ]/following-sibling::page[1]/@name"/>
    | <a href="{$pageIdNext}.html"><xsl:value-of select="$pageNameNext"/> &gt;&gt;</a>
  </xsl:if>
</xsl:template>

<!-- ========================[ content elements ]======================== -->

<!-- copy all elements of contents for which not exists match -->
<xsl:template match="@*|node()" mode="content">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()" mode="content"/>
  </xsl:copy>
</xsl:template>

<!-- place here element's handler (match) for content -->
<!-- dont forget to add 'mode="content"' -->

  <!-- link to page <link id="download">go to download</link> -->
<xsl:template match="link" mode="content">
  <a href="{@id}.html"><xsl:value-of select="."/></a>
</xsl:template>

  <!-- tag 'email' -->
<xsl:template match="email" mode="content">
  <a href="mailto:{.}"><xsl:value-of select="."/></a>
</xsl:template>

  <!-- simple tag 'smile' -->
<xsl:template match="smile" mode="content">
  <xsl:text>:)</xsl:text>
</xsl:template>

  <!-- tag 'childPageList' show list child-pages of current page -->
<xsl:template match="childPageList" mode="content">
  <p>
  <xsl:for-each select="/page-of-site/pages//page[ @id = /page-of-site/pageId ]/page">
    <a href="{@id}.html"><xsl:value-of select="@descr"/></a><br/>
  </xsl:for-each>
  </p>
</xsl:template>

<!-- section area -->

  <!-- show list sections of current page-->
<xsl:template match="sectionList" mode="content">
  <p>
  <xsl:for-each select="/page-of-site/page-content/section">
  <!-- indend before section name -->
  <xsl:choose>
    <xsl:when test="@level = 1"/>
    <xsl:when test="@level = 2">&#160;&#160;</xsl:when>
    <xsl:when test="@level = 3">&#160;&#160;&#160;&#160;</xsl:when>
  </xsl:choose>
  <a href="#{@id}"><xsl:value-of select="@name"/></a><br/>
  </xsl:for-each>
  </p>
</xsl:template>

  <!-- show section as h1, h2, h3 (@level = 1,2,3) -->
<xsl:template match="section" mode="content">
  <a name="{@id}"/>
  <xsl:element name="h{@level}"><xsl:value-of select="@name"/></xsl:element>
</xsl:template>

<!-- /section area -->

<!-- tag 'source' -->
<xsl:template match="source" mode="content">
<table border="0" cellpadding="5" cellspacing="0">
<!-- <tr><td>Source:</td></tr> -->
<tr>
<td class="source">
<xsl:if test="@from">from <b><xsl:value-of select="@from"/></b></xsl:if>
<pre><xsl:value-of select="."/></pre></td>
</tr>
</table>
</xsl:template>

<!-- for download area -->
<xsl:template match="file-list" mode="content">
  <table bgcolor="#cccccc" border="0" cellpadding="5" cellspacing="2">
    <xsl:for-each select="file">
      <tr>
        <td bgcolor="#ffffff">
          <a href="./files/{@name}"><xsl:value-of select="@name"/></a>
        </td>
        <td bgcolor="#ffffff">
           <xsl:value-of select="@size div 1024"/> Kb
        </td>
        <td bgcolor="#ffffff">
          <xsl:value-of select="@version"/>,
          <xsl:value-of select="@date"/>
        </td>
        <td bgcolor="#ffffff">
          <xsl:value-of select="@descr"/>
        </td>
      </tr>
    </xsl:for-each>
  </table>
</xsl:template>


<!-- ========================[ /content elements ]======================== -->

</xsl:stylesheet>