133 lines
4.0 KiB
XML
133 lines
4.0 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<xsl:stylesheet version="1.0"
|
|
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">
|
|
|
|
<xsl:include href="include/html_entities.xsl" />
|
|
<xsl:include href="include/helpers.xsl" />
|
|
<xsl:include href="include/navigation.xsl" />
|
|
|
|
<xsl:output method="xml"
|
|
version="1.0"
|
|
encoding="utf-8"
|
|
indent="yes"/>
|
|
|
|
<!--
|
|
# Starting point
|
|
# ==============
|
|
#
|
|
# Matches root and calls the
|
|
# main-Template defined within the
|
|
# application-specific template.
|
|
-->
|
|
|
|
<xsl:template match="/page">
|
|
<xsl:call-template name="main" />
|
|
</xsl:template>
|
|
|
|
<!--
|
|
# Interface templates
|
|
# ===================
|
|
#
|
|
# To be used by the application-specific
|
|
# xsl-template.
|
|
-->
|
|
|
|
<xsl:template name="page_title">
|
|
<xsl:value-of select="/page/@title" />
|
|
</xsl:template>
|
|
|
|
<xsl:template name="navigation">
|
|
<xsl:call-template name="navitems">
|
|
<xsl:with-param name="active" select="/page/@nav_id" />
|
|
</xsl:call-template>
|
|
</xsl:template>
|
|
|
|
<xsl:template name="page_body">
|
|
<xsl:apply-templates match="/page/*" />
|
|
</xsl:template>
|
|
|
|
<xsl:template name="head_include">
|
|
<!-- TBD -->
|
|
</xsl:template>
|
|
|
|
<!--
|
|
# Additional templates
|
|
# ====================
|
|
#
|
|
-->
|
|
|
|
<!-- Bilder in News-Einträgen haben Pfad immer relativ zu /images/news/ -->
|
|
<xsl:template match="image">
|
|
<xsl:variable name="path">
|
|
<xsl:call-template name="normalize-path">
|
|
<xsl:with-param name="path">
|
|
<xsl:choose>
|
|
<!-- use it like this: <image thumb="no">http://upload.wikimedia.org/commons/h/ha/picture.img</image> -->
|
|
<xsl:when test="not(@thumb='no') and contains(string(.), '://') and contains(string(.), 'wikimedia.org')">
|
|
<xsl:variable name="filename">
|
|
<xsl:value-of select="string(str:tokenize(string(.),'/')[last()])"/>
|
|
</xsl:variable>
|
|
<xsl:variable name="hash">
|
|
<xsl:value-of select="concat(str:tokenize(string(.),'/')[position()=last()-2],'/',str:tokenize(string(.),'/')[position()=last()-1],'/')"/>
|
|
</xsl:variable>
|
|
<xsl:variable name="validfilename">
|
|
<xsl:choose>
|
|
<xsl:when test="contains($filename, '.svg') and string-length(substring-after($filename, '.svg'))=0">
|
|
<xsl:value-of select="concat($filename, '.png')"/>
|
|
</xsl:when>
|
|
<xsl:when test="contains(., '://')">
|
|
<xsl:value-of select="."/>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:value-of select="$filename"/>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
</xsl:variable>
|
|
<xsl:value-of select="concat(substring-before(string(.),'commons/'),'commons/thumb/',$hash,$filename,'/600px-',$validfilename)"/>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:value-of select="."/>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
</xsl:with-param>
|
|
</xsl:call-template>
|
|
</xsl:variable>
|
|
|
|
<img
|
|
src="{$path}"
|
|
title="{@title}"
|
|
alt="{@title}"
|
|
class="{@class}"/>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="link">
|
|
<a href="{@href}">
|
|
<xsl:if test="@class">
|
|
<xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute>
|
|
</xsl:if>
|
|
|
|
<xsl:apply-templates/>
|
|
</a>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="xhtml:*"
|
|
xmlns:xhtml="http://www.w3.org/1999/xhtml">
|
|
<xsl:copy-of select="."/>
|
|
</xsl:template>
|
|
|
|
<!--
|
|
# Identity transformation for all elements
|
|
# not handled by the templates within this file.
|
|
# Taken from
|
|
# http://stackoverflow.com/questions/10454114/xslt-template-for-any-node-not-already-handled
|
|
-->
|
|
<xsl:template match="@* | node()">
|
|
<xsl:copy>
|
|
<xsl:apply-templates select="@* | node()"/>
|
|
</xsl:copy>
|
|
</xsl:template>
|
|
</xsl:stylesheet>
|