styles/tm.xsl
changeset 785 5987f9f15bac
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/styles/tm.xsl	Mon Aug 03 10:42:12 2009 +0000
     1.3 @@ -0,0 +1,353 @@
     1.4 +<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
     1.5 +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl" version="1.0">
     1.6 +
     1.7 +<xsl:template name="getTopicName">
     1.8 +	<xsl:param name="id"/>
     1.9 +	<xsl:variable name="searching" select="$topics[@id=$id]" />
    1.10 +	<xsl:variable name="get"><xsl:value-of select="$searching/baseName/baseNameString" /><xsl:value-of select="$searching/@name" /></xsl:variable>
    1.11 +	<xsl:if test="string( $get )"><xsl:value-of select="$get" /></xsl:if>
    1.12 +	<xsl:if test="not(string( $get ))"><span class="notFound"><xsl:value-of select="$id" /> not found.</span></xsl:if>
    1.13 +</xsl:template>
    1.14 +	
    1.15 +<xsl:template name="getParent">
    1.16 +	<xsl:param name="currentID"/>
    1.17 +	<xsl:call-template name="getAllAssocID">
    1.18 +		<xsl:with-param name="filter" select="'#group-subgroup'" />
    1.19 +		<xsl:with-param name="role" select="'#parent'" />
    1.20 +		<xsl:with-param name="currentID" select="$currentID" />
    1.21 +	</xsl:call-template>
    1.22 +</xsl:template>
    1.23 +
    1.24 +<xsl:template name="getChild">
    1.25 +	<xsl:param name="currentID"/>
    1.26 +	<xsl:call-template name="getAllAssocID">
    1.27 +		<xsl:with-param name="filter" select="'#group-subgroup'" />
    1.28 +		<xsl:with-param name="role" select="'#child'" />
    1.29 +		<xsl:with-param name="currentID" select="$currentID" />
    1.30 +	</xsl:call-template>
    1.31 +</xsl:template>
    1.32 +
    1.33 +<xsl:template name="getAllAssocID">
    1.34 +	<xsl:param name="filter"/>
    1.35 +	<xsl:param name="role"/>
    1.36 +	<xsl:param name="currentID"/>
    1.37 +	
    1.38 +	<xsl:variable name="theseOnes" select="$associations[instanceOf/topicRef/@xlink:href=$filter][member/topicRef/@xlink:href=concat('#',$currentID)]" />
    1.39 +	<xsl:variable name="fiddle" select="$theseOnes/member/topicRef[not(@xlink:href=concat('#',$currentID))][parent::*/roleSpec/topicRef/@xlink:href=$role]" />
    1.40 +
    1.41 +	<xsl:value-of select="substring-after($fiddle[1]/@xlink:href, '#')" />
    1.42 +	
    1.43 +</xsl:template>
    1.44 +
    1.45 +<xsl:template name="getAllAssoc">
    1.46 +	<xsl:param name="filter"/>
    1.47 +	<xsl:param name="role"/>
    1.48 +	<xsl:param name="style" select="'default'" />
    1.49 +	<xsl:param name="title"/>
    1.50 +	<xsl:param name="box"/>
    1.51 +	<xsl:param name="without"/>
    1.52 +	<xsl:param name="currentID"/>
    1.53 +	<xsl:param name="againstID"/>
    1.54 +	
    1.55 +	<xsl:variable name="theseOnes" select="$associations[instanceOf/topicRef/@xlink:href=$filter][member/topicRef/@xlink:href=concat('#',$currentID)]" />
    1.56 +
    1.57 + 	<xsl:variable name="found"><xsl:choose> 
    1.58 +			<xsl:when test="$style = 'sections'">
    1.59 +				<table border="0" cellspacing="0" cellpadding="0" class="sections"><tr>
    1.60 +				<xsl:for-each select="$theseOnes/member/topicRef[@xlink:href!=concat('#',$currentID)][parent::*/roleSpec/topicRef/@xlink:href=$role]"> 
    1.61 +					<xsl:variable name="thisOne" select="substring-after(@xlink:href, '#')" />
    1.62 +					<xsl:variable name="cat" select="concat('#',$currentID)" />
    1.63 +					<td valign="top" class="{$style}Menu">
    1.64 +						<a href="{$pre-link}{$thisOne}{$post-link}" class="{$style}MenuLink"><xsl:call-template name="getTopicName"><xsl:with-param name="id" select="$thisOne" /></xsl:call-template></a>
    1.65 +						<div class="{$style}MenuContent"><xsl:call-template name="getClue"><xsl:with-param name="currentID" select="$thisOne" /></xsl:call-template></div>
    1.66 +					</td>
    1.67 +		 		</xsl:for-each>
    1.68 +				</tr></table>
    1.69 +			</xsl:when>
    1.70 +			<xsl:when test="$style = 'news'">
    1.71 +				<xsl:for-each select="$theseOnes/member/topicRef[@xlink:href!=concat('#',$currentID)][parent::*/roleSpec/topicRef/@xlink:href=$role]"> 
    1.72 +					<xsl:variable name="thisOne" select="substring-after(@xlink:href, '#')" />
    1.73 +					<xsl:variable name="cat" select="concat('#',$currentID)" />
    1.74 +					<div class="{$style}Menu">
    1.75 +						<a href="{$pre-link}{$thisOne}{$post-link}" class="{$style}MenuLink">
    1.76 +							<xsl:call-template name="getTopicName"><xsl:with-param name="id" select="$thisOne" /></xsl:call-template> : 
    1.77 +							<xsl:call-template name="getClue"><xsl:with-param name="currentID" select="$thisOne" /><xsl:with-param name="style" select="'news'" /></xsl:call-template>
    1.78 +						</a>
    1.79 +					</div>
    1.80 +		 		</xsl:for-each>
    1.81 +			</xsl:when>
    1.82 +			<xsl:when test="$style = 'smallnews'">
    1.83 +				<xsl:for-each select="$theseOnes/member/topicRef[@xlink:href!=concat('#',$currentID)][parent::*/roleSpec/topicRef/@xlink:href=$role]"> 
    1.84 +					<xsl:variable name="thisOne" select="substring-after(@xlink:href, '#')" />
    1.85 +					<xsl:variable name="cat" select="concat('#',$currentID)" />
    1.86 +					<div class="{$style}Menu">
    1.87 +						<a href="{$pre-link}{$thisOne}{$post-link}" class="{$style}MenuLink">
    1.88 +							<xsl:call-template name="getTopicName"><xsl:with-param name="id" select="$thisOne" /></xsl:call-template> : 
    1.89 +							 <xsl:call-template name="getShort"><xsl:with-param name="currentID" select="$thisOne" /></xsl:call-template>
    1.90 +						</a>
    1.91 +					</div>
    1.92 +		 		</xsl:for-each>
    1.93 +			</xsl:when>
    1.94 +			<xsl:otherwise>
    1.95 +			
    1.96 +				<xsl:variable name="allThese" select="$theseOnes/member/topicRef[@xlink:href!=concat('#',$currentID)][parent::*/roleSpec/topicRef/@xlink:href=$role]" />
    1.97 +				<xsl:for-each select="$allThese"> 
    1.98 +				
    1.99 +				<xsl:variable name="thisOne" select="substring-after(@xlink:href, '#')" />
   1.100 +					<xsl:variable name="cat" select="concat('#',$currentID)" />
   1.101 +						<xsl:choose> 
   1.102 +							<xsl:when test="$style = 'right' or $style = 'left' or $style = 'full' or $style = 'tree'">
   1.103 +								<xsl:choose>
   1.104 +									<xsl:when test="$thisOne = $againstID">
   1.105 +										<div class="{$style}MenuSelected"><a href="{$pre-link}{$thisOne}{$post-link}"><xsl:call-template name="getTopicName"><xsl:with-param name="id" select="$thisOne" /></xsl:call-template></a> </div>
   1.106 +									</xsl:when>
   1.107 +									<xsl:otherwise>
   1.108 +										<div class="{$style}Menu"><a href="{$pre-link}{$thisOne}{$post-link}"><xsl:call-template name="getTopicName"><xsl:with-param name="id" select="$thisOne" /></xsl:call-template></a> </div>
   1.109 +									</xsl:otherwise>
   1.110 +								</xsl:choose>
   1.111 +							</xsl:when>
   1.112 +							<xsl:when test="$style = 'banner'">
   1.113 +								<xsl:choose>
   1.114 +									<xsl:when test="$thisOne = $againstID">
   1.115 +										<td class="{$style}MenuSelected"><a href="{$pre-link}{$thisOne}{$post-link}"><xsl:call-template name="getTopicName"><xsl:with-param name="id" select="$thisOne" /></xsl:call-template></a> </td>
   1.116 +									</xsl:when>
   1.117 +									<xsl:otherwise>
   1.118 +										<td class="{$style}Menu"><a href="{$pre-link}{$thisOne}{$post-link}"><xsl:call-template name="getTopicName"><xsl:with-param name="id" select="$thisOne" /></xsl:call-template></a> </td>
   1.119 +									</xsl:otherwise>
   1.120 +								</xsl:choose>
   1.121 +							</xsl:when>
   1.122 +							<xsl:otherwise>
   1.123 +								<xsl:if test="position() != 1"> / </xsl:if>
   1.124 +								<a href="{$pre-link}{$thisOne}{$post-link}"><xsl:call-template name="getTopicName"><xsl:with-param name="id" select="$thisOne" /></xsl:call-template> </a>
   1.125 +							</xsl:otherwise>
   1.126 +						</xsl:choose>
   1.127 +		 		</xsl:for-each>
   1.128 +			</xsl:otherwise>
   1.129 +		</xsl:choose>
   1.130 +	</xsl:variable>
   1.131 +	<xsl:if test="string($found)">
   1.132 +		<xsl:choose>
   1.133 +			<xsl:when test="string($box) and $style != 'news' and $style != 'right' and $style != 'left' and $style != 'full' and $style = 'tree' and $style = 'banner'">
   1.134 +				<table class="{$box}">
   1.135 +				<tr>
   1.136 +					<xsl:if test="string($title)"><td class="{$box}Title"><xsl:value-of select="$title" /></td></xsl:if>
   1.137 +					<td class="{$box}Content"><xsl:copy-of select="$found" /></td>
   1.138 +				</tr>
   1.139 +				</table>
   1.140 +			</xsl:when>
   1.141 +			<xsl:otherwise>
   1.142 +				<xsl:copy-of select="$found" />
   1.143 +			</xsl:otherwise>
   1.144 +		</xsl:choose>
   1.145 +	</xsl:if>
   1.146 +</xsl:template>
   1.147 +
   1.148 +<xsl:template name="getAllAssocTwo">
   1.149 +	<xsl:param name="filter"/>
   1.150 +	<xsl:param name="role"/>
   1.151 +	<xsl:param name="type"/>
   1.152 +	<xsl:param name="style" select="'default'" />
   1.153 +	<xsl:param name="title"/>
   1.154 +	<xsl:param name="box"/>
   1.155 +	<xsl:param name="without"/>
   1.156 +	<xsl:param name="currentID"/>
   1.157 +	<xsl:param name="againstID"/>
   1.158 +	<xsl:variable name="theseOnes" select="$associations[instanceOf/topicRef/@xlink:href=$filter][member/topicRef/@xlink:href=concat('#',$currentID)]" />
   1.159 +	<xsl:variable name="allThese" select="$theseOnes/member/topicRef[@xlink:href!=concat('#',$currentID)][parent::*/roleSpec/topicRef/@xlink:href=$role]" />
   1.160 +	<xsl:variable name="w" select="substring-after($type, '#')" />
   1.161 +	<xsl:variable name="all" select="$topics[starts-with(@id, concat($w, '-'))]" />
   1.162 +	<xsl:variable name="found">
   1.163 +		<xsl:for-each select="$all"> 
   1.164 +			<xsl:variable name="this" select="@id" />
   1.165 +			<xsl:variable name="c" select="count( $allThese[substring-after(@xlink:href, '#')=$this])" />
   1.166 +			<xsl:if test="$c &gt; 0">
   1.167 +				<xsl:variable name="single" select="$this[1]" />
   1.168 +				<a href="{$pre-link}{$single}{$post-link}" class="foundLink"><xsl:call-template name="getTopicName"><xsl:with-param name="id" select="$single" /></xsl:call-template></a>
   1.169 +			</xsl:if>
   1.170 +		</xsl:for-each>
   1.171 +	</xsl:variable>
   1.172 +	<xsl:if test="string($found)"><xsl:copy-of select="$found" /></xsl:if>
   1.173 +</xsl:template>
   1.174 +
   1.175 +<xsl:template name="drawNextLevel">	
   1.176 +	<xsl:param name="currentID"/>
   1.177 +	<xsl:param name="againstID"/>
   1.178 +	<xsl:param name="currentType"/>
   1.179 +	<xsl:param name="currentRole"/>
   1.180 +	<xsl:param name="style"/>
   1.181 +	<xsl:call-template name="getAllAssoc">
   1.182 +		<xsl:with-param name="currentID" select="$currentID" />
   1.183 +		<xsl:with-param name="againstID" select="$againstID" />
   1.184 +		<xsl:with-param name="filter" select="'#group-subgroup'" />
   1.185 +		<xsl:with-param name="role" select="$currentRole" />
   1.186 +		<xsl:with-param name="box" select="'box'" />
   1.187 +		<xsl:with-param name="style" select="$style" />
   1.188 +	</xsl:call-template>
   1.189 +</xsl:template>
   1.190 +
   1.191 +<xsl:template name="drawRelated">
   1.192 +	<xsl:param name="currentID"/>
   1.193 +	<xsl:param name="currentType"/>
   1.194 +	<xsl:param name="currentRole"/>
   1.195 +	<xsl:param name="style" select="'box'" />
   1.196 +	<xsl:call-template name="getAll">
   1.197 +		<xsl:with-param name="ThisThat" select="'#this'" />
   1.198 +		<xsl:with-param name="role" select="$currentRole" />
   1.199 +		<xsl:with-param name="box" select="$style" />
   1.200 +		<xsl:with-param name="currentID" select="$currentID" />
   1.201 +	</xsl:call-template>
   1.202 +	<xsl:call-template name="getAll">
   1.203 +		<xsl:with-param name="ThisThat" select="'#that'" />
   1.204 +		<xsl:with-param name="role" select="$currentRole" />
   1.205 +		<xsl:with-param name="box" select="$style" />
   1.206 +		<xsl:with-param name="currentID" select="$currentID" />
   1.207 +	</xsl:call-template>
   1.208 +</xsl:template> 	
   1.209 +
   1.210 +<xsl:template name="getAll">
   1.211 +	<xsl:param name="ThisThat"/>
   1.212 +	<xsl:param name="filter"/>
   1.213 +	<xsl:param name="title"/>
   1.214 +	<xsl:param name="role"/>
   1.215 +	<xsl:param name="box"/>
   1.216 +	<xsl:param name="without"/>
   1.217 +	<xsl:param name="currentID"/>
   1.218 +	<xsl:variable name="allRelations" select="$topics[starts-with(@id, 'relation-')]" />
   1.219 +	<xsl:variable name="allAssociations" select="$associations[member/topicRef/@xlink:href=concat('#',$currentID)]" />
   1.220 +	<xsl:for-each select="$allRelations">
   1.221 +		<xsl:variable name="relID" select="concat('#', @id)" />
   1.222 +		<xsl:variable name="ThisThatRole"><xsl:choose><xsl:when test="$ThisThat = '#that'">#child</xsl:when><xsl:otherwise>#parent</xsl:otherwise></xsl:choose></xsl:variable>
   1.223 +		<xsl:variable name="thisName"><xsl:value-of select="baseName[scope/topicRef/@xlink:href=$ThisThat]/baseNameString" /></xsl:variable>
   1.224 +		<xsl:variable name="found">
   1.225 +			<xsl:for-each select="$allAssociations">
   1.226 +				<xsl:variable name="assocInstance" select="instanceOf/topicRef/@xlink:href" />
   1.227 +				<xsl:variable name="assocHref" select="member[roleSpec/topicRef/@xlink:href=$ThisThatRole]/topicRef/@xlink:href" />
   1.228 +				<xsl:variable name="thisID" select="substring-after($assocHref, '#')" />
   1.229 +				<xsl:if test="$relID = $assocInstance and $thisID != $currentID">			
   1.230 +					<span class="{$box}Element"><a href="{$pre-link}{$thisID}{$post-link}"><xsl:call-template name="getTopicName"><xsl:with-param name="id" select="$thisID" /></xsl:call-template></a></span>
   1.231 +				</xsl:if>
   1.232 +			</xsl:for-each>
   1.233 +		</xsl:variable>
   1.234 +		<xsl:if test="string($found) and string($thisName)">
   1.235 +			<xsl:call-template name="drawRelationsBox">
   1.236 +				<xsl:with-param name="style" select="$box" />
   1.237 +				<xsl:with-param name="title" select="$thisName" />
   1.238 +				<xsl:with-param name="content" select="$found" />
   1.239 +			</xsl:call-template>
   1.240 +		</xsl:if>
   1.241 +	</xsl:for-each>	
   1.242 +</xsl:template>
   1.243 +
   1.244 +<xsl:template name="getAllBlogs">
   1.245 +	<xsl:param name="currentID"/>
   1.246 +	<xsl:param name="notraverse"/>
   1.247 +	
   1.248 +	<xsl:variable name="parentID">
   1.249 +		<xsl:call-template name="getParent">
   1.250 +			<xsl:with-param name="currentID" select="$currentID" />
   1.251 +		</xsl:call-template>
   1.252 +	</xsl:variable>
   1.253 +	<xsl:choose>
   1.254 +		<xsl:when test="string($notraverse)">
   1.255 +			<xsl:variable name="theseOnes" select="$topics[instanceOf/topicRef/@xlink:href='#blog']" />
   1.256 +			<xsl:variable name="assoc" select="$associations[instanceOf/topicRef/@xlink:href='#group-subgroup'][member/topicRef/@xlink:href=concat('#',$currentID)]/member[roleSpec/topicRef/@xlink:href='#child']/topicRef" />
   1.257 +			<div class="doc">
   1.258 +				<xsl:for-each select="$theseOnes">
   1.259 +					<xsl:variable name="ct" select="." />
   1.260 +					<xsl:for-each select="$assoc">
   1.261 +						<xsl:variable name="ca" select="." />
   1.262 +						<xsl:variable name="t" select="substring-after($ca/@xlink:href, '#')" />
   1.263 +						<xsl:if test="$t = $ct/@id">
   1.264 +							<xsl:variable name="currentDate" select="$ct/occurrence[instanceOf/topicRef/@xlink:href='#blog-date']/resourceData" />
   1.265 +							<div class="blogDate"><xsl:value-of select="$currentDate" /></div>
   1.266 +							<xsl:call-template name="displayBlogItem">
   1.267 +								<xsl:with-param name="item" select="$ct" />
   1.268 +							</xsl:call-template>
   1.269 +						</xsl:if>
   1.270 +					</xsl:for-each>
   1.271 +				</xsl:for-each>
   1.272 +			</div>
   1.273 +		</xsl:when>
   1.274 +		<xsl:otherwise>
   1.275 +			<xsl:variable name="items" select="$topics[instanceOf/topicRef/@xlink:href='#blog']" />
   1.276 +			<xsl:call-template name="traverseBlog">
   1.277 +				<xsl:with-param name="items" select="$items[position() &lt; 6]" />
   1.278 +				<xsl:with-param name="currentNo" select="'1'" />
   1.279 +			</xsl:call-template>
   1.280 +		</xsl:otherwise>
   1.281 +	</xsl:choose>
   1.282 +
   1.283 +</xsl:template>
   1.284 +
   1.285 +<xsl:template name="traverseBlog">
   1.286 +	<xsl:param name="items" />
   1.287 +	<xsl:param name="currentNo" />
   1.288 +	<xsl:param name="previousDate" />
   1.289 +	
   1.290 +	<xsl:variable name="item" select="$items[position() = $currentNo]" />
   1.291 +
   1.292 +	<xsl:variable name="currentDate" select="$item/occurrence[instanceOf/topicRef/@xlink:href='#blog-date']/resourceData" />
   1.293 +
   1.294 +	<xsl:if test="string($currentDate)">
   1.295 +	
   1.296 +		<xsl:if test="string($previousDate) = string($currentDate)">
   1.297 +			<div class="blogEnd"> </div>
   1.298 +		</xsl:if>
   1.299 +		
   1.300 +		<xsl:if test="$previousDate != $currentDate">
   1.301 +			<div class="blogDate"><xsl:value-of select="$currentDate" /></div>
   1.302 +		</xsl:if>
   1.303 +		
   1.304 +		<xsl:call-template name="displayBlogItem">
   1.305 +			<xsl:with-param name="item" select="$item" />
   1.306 +		</xsl:call-template>
   1.307 +		
   1.308 +		<xsl:if test="string($items[position() = $currentNo+1])">
   1.309 +			<xsl:call-template name="traverseBlog">
   1.310 +				<xsl:with-param name="items" select="$items" />
   1.311 +				<xsl:with-param name="currentNo" select="$currentNo + 1" />
   1.312 +				<xsl:with-param name="previousDate" select="$currentDate" />
   1.313 +			</xsl:call-template>
   1.314 +		</xsl:if>
   1.315 +	
   1.316 +	</xsl:if>
   1.317 +	
   1.318 +</xsl:template>
   1.319 +
   1.320 +<xsl:template name="displayBlogItem">
   1.321 +	<xsl:param name="item" />
   1.322 +	
   1.323 +	<xsl:variable name="currentHeader" select="$item/baseName/baseNameString" />
   1.324 +	<xsl:variable name="currentDate" select="$item/occurrence[instanceOf/topicRef/@xlink:href='#blog-date']/resourceData" />
   1.325 +	<xsl:variable name="currentLink" select="$item/occurrence[instanceOf/topicRef/@xlink:href='#blog-link']/resourceData" />
   1.326 +	<xsl:variable name="currentShort" select="$item/occurrence[instanceOf/topicRef/@xlink:href='#blog-short']/resourceData" />
   1.327 +	
   1.328 +	<div class="blogItem">
   1.329 +		<xsl:if test="string($currentHeader)"><div class="blogHeader"><xsl:value-of select="$currentHeader" /></div></xsl:if>
   1.330 +		
   1.331 +		<xsl:variable name="fileName">../content/<xsl:value-of select="$item/@id" />.xml</xsl:variable>
   1.332 +		<xsl:variable name="this" select="document($fileName)/div/*" />
   1.333 +		<xsl:apply-templates select="$this"><xsl:with-param name="currentID" select="$item/@id" /></xsl:apply-templates>
   1.334 +		
   1.335 +		<xsl:if test="string($currentLink)"><div class="blogLinkBox">Read the full story at &lt; <a href="{$currentLink}"><xsl:value-of select="$currentHeader" /></a> &gt;</div></xsl:if>
   1.336 +
   1.337 +		<xsl:variable name="theseOnes" select="$associations[instanceOf/topicRef/@xlink:href='#group-subgroup'][member/topicRef/@xlink:href=concat('#',$item/@id)]/member[roleSpec/topicRef/@xlink:href='#parent']" />
   1.338 +
   1.339 +		<span class="blogLinks"><a href="{$item/@id}.html" class="blogLink">Permalink</a>added <strong><xsl:value-of select="$currentDate" /></strong>.</span> 
   1.340 +		
   1.341 +		<xsl:if test="count($theseOnes) &gt; 0">
   1.342 +			<span class="blogLinks">
   1.343 +				Catalogued under:
   1.344 +				<xsl:for-each select="$theseOnes">
   1.345 +					<xsl:variable name="chug" select="substring-after(topicRef/@xlink:href, '#')" />
   1.346 +					<a href="{$pre-link}{$chug}{$post-link}" class="blogLink"><xsl:call-template name="getTopicName"><xsl:with-param name="id" select="$chug" /></xsl:call-template> </a>
   1.347 +				</xsl:for-each>
   1.348 +	 		</span>
   1.349 +		</xsl:if>
   1.350 +		
   1.351 +	</div>
   1.352 +	
   1.353 +</xsl:template>
   1.354 +
   1.355 +
   1.356 +</xsl:stylesheet>