home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / news2html-homepage.xslt < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  3.3 KB  |  110 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.   Copyright 2002-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17.  
  18. <xsl:stylesheet version="1.0" 
  19.   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  20.   xmlns:include="http://apache.org/cocoon/include/1.0"
  21.   xmlns:n="http://www.betaversion.org/linotype/news/1.0"
  22.   xmlns:h="http://www.w3.org/1999/xhtml"
  23.   xmlns="http://www.w3.org/1999/xhtml"
  24.   exclude-result-prefixes="#default include n h"
  25. >
  26.  
  27.   <xsl:param name="home"/>
  28.  
  29.   <xsl:template match="/">
  30.    <xsl:apply-templates select="//n:news"/>
  31.   </xsl:template>
  32.   
  33.   <xsl:template match="n:news">
  34.    <xsl:variable name="id" select="../@id"/>
  35.    <div class="news">
  36.     <h1><img src="images/hand.jpg" alt=""/><xsl:value-of select="n:title"/></h1>
  37.     <h2><xsl:value-of select="@creation-date"/></h2>
  38.     <xsl:apply-templates select="h:body"/>
  39.     <div class="info">Posted at <xsl:value-of select="@creation-time"/> | <a class="permalink" href="{$home}/news/{$id}/">Permalink</a></div>
  40.    </div>
  41.    <xsl:if test="not(position() = last())">
  42.     <div class="separator"><img src="images/separator1.jpg"/></div>
  43.    </xsl:if>
  44.   </xsl:template>
  45.  
  46.   <xsl:template name="find-id">
  47.    <xsl:param name="node"/>
  48.    <xsl:choose>
  49.     <xsl:when test="$node/@id">
  50.      <xsl:value-of select="$node/@id"/>
  51.     </xsl:when>
  52.     <xsl:when test="not($node)"/>
  53.     <xsl:otherwise>
  54.      <xsl:call-template name="find-id">
  55.       <xsl:with-param name="node" select="$node/.."/>
  56.      </xsl:call-template>
  57.     </xsl:otherwise>
  58.    </xsl:choose>
  59.   </xsl:template>
  60.  
  61.   <xsl:template match="h:body">
  62.    <div class="body">
  63.     <xsl:apply-templates/>
  64.    </div>
  65.   </xsl:template>
  66.  
  67.   <xsl:template match="@src" priority="1">
  68.    <xsl:variable name="id"><xsl:call-template name="find-id"><xsl:with-param name="node" select=".."/></xsl:call-template></xsl:variable>
  69.    <xsl:choose>
  70.     <xsl:when test="starts-with(.,'http://')">
  71.      <xsl:attribute name="src">
  72.       <xsl:apply-templates/>
  73.      </xsl:attribute>
  74.     </xsl:when>
  75.     <xsl:otherwise>
  76.      <xsl:attribute name="src">news/<xsl:value-of select="$id"/>/<xsl:value-of select="."/></xsl:attribute>
  77.     </xsl:otherwise>
  78.    </xsl:choose>
  79.   </xsl:template>
  80.  
  81.   <xsl:template match="h:p[1]">
  82.    <p>
  83.     <span class="firstletter"><xsl:value-of select="substring(text()[1],1,1)"/></span>
  84.     <xsl:value-of select="substring(text()[1],2)"/>
  85.     <xsl:apply-templates select="text()[position() > 1]|@*|*"/>
  86.    </p>
  87.   </xsl:template>
  88.  
  89.   <xsl:template match="hr">
  90.     <div class="separator"><img src="images/separator2.jpg"/></div>
  91.   </xsl:template>
  92.  
  93.   <xsl:template match="@*">
  94.    <xsl:copy>
  95.     <xsl:apply-templates/>
  96.    </xsl:copy>
  97.   </xsl:template>
  98.  
  99.   <xsl:template match="*">
  100.    <xsl:element name="{name()}">
  101.     <xsl:apply-templates select="@*|node()"/>
  102.    </xsl:element>
  103.   </xsl:template>
  104.     
  105.   <xsl:template match="text()">
  106.    <xsl:copy/>
  107.   </xsl:template>
  108.  
  109. </xsl:stylesheet>
  110.