1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/styles/cm.xsl Tue May 06 10:45:26 2008 +0000
1.3 @@ -0,0 +1,295 @@
1.4 +<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
1.5 +<xsl:stylesheet
1.6 + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
1.7 + xmlns:exsl="http://exslt.org/common"
1.8 + extension-element-prefixes="exsl" version="1.0">
1.9 +
1.10 +<xsl:variable name="controlCharacter" select="'¤'" />
1.11 +<xsl:variable name="crlf" select="' '" />
1.12 +<!-- <xsl:variable name="wikistyle" select="false()" /> -->
1.13 +
1.14 +<xsl:variable name="supportMenu" select="'true'" />
1.15 +<xsl:variable name="supportShowme" select="'true'" />
1.16 +<xsl:variable name="supportSource" select="'true'" />
1.17 +<xsl:variable name="supportImage" select="'true'" />
1.18 +
1.19 +<xsl:template name="findNext">
1.20 + <xsl:param name="content" />
1.21 + <xsl:variable name="escaped" select="substring-after( $content, '\{' )" />
1.22 + <xsl:variable name="item-start" select="substring-after( $content, '{' )" />
1.23 + <xsl:variable name="item-end" select="substring-before( $item-start, '}' )" />
1.24 + <xsl:if test="normalize-space($escaped) != normalize-space($item-start)">
1.25 + <xsl:copy-of select="normalize-space($item-end)" />
1.26 + </xsl:if>
1.27 +</xsl:template>
1.28 +
1.29 +<xsl:template name="findNextTag">
1.30 + <xsl:param name="content" />
1.31 + <xsl:variable name="item-start" select="substring-after( $content, '|' )" />
1.32 + <xsl:variable name="item-end" select="substring-before( $item-start, '|' )" />
1.33 + <xsl:variable name="name-start" select="substring-after( $item-start, '(' )" />
1.34 + <xsl:variable name="name-end" select="substring-before( $name-start, ')' )" />
1.35 + <!-- <xsl:copy-of select="normalize-space($item-end)" /> -->
1.36 + <xsl:variable name="w" select="substring-after( $item-end, ') ')" />
1.37 + <xsl:if test="string($w)">
1.38 + <xsl:element name="{$w}">
1.39 + <xsl:value-of select="$name-end" />
1.40 + </xsl:element>
1.41 + </xsl:if>
1.42 +</xsl:template>
1.43 +
1.44 +<xsl:template name="lastCall">
1.45 + <xsl:param name="content" />
1.46 +
1.47 + <xsl:variable name="inTheBeginning" select="substring-before( $content, '|' )" />
1.48 + <xsl:variable name="markup-start" select="substring-after( $content, '|' )" />
1.49 + <xsl:variable name="markup-end" select="substring-before( $markup-start, '|' )" />
1.50 + <xsl:variable name="markup-after" select="substring-after( $markup-start, concat( $markup-end, '|') )" />
1.51 +
1.52 + <xsl:variable name="cmd" select="substring-before( $markup-end, ';' )" />
1.53 +
1.54 + <xsl:copy-of select="$inTheBeginning" />
1.55 +
1.56 + <xsl:choose>
1.57 + <xsl:when test="string($markup-end)">
1.58 + <xsl:choose>
1.59 + <xsl:when test="starts-with( $markup-end, '!' )">
1.60 + <span class="note"><xsl:copy-of select="substring-after( $markup-end, '!')" /></span>
1.61 + </xsl:when>
1.62 + <xsl:when test="starts-with( $markup-end, '/' )">
1.63 + <em><xsl:copy-of select="substring-after( $markup-end, '/')" /></em>
1.64 + </xsl:when>
1.65 + <xsl:when test="starts-with( $markup-end, '*' )">
1.66 + <pre><xsl:copy-of select="substring-after( $markup-end, '*')" /></pre>
1.67 + </xsl:when>
1.68 + <xsl:otherwise>
1.69 + <strong><xsl:copy-of select="$markup-end" /></strong>
1.70 + </xsl:otherwise>
1.71 + </xsl:choose>
1.72 + <xsl:call-template name="lastCall">
1.73 + <xsl:with-param name="content" select="$markup-after" />
1.74 + </xsl:call-template>
1.75 + <!-- [<xsl:copy-of select="$markup-after" />] -->
1.76 + </xsl:when>
1.77 + <xsl:otherwise>
1.78 + <xsl:copy-of select="$content" />
1.79 + </xsl:otherwise>
1.80 + </xsl:choose>
1.81 +
1.82 +</xsl:template>
1.83 +
1.84 +<xsl:template name="replace-tags">
1.85 + <xsl:param name="content" />
1.86 + <xsl:param name="currentID" />
1.87 + <xsl:variable name="topic"><xsl:call-template name="findNext"><xsl:with-param name="content" select="$content" /></xsl:call-template></xsl:variable>
1.88 + <!-- <xsl:variable name="this" select="$thisDoc/item[@id=$topic]" /> -->
1.89 + <!-- <xsl:variable name="name" select="$this/@name" /> -->
1.90 + <xsl:variable name="name"><xsl:call-template name="getTopicName"><xsl:with-param name="id" select="$topic" /></xsl:call-template></xsl:variable>
1.91 +
1.92 + <xsl:variable name="escaped-start" select="substring-after( $content, '\{' )" />
1.93 + <xsl:variable name="item-start" select="substring-before( $content, '{' )" />
1.94 +
1.95 + <xsl:variable name="item-end" select="substring-after( $content, '}' )" />
1.96 + <xsl:variable name="escaped-end" select="substring-after( $content, '\}' )" />
1.97 +
1.98 + <xsl:if test="string(normalize-space($item-start))">
1.99 + <xsl:if test="normalize-space($escaped-start) != normalize-space($item-start)">
1.100 + <xsl:call-template name="lastCall">
1.101 + <xsl:with-param name="content" select="$item-start" />
1.102 + </xsl:call-template>
1.103 + </xsl:if>
1.104 + <xsl:if test="normalize-space($escaped-start) = normalize-space($item-start)">
1.105 + <xsl:call-template name="lastCall">
1.106 + <xsl:with-param name="content" select="$escaped-start" />
1.107 + </xsl:call-template>
1.108 + </xsl:if>
1.109 + </xsl:if>
1.110 +
1.111 + <xsl:variable name="middle">
1.112 + <xsl:if test="string(normalize-space($topic))">
1.113 +
1.114 + <!-- <xsl:value-of select="$topic" />(<xsl:value-of select="substring($topic, 1)" />) -->
1.115 + <xsl:choose>
1.116 + <xsl:when test="substring($topic, 1, 1) = '('">
1.117 +
1.118 + <xsl:variable name="tmp"><xsl:value-of select="substring-before( $topic, ')' )" /></xsl:variable>
1.119 + <xsl:variable name="thisName" select="substring-after( $topic, ') ' )" />
1.120 + <xsl:variable name="name2">
1.121 + <xsl:choose>
1.122 + <xsl:when test="substring($topic, 2, 1) = '%'"><img src="{substring( $tmp, 3 )}" class="image" border="0" alt="" /></xsl:when>
1.123 + <xsl:otherwise><xsl:value-of select="substring( $tmp, 2 )" /></xsl:otherwise>
1.124 + </xsl:choose>
1.125 + </xsl:variable>
1.126 + <xsl:choose>
1.127 + <xsl:when test="starts-with($thisName, 'http')">
1.128 + <xsl:element name="a">
1.129 + <xsl:attribute name="href"><xsl:value-of select="$thisName" /></xsl:attribute>
1.130 + <xsl:if test="substring($topic, 2, 1) != '%'">
1.131 + <xsl:attribute name="class">extLink</xsl:attribute>
1.132 + </xsl:if><xsl:copy-of select="$name2" />
1.133 + </xsl:element>
1.134 + </xsl:when>
1.135 + <xsl:when test="starts-with($thisName, 'mailto')">
1.136 + <xsl:element name="a">
1.137 + <xsl:attribute name="href"><xsl:value-of select="$thisName" /></xsl:attribute>
1.138 + <xsl:if test="substring($topic, 2, 1) != '%'">
1.139 + <xsl:attribute name="class">extLink</xsl:attribute>
1.140 + </xsl:if><xsl:copy-of select="$name2" />
1.141 + </xsl:element>
1.142 + </xsl:when>
1.143 + <xsl:otherwise>
1.144 + <xsl:element name="a">
1.145 + <xsl:attribute name="href"><xsl:value-of select="$thisName" />.html</xsl:attribute>
1.146 + <xsl:if test="not(substring($topic, 2, 1) = '%')">
1.147 + <xsl:attribute name="class">topicLink</xsl:attribute>
1.148 + </xsl:if>
1.149 + <xsl:copy-of select="$name2" />
1.150 + </xsl:element>
1.151 + </xsl:otherwise>
1.152 + </xsl:choose>
1.153 +
1.154 + </xsl:when>
1.155 + <xsl:when test="substring($topic, 1, 1) = '!' and string($supportMenu)">
1.156 + <menu style="{substring-after($topic, '!')}"/>
1.157 + </xsl:when>
1.158 + <xsl:when test="substring($topic, 1, 1) = '#' and string($supportShowme)">
1.159 + <show-me what="{substring-after($topic, '#')}" id="{$currentID}" />
1.160 + </xsl:when>
1.161 + <xsl:when test="substring($topic, 1, 1) = '+' and string($supportSource)">
1.162 + <div class="viewSource"><a href="content/{$currentID}.orig" class="viewSource">view content source file</a></div>
1.163 + </xsl:when>
1.164 + <xsl:when test="substring($topic, 1, 1) = '%' and string($supportImage)">
1.165 + <image href="{substring-after($topic, '%')}" id="{$currentID}" />
1.166 + </xsl:when>
1.167 + <xsl:when test="starts-with($topic, 'http')">
1.168 + <xsl:element name="a">
1.169 + <xsl:attribute name="href"><xsl:value-of select="$topic" /></xsl:attribute>
1.170 + <xsl:attribute name="class">extLink</xsl:attribute><xsl:value-of select="$topic" />
1.171 + </xsl:element>
1.172 + </xsl:when>
1.173 + <xsl:otherwise>
1.174 + <xsl:element name="a">
1.175 + <xsl:attribute name="href"><xsl:value-of select="$topic" />.html</xsl:attribute>
1.176 + <xsl:attribute name="class">topicLink</xsl:attribute><xsl:value-of select="$name" />
1.177 + </xsl:element>
1.178 + </xsl:otherwise>
1.179 + </xsl:choose>
1.180 +
1.181 + </xsl:if>
1.182 + </xsl:variable>
1.183 +
1.184 + <xsl:call-template name="lastCall">
1.185 + <xsl:with-param name="content" select="$middle" />
1.186 + </xsl:call-template>
1.187 +<!-- <xsl:copy-of select="$middle" />
1.188 + -->
1.189 + <xsl:variable name="more">
1.190 + <xsl:call-template name="findNext">
1.191 + <xsl:with-param name="content" select="$item-end" />
1.192 + </xsl:call-template>
1.193 + </xsl:variable>
1.194 +
1.195 + <xsl:choose>
1.196 + <xsl:when test="string(normalize-space($more))">
1.197 + <xsl:call-template name="replace-tags"><xsl:with-param name="content" select="$item-end" /><xsl:with-param name="currentID" select="$currentID" /></xsl:call-template>
1.198 + </xsl:when>
1.199 + <xsl:otherwise>
1.200 + <xsl:if test="string(normalize-space($item-end))">
1.201 + <xsl:call-template name="lastCall">
1.202 + <xsl:with-param name="content" select="$item-end" />
1.203 + </xsl:call-template>
1.204 +<!-- <xsl:copy-of select="$item-end" />
1.205 + --> </xsl:if>
1.206 + </xsl:otherwise>
1.207 + </xsl:choose>
1.208 +
1.209 + <xsl:if test="not(string(normalize-space($item-start))) and not(string(normalize-space($item-end))) and not(string(normalize-space($topic)))">
1.210 + <xsl:call-template name="lastCall">
1.211 + <xsl:with-param name="content" select="$content" />
1.212 + </xsl:call-template>
1.213 +<!-- <xsl:copy-of select="$content" /> -->
1.214 + </xsl:if>
1.215 +
1.216 +</xsl:template>
1.217 +
1.218 +<xsl:template name="markupLine">
1.219 + <xsl:param name="content" />
1.220 + <xsl:param name="currentID" />
1.221 + <xsl:variable name="first" select="substring($content, 1, 1)" />
1.222 + <xsl:variable name="c">
1.223 + <xsl:if test="$wikistyle">
1.224 + <xsl:if test="string($first) = '?'">question</xsl:if>
1.225 + <xsl:if test="string($first) = '='">answer</xsl:if>
1.226 + <xsl:if test="string($first) = '!'">note</xsl:if>
1.227 + <xsl:if test="string($first) = '*'">point</xsl:if>
1.228 + <xsl:if test="string($first) = '.'">indent</xsl:if>
1.229 + <xsl:if test="string($first) = '|'">code</xsl:if>
1.230 + <xsl:if test="string($first) = ':'">blank</xsl:if>
1.231 + <xsl:if test="string($first) = '-'">headerSmall</xsl:if>
1.232 + <xsl:if test="string($first) = '+'">headerLarge</xsl:if>
1.233 + <xsl:if test="string($first) = '#'">meta</xsl:if>
1.234 + </xsl:if>
1.235 + <xsl:if test="not($wikistyle)"></xsl:if>
1.236 + </xsl:variable>
1.237 +
1.238 + <!-- <xsl:message>
1.239 + <xsl:text>c: </xsl:text><xsl:value-of select="$c"/>
1.240 + <xsl:text> wikistyle: </xsl:text><xsl:value-of select="$wikistyle"/>
1.241 + </xsl:message> -->
1.242 +
1.243 + <xsl:variable name="cont">
1.244 + <xsl:if test="string($c) and $wikistyle">
1.245 + <xsl:copy-of select="substring($content, 2)" /></xsl:if>
1.246 + <xsl:if test="not(string($c))">
1.247 + <xsl:copy-of select="$content" /></xsl:if>
1.248 + </xsl:variable>
1.249 +
1.250 + <xsl:variable name="class">
1.251 + <xsl:if test="string($c)">
1.252 + <xsl:copy-of select="$c" /></xsl:if>
1.253 + <xsl:if test="not(string($c))">normal</xsl:if>
1.254 + </xsl:variable>
1.255 +
1.256 + <xsl:choose>
1.257 + <xsl:when test="$c = 'meta'">
1.258 + <xsl:variable name="what" select="$cont" />
1.259 + <xsl:variable name="before" select="substring-before($what, '=')" />
1.260 + <xsl:variable name="after" select="substring-after($what, '=')" />
1.261 + <xsl:if test="string($before)">
1.262 + <xsl:text disable-output-escaping="yes"><![CDATA[<]]></xsl:text><xsl:copy-of select="normalize-space($before)" /><xsl:text disable-output-escaping="yes"><![CDATA[>]]></xsl:text>
1.263 + <xsl:copy-of select="$after" />
1.264 + <xsl:text disable-output-escaping="yes"><![CDATA[</]]></xsl:text><xsl:copy-of select="normalize-space($before)" /><xsl:text disable-output-escaping="yes"><![CDATA[>]]></xsl:text>
1.265 + </xsl:if>
1.266 + </xsl:when>
1.267 + <xsl:when test="$c = 'code'">
1.268 + <p class="{$class}"><xsl:copy-of select="$cont" /></p>
1.269 + </xsl:when>
1.270 + <xsl:when test="not($wikistyle)">
1.271 + <p class="{$class}"><xsl:copy-of select="$cont" /></p>
1.272 + <!-- <xsl:message terminate="yes" /> -->
1.273 + </xsl:when>
1.274 + <xsl:otherwise>
1.275 + <p class="{$class}"><xsl:call-template name="replace-tags"><xsl:with-param name="content" select="$cont" /><xsl:with-param name="currentID" select="$currentID" /></xsl:call-template></p>
1.276 + </xsl:otherwise>
1.277 + </xsl:choose>
1.278 +</xsl:template>
1.279 +
1.280 +<xsl:template name="doLine">
1.281 + <xsl:param name="content" />
1.282 + <xsl:param name="currentID" />
1.283 + <xsl:variable name="line" select="normalize-space(concat( substring-before( $content, $controlCharacter ), $controlCharacter))" />
1.284 + <xsl:variable name="lineClear" select="normalize-space(translate( $line, $controlCharacter, ' ' ))" />
1.285 + <xsl:variable name="next" select="normalize-space(substring-after( $content, $line ))" />
1.286 +<!-- [<xsl:value-of select="$content" />]<br/>
1.287 + [<xsl:value-of select="$line" />]<br/>
1.288 + [<xsl:value-of select="$lineClear" />]<br/>
1.289 + [<xsl:value-of select="$next" />]<br/> -->
1.290 + <xsl:if test="string(normalize-space($lineClear))">
1.291 + <xsl:call-template name="markupLine"><xsl:with-param name="content"><xsl:copy-of select="$lineClear" /></xsl:with-param><xsl:with-param name="currentID" select="$currentID" /></xsl:call-template>
1.292 + </xsl:if>
1.293 + <xsl:if test="string(normalize-space($next))">
1.294 + <xsl:call-template name="doLine"><xsl:with-param name="content"><xsl:copy-of select="$next" /></xsl:with-param><xsl:with-param name="currentID" select="$currentID" /></xsl:call-template>
1.295 + </xsl:if>
1.296 +</xsl:template>
1.297 +
1.298 +</xsl:stylesheet>