c3d2-web/transformation/news2page/item.xsl

122 lines
3.4 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
xmlns:crypto="http://exslt.org/crypto"
exclude-result-prefixes="xsl date crypto">
<!-- Support für <event/> bzw. Microformats -->
<xsl:include href="date.xsl" />
<xsl:template match="item/event">
<dl>
<xsl:apply-templates/>
</dl>
</xsl:template>
<xsl:template match="item/event/start">
<xsl:variable name="start" select="."/>
<xsl:variable name="end" select="../end"/>
<dt>Datum</dt>
<dd>
<abbr class="dtstart">
<xsl:attribute name="title">
<xsl:call-template name="date-to-hevent">
<xsl:with-param name="date" select="$start"/>
</xsl:call-template>
</xsl:attribute>
<xsl:call-template name="get-datestring">
<xsl:with-param name="date" select="$start"/>
</xsl:call-template>
</abbr>
<xsl:if test="$end">
bis
<abbr class="dtend">
<xsl:attribute name="title">
<xsl:call-template name="date-to-hevent">
<xsl:with-param name="date" select="$end"/>
</xsl:call-template>
</xsl:attribute>
<xsl:choose>
<!-- Ends on same day it starts? -->
<xsl:when test="date:date($start) = date:date($end)">
<xsl:call-template name="get-timestring">
<xsl:with-param name="date" select="$end"/>
</xsl:call-template>
</xsl:when>
<!-- Event spans days -->
<xsl:otherwise>
<xsl:call-template name="get-datestring">
<xsl:with-param name="date" select="$end"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</abbr>
</xsl:if>
</dd>
</xsl:template>
<xsl:template match="item/event/end">
<!-- Output already for item/event/start above -->
</xsl:template>
<xsl:template match="item/event/location">
<dt>Ort</dt>
<dd class="location"><xsl:apply-templates/></dd>
</xsl:template>
<xsl:template match="item/image[1]">
<xsl:variable name="path">
<xsl:call-template name="normalize-path">
<xsl:with-param name="path">
<xsl:value-of select="concat($baseurl, 'images/news/', .)"/>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<img
src="{$path}"
title="{@title}"
alt="{@title}"
class="{@class}"/>
</xsl:template>
<xsl:template match="item/image">
<xsl:param name="itemposition"/>
<img>
<xsl:attribute name="src">
<xsl:call-template name="normalize-path">
<xsl:with-param name="path">
<xsl:choose>
<xsl:when test="contains(., '://')">
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($baseurl, 'images/news/', .)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="@title"/></xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="@title"/></xsl:attribute>
<!-- News-Items haben ihre Bilder abwechselnd rechts und links... -->
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="$itemposition mod 2 = 1">
<xsl:text>left</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>right</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</img>
</xsl:template>
</xsl:stylesheet>