c3d2-web/xsl/common.xsl

112 lines
3.5 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rss="http://purl.org/rss/1.0/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:date="http://exslt.org/dates-and-times"
exclude-result-prefixes="xsl rss rdf">
<xsl:template match="pre">
<xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>
<xsl:template match="p">
<xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>
<xsl:template match="dl">
<xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>
<xsl:template match="dh">
<dt class="main"><xsl:apply-templates/></dt>
</xsl:template>
<xsl:template match="dt">
<xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>
<xsl:template match="dd">
<xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>
<xsl:template match="image">
<xsl:element name="img">
<xsl:attribute name="src"><xsl:value-of select="."/></xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="@title"/></xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="@title"/></xsl:attribute>
<xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute>
</xsl:element>
</xsl:template>
<xsl:template match="link">
<xsl:element name="a">
<xsl:choose>
<xsl:when test="@href">
<xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="em">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template name="navitem">
<xsl:param name="file"/>
<li>
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="$file"/>.html</xsl:attribute>
<xsl:if test="document(concat('../content/', $file, '.xml'))/page/@pagetitle">
<xsl:attribute name="title"><xsl:value-of select="document(concat('../content/', $file, '.xml'))/page/@pagetitle"/></xsl:attribute>
</xsl:if>
<xsl:value-of select="document(concat('../content/', $file, '.xml'))/page/@title"/>
</xsl:element>
</li>
</xsl:template>
<xsl:template name="navitems">
<ul>
<li>
<a href="news.html" title="News">News</a>
</li>
<xsl:for-each select="document('../content/navigation.xml')/navigation/file">
<xsl:call-template name="navitem">
<xsl:with-param name="file" select="."/>
</xsl:call-template>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template name="chaosupdates">
<div id="news">
<h2>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="document('../chaosupdates.rdf')/rdf:RDF/rss:channel/rss:link"/>
</xsl:attribute>
<xsl:value-of select="document('../chaosupdates.rdf')/rdf:RDF/rss:channel/rss:title"/>
</xsl:element>
</h2>
<ul>
<xsl:for-each select="document('../chaosupdates.rdf')/rdf:RDF/rss:item[position() &lt; 14]">
<li>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="rss:link"/>
</xsl:attribute>
<xsl:value-of select="rss:title"/>
</xsl:element>
</li>
</xsl:for-each>
</ul>
</div> <!-- id="news" -->
</xsl:template>
</xsl:stylesheet>