c3d2-web/xsl/portal2items.xsl

77 lines
2.5 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" indent="yes"/>
<xsl:template match="/">
<page>
<xsl:apply-templates/>
</page>
</xsl:template>
<xsl:template match="/config">
<portal>
<xsl:apply-templates select="*[@id]"/>
<xsl:for-each select="document('../news.xml')//newsfile">
<xsl:apply-templates select="document(concat('../', .))/item" mode="news">
<xsl:with-param name="link"
select="concat(substring-before(., '.xml'), '.html')"/>
</xsl:apply-templates>
</xsl:for-each>
</portal>
</xsl:template>
<xsl:template match="/config/gallery">
<xsl:apply-templates select="document(concat('../portal/portal-', @id, '.xml'))/atom:feed/atom:entry" mode="gallery"/>
</xsl:template>
<xsl:template match="/config/wiki">
<xsl:apply-templates select="document(concat('../portal/portal-', @id, '.xml'))/atom:feed/atom:entry" mode="wiki"/>
</xsl:template>
<xsl:template match="*">
</xsl:template>
<xsl:template match="atom:entry" mode="gallery">
<item date="{atom:updated}">
<header><xsl:value-of select="atom:title"/></header>
<footer><xsl:value-of select="atom:content[@type='html']" disable-output-escaping="yes"/></footer>
<content-image><xsl:value-of select="atom:link[@rel='enclosure'][1]/@href"/></content-image>
<link><xsl:value-of select="atom:link[@rel='alternate'][1]/@href"/></link>
</item>
</xsl:template>
<xsl:template match="atom:entry" mode="wiki">
<item date="{atom:updated}">
<header>C3D2 Wiki</header>
<footer>by <xsl:value-of select="atom:author/atom:name"/></footer>
<content-text>[[<xsl:value-of select="atom:title"/>]]</content-text>
<link><xsl:value-of select="atom:link[@rel='alternate'][1]/@href"/></link>
</item>
</xsl:template>
<xsl:template match="item" mode="news">
<xsl:param name="link"/>
<item date="{@date}">
<header>News</header>
<footer>by <xsl:value-of select="@author"/></footer>
<content-text><xsl:value-of select="@title"/></content-text>
<xsl:apply-templates select="image[1]" mode="news"/>
<link><xsl:value-of select="$link"/></link>
</item>
</xsl:template>
<xsl:template match="image" mode="news">
<content-image>
<xsl:choose>
<xsl:when test="contains(., '//')"></xsl:when>
<xsl:otherwise>images/news/</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="."/>
</content-image>
</xsl:template>
</xsl:stylesheet>