1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
2 | <xsl:stylesheet version="1.0"
|
---|
3 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
4 | xmlns:java="http://xml.apache.org/xslt/java"
|
---|
5 | xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
|
---|
6 | extension-element-prefixes="java util"
|
---|
7 | exclude-result-prefixes="java util">
|
---|
8 |
|
---|
9 | <!-- some global parameters - these are set by whoever is invoking the transformation -->
|
---|
10 | <xsl:param name="interface_name"/>
|
---|
11 |
|
---|
12 | <!-- Display the appropriate image, depending on the node type -->
|
---|
13 | <xsl:template match="documentNode" mode="displayNodeIcon">
|
---|
14 |
|
---|
15 | <!-- Root node: book icon (open or closed) -->
|
---|
16 | <xsl:choose>
|
---|
17 | <xsl:when test="@nodeType='root'">
|
---|
18 | <xsl:choose>
|
---|
19 | <xsl:when test="documentNode">
|
---|
20 | <xsl:call-template name="openbookimg">
|
---|
21 | <xsl:with-param name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'close_book')"/></xsl:with-param>
|
---|
22 | </xsl:call-template>
|
---|
23 | </xsl:when>
|
---|
24 | <xsl:otherwise>
|
---|
25 | <xsl:call-template name="closedbookimg">
|
---|
26 | <xsl:with-param name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'open_book')"/></xsl:with-param>
|
---|
27 | </xsl:call-template>
|
---|
28 | </xsl:otherwise>
|
---|
29 | </xsl:choose>
|
---|
30 | </xsl:when>
|
---|
31 |
|
---|
32 | <!-- Internal node: folder icon (open or closed) -->
|
---|
33 | <xsl:when test="@nodeType='internal'">
|
---|
34 | <xsl:choose>
|
---|
35 | <xsl:when test="documentNode">
|
---|
36 | <xsl:call-template name="openfolderimg">
|
---|
37 | <xsl:with-param name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'close_folder')"/></xsl:with-param>
|
---|
38 | </xsl:call-template>
|
---|
39 | </xsl:when>
|
---|
40 | <xsl:otherwise>
|
---|
41 | <xsl:call-template name="closedfolderimg">
|
---|
42 | <xsl:with-param name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'open_folder')"/></xsl:with-param>
|
---|
43 | </xsl:call-template>
|
---|
44 | </xsl:otherwise>
|
---|
45 | </xsl:choose>
|
---|
46 | </xsl:when>
|
---|
47 |
|
---|
48 | <!-- Leaf node: page icon, and this is the default -->
|
---|
49 | <xsl:otherwise>
|
---|
50 | <xsl:call-template name="textpageimg">
|
---|
51 | <xsl:with-param name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'view_document')"/></xsl:with-param>
|
---|
52 | </xsl:call-template>
|
---|
53 | </xsl:otherwise>
|
---|
54 | </xsl:choose>
|
---|
55 | </xsl:template>
|
---|
56 |
|
---|
57 | <xsl:template name="openbookimg">
|
---|
58 | <xsl:param name="alt"/>
|
---|
59 | <xsl:param name="title"/>
|
---|
60 | <img border="0" width="28" height="23"
|
---|
61 | src="interfaces/basic/images/openbook.gif"
|
---|
62 | alt="{$alt}" title="{$title}"/>
|
---|
63 | </xsl:template>
|
---|
64 |
|
---|
65 | <xsl:template name="closedbookimg">
|
---|
66 | <xsl:param name="alt"/>
|
---|
67 | <xsl:param name="title"/>
|
---|
68 | <img border="0" width="18" height="11"
|
---|
69 | src="interfaces/basic/images/book.gif"
|
---|
70 | alt="{$alt}" title="{$title}"/>
|
---|
71 | </xsl:template>
|
---|
72 |
|
---|
73 | <xsl:template name="openfolderimg">
|
---|
74 | <xsl:param name="alt"/>
|
---|
75 | <xsl:param name="title"/>
|
---|
76 | <img border="0" width="23" height="15"
|
---|
77 | src="interfaces/basic/images/openfldr.gif"
|
---|
78 | alt="{$alt}" title="{$title}"/>
|
---|
79 | </xsl:template>
|
---|
80 |
|
---|
81 | <xsl:template name="closedfolderimg">
|
---|
82 | <xsl:param name="alt"/>
|
---|
83 | <xsl:param name="title"/>
|
---|
84 | <img border="0" width="23" height="15"
|
---|
85 | src="interfaces/basic/images/clsdfldr.gif"
|
---|
86 | alt="{$alt}" title="{$title}"/>
|
---|
87 | </xsl:template>
|
---|
88 |
|
---|
89 | <xsl:template name="textpageimg">
|
---|
90 | <xsl:param name="alt"/>
|
---|
91 | <xsl:param name="title"/>
|
---|
92 | <img border="0" width="16" height="21"
|
---|
93 | src="interfaces/basic/images/itext.gif"
|
---|
94 | alt="{$alt}" title="{$title}"/>
|
---|
95 | </xsl:template>
|
---|
96 |
|
---|
97 | <xsl:template name="bookshelfimg">
|
---|
98 | <xsl:param name="alt"/>
|
---|
99 | <xsl:param name="title"/>
|
---|
100 | <img border="0" width="20" height="16"
|
---|
101 | src="interfaces/basic/images/bshelf.gif"
|
---|
102 | alt="{$alt}" title="{$title}"/>
|
---|
103 | </xsl:template>
|
---|
104 |
|
---|
105 | <xsl:template name="iconpdf">
|
---|
106 | <xsl:param name="alt">PDF</xsl:param>
|
---|
107 | <xsl:param name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'texticonpdf')"/></xsl:param>
|
---|
108 | <img border="0" width='26' height='26'
|
---|
109 | src='interfaces/basic/images/ipdf.gif'
|
---|
110 | alt='{$alt}' title='{$title}'/>
|
---|
111 | </xsl:template>
|
---|
112 |
|
---|
113 | <xsl:template name="icondoc">
|
---|
114 | <xsl:param name="alt">Word</xsl:param>
|
---|
115 | <xsl:param name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'texticonmsword')"/></xsl:param>
|
---|
116 | <img border="0" width='26' height='26'
|
---|
117 | src='interfaces/basic/images/imsword.gif'
|
---|
118 | alt='{$alt}' title='{$title}'/>
|
---|
119 | </xsl:template>
|
---|
120 |
|
---|
121 | <!-- builds up links to available document types equivalent to the default source
|
---|
122 | document with as anchor the equivalent documents' doctype icons. -->
|
---|
123 | <xsl:template name="equivDocLinks">
|
---|
124 | <xsl:param name="count"/>
|
---|
125 |
|
---|
126 | <xsl:variable name="docicon" select="metadataList/metadata[contains(@name, 'equivDocIcon')]"/>
|
---|
127 | <xsl:variable name="docEndlink" select="metadataList/metadata[contains(@name, '/equivDocLink')]"/>
|
---|
128 |
|
---|
129 | <!--<xsl:variable name="docStartlink" select="metadataList/metadata[contains(@name, 'all_*,*_equivDocLink')]"/>-->
|
---|
130 | <!-- In the following variable statement, we're trying to set the docStartlink to any metadata whose value
|
---|
131 | ends on equivDocLink but NOT /equivDocLink. Unfortunately, the xslt function fn:ends-with only exists from
|
---|
132 | xslt 2.0 onwards. So need to use substring() and string-lenth() functions now to check whether the 13th char
|
---|
133 | from the end is a slash or not, in order to distinguish between the start of a doclink and end of one.
|
---|
134 | If this 13th char from the end is not a slash, then we found (the string we want to store in) docStartlink. -->
|
---|
135 | <xsl:variable name="docStartlink">
|
---|
136 | <xsl:for-each select="metadataList/metadata">
|
---|
137 | <xsl:if test="contains(@name, 'equivDocLink')">
|
---|
138 | <xsl:variable name="tmpvar" select="substring(@name, string-length(@name)-12, 1)"/>
|
---|
139 | <xsl:if test="not($tmpvar='/')">
|
---|
140 | <xsl:value-of select="self::node()[@name]"/>
|
---|
141 | </xsl:if>
|
---|
142 | </xsl:if>
|
---|
143 | </xsl:for-each>
|
---|
144 | </xsl:variable>
|
---|
145 |
|
---|
146 | <xsl:variable name="equivDocIcon" select="java:org.greenstone.gsdl3.util.XSLTUtil.getNumberedItem($docicon, $count)" />
|
---|
147 | <xsl:variable name="equivStartlink" select="java:org.greenstone.gsdl3.util.XSLTUtil.getNumberedItem($docStartlink, $count)" />
|
---|
148 | <xsl:variable name="equivEndlink" select="java:org.greenstone.gsdl3.util.XSLTUtil.getNumberedItem($docEndlink, $count)" />
|
---|
149 |
|
---|
150 | <xsl:if test="$equivDocIcon != ''">
|
---|
151 | <xsl:value-of disable-output-escaping="yes" select="$equivStartlink"/>
|
---|
152 | <xsl:value-of disable-output-escaping="yes" select="$equivDocIcon"/>
|
---|
153 | <xsl:value-of disable-output-escaping="yes" select="$equivEndlink"/>
|
---|
154 |
|
---|
155 | <!-- recursively call this template to get multiple entries -->
|
---|
156 | <xsl:call-template name="equivDocLinks">
|
---|
157 | <xsl:with-param name="count"><xsl:value-of select="$count + 1"/></xsl:with-param>
|
---|
158 | </xsl:call-template>
|
---|
159 | </xsl:if>
|
---|
160 |
|
---|
161 | </xsl:template>
|
---|
162 |
|
---|
163 | </xsl:stylesheet>
|
---|
164 |
|
---|