added modifier modes (color,link,copy). Not fully functional yet
1 <?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
2 <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">
4 <xsl:template name="getTopicName">
6 <xsl:variable name="searching" select="$topics[@id=$id]" />
7 <xsl:variable name="get"><xsl:value-of select="$searching/baseName/baseNameString" /><xsl:value-of select="$searching/@name" /></xsl:variable>
8 <xsl:if test="string( $get )"><xsl:value-of select="$get" /></xsl:if>
9 <xsl:if test="not(string( $get ))"><span class="notFound"><xsl:value-of select="$id" /> not found.</span></xsl:if>
12 <xsl:template name="getParent">
13 <xsl:param name="currentID"/>
14 <xsl:call-template name="getAllAssocID">
15 <xsl:with-param name="filter" select="'#group-subgroup'" />
16 <xsl:with-param name="role" select="'#parent'" />
17 <xsl:with-param name="currentID" select="$currentID" />
21 <xsl:template name="getChild">
22 <xsl:param name="currentID"/>
23 <xsl:call-template name="getAllAssocID">
24 <xsl:with-param name="filter" select="'#group-subgroup'" />
25 <xsl:with-param name="role" select="'#child'" />
26 <xsl:with-param name="currentID" select="$currentID" />
30 <xsl:template name="getAllAssocID">
31 <xsl:param name="filter"/>
32 <xsl:param name="role"/>
33 <xsl:param name="currentID"/>
35 <xsl:variable name="theseOnes" select="$associations[instanceOf/topicRef/@xlink:href=$filter][member/topicRef/@xlink:href=concat('#',$currentID)]" />
36 <xsl:variable name="fiddle" select="$theseOnes/member/topicRef[not(@xlink:href=concat('#',$currentID))][parent::*/roleSpec/topicRef/@xlink:href=$role]" />
38 <xsl:value-of select="substring-after($fiddle[1]/@xlink:href, '#')" />
42 <xsl:template name="getAllAssoc">
43 <xsl:param name="filter"/>
44 <xsl:param name="role"/>
45 <xsl:param name="style" select="'default'" />
46 <xsl:param name="title"/>
47 <xsl:param name="box"/>
48 <xsl:param name="without"/>
49 <xsl:param name="currentID"/>
50 <xsl:param name="againstID"/>
52 <xsl:variable name="theseOnes" select="$associations[instanceOf/topicRef/@xlink:href=$filter][member/topicRef/@xlink:href=concat('#',$currentID)]" />
54 <xsl:variable name="found"><xsl:choose>
55 <xsl:when test="$style = 'sections'">
56 <table border="0" cellspacing="0" cellpadding="0" class="sections"><tr>
57 <xsl:for-each select="$theseOnes/member/topicRef[@xlink:href!=concat('#',$currentID)][parent::*/roleSpec/topicRef/@xlink:href=$role]">
58 <xsl:variable name="thisOne" select="substring-after(@xlink:href, '#')" />
59 <xsl:variable name="cat" select="concat('#',$currentID)" />
60 <td valign="top" class="{$style}Menu">
61 <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>
62 <div class="{$style}MenuContent"><xsl:call-template name="getClue"><xsl:with-param name="currentID" select="$thisOne" /></xsl:call-template></div>
67 <xsl:when test="$style = 'news'">
68 <xsl:for-each select="$theseOnes/member/topicRef[@xlink:href!=concat('#',$currentID)][parent::*/roleSpec/topicRef/@xlink:href=$role]">
69 <xsl:variable name="thisOne" select="substring-after(@xlink:href, '#')" />
70 <xsl:variable name="cat" select="concat('#',$currentID)" />
71 <div class="{$style}Menu">
72 <a href="{$pre-link}{$thisOne}{$post-link}" class="{$style}MenuLink">
73 <xsl:call-template name="getTopicName"><xsl:with-param name="id" select="$thisOne" /></xsl:call-template> :
74 <xsl:call-template name="getClue"><xsl:with-param name="currentID" select="$thisOne" /><xsl:with-param name="style" select="'news'" /></xsl:call-template>
79 <xsl:when test="$style = 'smallnews'">
80 <xsl:for-each select="$theseOnes/member/topicRef[@xlink:href!=concat('#',$currentID)][parent::*/roleSpec/topicRef/@xlink:href=$role]">
81 <xsl:variable name="thisOne" select="substring-after(@xlink:href, '#')" />
82 <xsl:variable name="cat" select="concat('#',$currentID)" />
83 <div class="{$style}Menu">
84 <a href="{$pre-link}{$thisOne}{$post-link}" class="{$style}MenuLink">
85 <xsl:call-template name="getTopicName"><xsl:with-param name="id" select="$thisOne" /></xsl:call-template> :
86 <xsl:call-template name="getShort"><xsl:with-param name="currentID" select="$thisOne" /></xsl:call-template>
93 <xsl:variable name="allThese" select="$theseOnes/member/topicRef[@xlink:href!=concat('#',$currentID)][parent::*/roleSpec/topicRef/@xlink:href=$role]" />
94 <xsl:for-each select="$allThese">
96 <xsl:variable name="thisOne" select="substring-after(@xlink:href, '#')" />
97 <xsl:variable name="cat" select="concat('#',$currentID)" />
99 <xsl:when test="$style = 'right' or $style = 'left' or $style = 'full' or $style = 'tree'">
101 <xsl:when test="$thisOne = $againstID">
102 <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>
105 <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>
109 <xsl:when test="$style = 'banner'">
111 <xsl:when test="$thisOne = $againstID">
112 <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>
115 <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>
120 <xsl:if test="position() != 1"> / </xsl:if>
121 <a href="{$pre-link}{$thisOne}{$post-link}"><xsl:call-template name="getTopicName"><xsl:with-param name="id" select="$thisOne" /></xsl:call-template> </a>
128 <xsl:if test="string($found)">
130 <xsl:when test="string($box) and $style != 'news' and $style != 'right' and $style != 'left' and $style != 'full' and $style = 'tree' and $style = 'banner'">
131 <table class="{$box}">
133 <xsl:if test="string($title)"><td class="{$box}Title"><xsl:value-of select="$title" /></td></xsl:if>
134 <td class="{$box}Content"><xsl:copy-of select="$found" /></td>
139 <xsl:copy-of select="$found" />
145 <xsl:template name="getAllAssocTwo">
146 <xsl:param name="filter"/>
147 <xsl:param name="role"/>
148 <xsl:param name="type"/>
149 <xsl:param name="style" select="'default'" />
150 <xsl:param name="title"/>
151 <xsl:param name="box"/>
152 <xsl:param name="without"/>
153 <xsl:param name="currentID"/>
154 <xsl:param name="againstID"/>
155 <xsl:variable name="theseOnes" select="$associations[instanceOf/topicRef/@xlink:href=$filter][member/topicRef/@xlink:href=concat('#',$currentID)]" />
156 <xsl:variable name="allThese" select="$theseOnes/member/topicRef[@xlink:href!=concat('#',$currentID)][parent::*/roleSpec/topicRef/@xlink:href=$role]" />
157 <xsl:variable name="w" select="substring-after($type, '#')" />
158 <xsl:variable name="all" select="$topics[starts-with(@id, concat($w, '-'))]" />
159 <xsl:variable name="found">
160 <xsl:for-each select="$all">
161 <xsl:variable name="this" select="@id" />
162 <xsl:variable name="c" select="count( $allThese[substring-after(@xlink:href, '#')=$this])" />
163 <xsl:if test="$c > 0">
164 <xsl:variable name="single" select="$this[1]" />
165 <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>
169 <xsl:if test="string($found)"><xsl:copy-of select="$found" /></xsl:if>
172 <xsl:template name="drawNextLevel">
173 <xsl:param name="currentID"/>
174 <xsl:param name="againstID"/>
175 <xsl:param name="currentType"/>
176 <xsl:param name="currentRole"/>
177 <xsl:param name="style"/>
178 <xsl:call-template name="getAllAssoc">
179 <xsl:with-param name="currentID" select="$currentID" />
180 <xsl:with-param name="againstID" select="$againstID" />
181 <xsl:with-param name="filter" select="'#group-subgroup'" />
182 <xsl:with-param name="role" select="$currentRole" />
183 <xsl:with-param name="box" select="'box'" />
184 <xsl:with-param name="style" select="$style" />
188 <xsl:template name="drawRelated">
189 <xsl:param name="currentID"/>
190 <xsl:param name="currentType"/>
191 <xsl:param name="currentRole"/>
192 <xsl:param name="style" select="'box'" />
193 <xsl:call-template name="getAll">
194 <xsl:with-param name="ThisThat" select="'#this'" />
195 <xsl:with-param name="role" select="$currentRole" />
196 <xsl:with-param name="box" select="$style" />
197 <xsl:with-param name="currentID" select="$currentID" />
199 <xsl:call-template name="getAll">
200 <xsl:with-param name="ThisThat" select="'#that'" />
201 <xsl:with-param name="role" select="$currentRole" />
202 <xsl:with-param name="box" select="$style" />
203 <xsl:with-param name="currentID" select="$currentID" />
207 <xsl:template name="getAll">
208 <xsl:param name="ThisThat"/>
209 <xsl:param name="filter"/>
210 <xsl:param name="title"/>
211 <xsl:param name="role"/>
212 <xsl:param name="box"/>
213 <xsl:param name="without"/>
214 <xsl:param name="currentID"/>
215 <xsl:variable name="allRelations" select="$topics[starts-with(@id, 'relation-')]" />
216 <xsl:variable name="allAssociations" select="$associations[member/topicRef/@xlink:href=concat('#',$currentID)]" />
217 <xsl:for-each select="$allRelations">
218 <xsl:variable name="relID" select="concat('#', @id)" />
219 <xsl:variable name="ThisThatRole"><xsl:choose><xsl:when test="$ThisThat = '#that'">#child</xsl:when><xsl:otherwise>#parent</xsl:otherwise></xsl:choose></xsl:variable>
220 <xsl:variable name="thisName"><xsl:value-of select="baseName[scope/topicRef/@xlink:href=$ThisThat]/baseNameString" /></xsl:variable>
221 <xsl:variable name="found">
222 <xsl:for-each select="$allAssociations">
223 <xsl:variable name="assocInstance" select="instanceOf/topicRef/@xlink:href" />
224 <xsl:variable name="assocHref" select="member[roleSpec/topicRef/@xlink:href=$ThisThatRole]/topicRef/@xlink:href" />
225 <xsl:variable name="thisID" select="substring-after($assocHref, '#')" />
226 <xsl:if test="$relID = $assocInstance and $thisID != $currentID">
227 <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>
231 <xsl:if test="string($found) and string($thisName)">
232 <xsl:call-template name="drawRelationsBox">
233 <xsl:with-param name="style" select="$box" />
234 <xsl:with-param name="title" select="$thisName" />
235 <xsl:with-param name="content" select="$found" />
241 <xsl:template name="getAllBlogs">
242 <xsl:param name="currentID"/>
243 <xsl:param name="notraverse"/>
245 <xsl:variable name="parentID">
246 <xsl:call-template name="getParent">
247 <xsl:with-param name="currentID" select="$currentID" />
251 <xsl:when test="string($notraverse)">
252 <xsl:variable name="theseOnes" select="$topics[instanceOf/topicRef/@xlink:href='#blog']" />
253 <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" />
255 <xsl:for-each select="$theseOnes">
256 <xsl:variable name="ct" select="." />
257 <xsl:for-each select="$assoc">
258 <xsl:variable name="ca" select="." />
259 <xsl:variable name="t" select="substring-after($ca/@xlink:href, '#')" />
260 <xsl:if test="$t = $ct/@id">
261 <xsl:variable name="currentDate" select="$ct/occurrence[instanceOf/topicRef/@xlink:href='#blog-date']/resourceData" />
262 <div class="blogDate"><xsl:value-of select="$currentDate" /></div>
263 <xsl:call-template name="displayBlogItem">
264 <xsl:with-param name="item" select="$ct" />
272 <xsl:variable name="items" select="$topics[instanceOf/topicRef/@xlink:href='#blog']" />
273 <xsl:call-template name="traverseBlog">
274 <xsl:with-param name="items" select="$items[position() < 6]" />
275 <xsl:with-param name="currentNo" select="'1'" />
282 <xsl:template name="traverseBlog">
283 <xsl:param name="items" />
284 <xsl:param name="currentNo" />
285 <xsl:param name="previousDate" />
287 <xsl:variable name="item" select="$items[position() = $currentNo]" />
289 <xsl:variable name="currentDate" select="$item/occurrence[instanceOf/topicRef/@xlink:href='#blog-date']/resourceData" />
291 <xsl:if test="string($currentDate)">
293 <xsl:if test="string($previousDate) = string($currentDate)">
294 <div class="blogEnd"> </div>
297 <xsl:if test="$previousDate != $currentDate">
298 <div class="blogDate"><xsl:value-of select="$currentDate" /></div>
301 <xsl:call-template name="displayBlogItem">
302 <xsl:with-param name="item" select="$item" />
305 <xsl:if test="string($items[position() = $currentNo+1])">
306 <xsl:call-template name="traverseBlog">
307 <xsl:with-param name="items" select="$items" />
308 <xsl:with-param name="currentNo" select="$currentNo + 1" />
309 <xsl:with-param name="previousDate" select="$currentDate" />
317 <xsl:template name="displayBlogItem">
318 <xsl:param name="item" />
320 <xsl:variable name="currentHeader" select="$item/baseName/baseNameString" />
321 <xsl:variable name="currentDate" select="$item/occurrence[instanceOf/topicRef/@xlink:href='#blog-date']/resourceData" />
322 <xsl:variable name="currentLink" select="$item/occurrence[instanceOf/topicRef/@xlink:href='#blog-link']/resourceData" />
323 <xsl:variable name="currentShort" select="$item/occurrence[instanceOf/topicRef/@xlink:href='#blog-short']/resourceData" />
325 <div class="blogItem">
326 <xsl:if test="string($currentHeader)"><div class="blogHeader"><xsl:value-of select="$currentHeader" /></div></xsl:if>
328 <xsl:variable name="fileName">../content/<xsl:value-of select="$item/@id" />.xml</xsl:variable>
329 <xsl:variable name="this" select="document($fileName)/div/*" />
330 <xsl:apply-templates select="$this"><xsl:with-param name="currentID" select="$item/@id" /></xsl:apply-templates>
332 <xsl:if test="string($currentLink)"><div class="blogLinkBox">Read the full story at < <a href="{$currentLink}"><xsl:value-of select="$currentHeader" /></a> ></div></xsl:if>
334 <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']" />
336 <span class="blogLinks"><a href="{$item/@id}.html" class="blogLink">Permalink</a>added <strong><xsl:value-of select="$currentDate" /></strong>.</span>
338 <xsl:if test="count($theseOnes) > 0">
339 <span class="blogLinks">
341 <xsl:for-each select="$theseOnes">
342 <xsl:variable name="chug" select="substring-after(topicRef/@xlink:href, '#')" />
343 <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>