source: main/trunk/greenstone3/web/interfaces/default/transform/config_format.xsl@ 24227

Last change on this file since 24227 was 24227, checked in by ak19, 13 years ago

The sourcelinkfile subtype of gsf:link that was recently introduced is no longer necessary: it's been merged with the source subtype, which now uses the srclinkFile metadata instead of source and generates links to source documents with both image collections and DSpace collection.

File size: 8.3 KB
RevLine 
[23972]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:xslt="output.xsl"
5 xmlns:java="http://xml.apache.org/xslt/java"
6 xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
7 extension-element-prefixes="java">
8
9 <xsl:output method="xml"/>
10 <xsl:namespace-alias
11 stylesheet-prefix="xslt" result-prefix="xsl"/>
12
13 <xsl:template match="format">
14 <format>
15 <xsl:apply-templates/>
16 </format>
17 </xsl:template>
18
19 <xsl:template match="gsf:template">
20 <xslt:template>
21 <xsl:copy-of select="@*"/>
22 <xsl:attribute name="priority">2</xsl:attribute>
23 <xsl:if test=".//gsf:link">
24 <xslt:param name="serviceName"/>
25 <xslt:param name="collName"/>
26 </xsl:if>
27 <xsl:apply-templates/>
28 </xslt:template>
29 </xsl:template>
30
31 <xsl:template match="gsf:link">
32 <xsl:choose>
33 <xsl:when test="@type='classifier'">
34 <a><xslt:attribute name='href'><xslt:value-of select='$library_name'/>?a=b&amp;rt=r&amp;s=<xslt:value-of select='$serviceName'/>&amp;c=<xslt:value-of select='$collName'/>&amp;cl=<xslt:value-of select='@nodeID'/><xslt:if test="classifierNode|documentNode">.pr</xslt:if><xslt:if test="parent::node()[@orientation='horizontal']">&amp;sib=1</xslt:if></xslt:attribute>
35 <xsl:apply-templates/>
36 </a>
37 </xsl:when>
[24087]38 <xsl:when test="@type='source'">
39 <a><xslt:attribute name='href'><xslt:value-of
40 disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']" />/index/assoc/<xslt:value-of
41 disable-output-escaping="yes" select="metadataList/metadata[@name='assocfilepath']" />/<xslt:value-of
[24224]42 disable-output-escaping="yes" select="metadataList/metadata[@name='srclinkFile']" /></xslt:attribute>
[24198]43 <xsl:apply-templates/>
44 </a>
45 </xsl:when>
[24087]46
[23972]47 <xsl:otherwise> <!-- a document link -->
48 <xslt:variable name="bookswitch"><xslt:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/></xslt:variable>
49 <xslt:choose>
50 <xslt:when test="$bookswitch = 'on' or $bookswitch = 'flashxml'">
51 <a><xslt:attribute name="href"><xslt:value-of select='$library_name'/>?a=d&amp;ed=1&amp;book=on&amp;c=<xslt:value-of select='$collName'/>&amp;d=<xslt:value-of select='@nodeID'/>&amp;dt=<xslt:value-of select='@docType'/><xslt:if test="@nodeType='leaf'">&amp;sib=1</xslt:if>&amp;p.a=<xslt:value-of select="/page/pageRequest/@action"/>&amp;p.sa=<xsl:value-of select="/page/pageRequest/@subaction"/>&amp;p.s=<xslt:value-of select="$serviceName"/></xslt:attribute><xsl:apply-templates/></a>
52 </xslt:when>
53 <xslt:otherwise>
54 <a><xslt:attribute name="href"><xslt:value-of select='$library_name'/>?a=d&amp;book=off&amp;c=<xslt:value-of select='$collName'/>&amp;d=<xslt:value-of select='@nodeID'/>&amp;dt=<xslt:value-of select='@docType'/><xslt:if test="@nodeType='leaf'">&amp;sib=1</xslt:if>&amp;p.a=<xslt:value-of select="/page/pageRequest/@action"/>&amp;p.sa=<xsl:value-of select="/page/pageRequest/@subaction"/>&amp;p.s=<xslt:value-of select="$serviceName"/></xslt:attribute><xsl:apply-templates/></a>
55 </xslt:otherwise>
56 </xslt:choose>
57 </xsl:otherwise>
58 </xsl:choose>
59 </xsl:template>
60
61 <xsl:template match="gsf:icon">
62 <xsl:choose>
63 <xsl:when test="@type='classifier'">
64 <xslt:call-template name="bookshelfimg"/>
65 </xsl:when>
66 <xsl:otherwise>
67 <xslt:apply-templates select="." mode="displayNodeIcon"/>
68 </xsl:otherwise>
69 </xsl:choose>
70 </xsl:template>
[24219]71
72 <!-- calls a template in icons.xsl in order to avoid xsl vs xslt issue -->
73 <xsl:template match="gsf:equivlinkgs3">
74 <xslt:call-template name="equivDocLinks">
75 <xslt:with-param name="count" select="0"/>
76 </xslt:call-template>
77 </xsl:template>
78
79 <!-- Another way: build all the equivalent document links for the current document in one go. No looping necessary: handled in function call. -->
80 <!--<xsl:template match="gsf:equivlinkgs3">
81 <xslt:variable name="docicon" select="metadataList/metadata[contains(@name, 'equivDocIcon')]"/>
82 <xslt:variable name="docStartlink" select="metadataList/metadata[contains(@name, 'all_*,*_equivDocLink')]"/>
83 <xslt:variable name="docEndlink" select="metadataList/metadata[contains(@name, '/equivDocLink')]"/>
84
85 <xslt:variable name="equivDocLinks" select="java:org.greenstone.gsdl3.util.XSLTUtil.getEquivDocLinks(',',$docicon, $docStartlink, $docEndlink, ' ')" />
86 <xslt:value-of disable-output-escaping="yes" select="$equivDocLinks"/>
87 </xsl:template>-->
88
89<!--
90In the collection's format statement, could have the following javascript+XSLT in place of
91the gsf:equivlinkgs3 element (which resolves to the XSLT in config_format.xsl and icons.xsl).
92<xsl:text disable-output-escaping="yes">&lt;script&gt;var equivDocIcon= [ &quot;
93</xsl:text>
94<gsf:metadata name="equivDocIcon" separator="&quot;, &quot;" multiple="true"/>
95<xsl:text disable-output-escaping="yes">&quot;];var equivDocStartLink= [ &quot;
96</xsl:text>
97<gsf:metadata name="equivDocLink" separator="&quot;,&quot;" multiple="true"/>
98<xsl:text disable-output-escaping="yes">&quot;];var equivDocEndLink= [ &quot;
99</xsl:text>
100<gsf:metadata name="/equivDocLink" separator="&quot;,&quot;" multiple="true"/>
101<xsl:text disable-output-escaping="yes">&quot;];for (var i=0; i&lt;equivDocIcon.length; i++) { document.write(equivDocStartLink[i]+ equivDocIcon[i] + equivDocEndLink[i]); }&lt;/script&gt;
102</xsl:text>
103-->
104
[23972]105 <xsl:template match="gsf:metadata[@format]">
106 <xslt:value-of disable-output-escaping="yes"><xsl:attribute name="select">java:org.greenstone.gsdl3.util.XSLTUtil.<xsl:value-of select="@format"/>(metadataList/metadata[@name='<xsl:apply-templates select="." mode="get-metadata-name"/>'], /page/@lang )</xsl:attribute></xslt:value-of>
107 </xsl:template>
108
109 <xsl:template match="gsf:metadata">
110 <xslt:value-of disable-output-escaping="yes"><xsl:attribute name="select">metadataList/metadata[@name='<xsl:apply-templates select="." mode="get-metadata-name"/>']</xsl:attribute></xslt:value-of>
111 </xsl:template>
112
113 <xsl:template match="gsf:metadata" mode="get-metadata-name">
114 <xsl:if test="@multiple='true'">all_</xsl:if><xsl:if test='@select'><xsl:value-of select='@select'/>_</xsl:if><xsl:if test="@separator">*<xsl:value-of select='@separator'/>*_</xsl:if><xsl:value-of select="@name"/>
115 </xsl:template>
116
117 <xsl:template match="gsf:metadata-old">
118 <xslt:value-of disable-output-escaping="yes"><xsl:attribute name="select">metadataList/metadata[@name="<xsl:choose><xsl:when test="@select='parent'">parent_</xsl:when><xsl:when test="@select='root'">root_</xsl:when><xsl:when test="@select='ancestors'">ancestors'<xsl:value-of select='@separator'/>'_</xsl:when><xsl:when test="@select='siblings'">siblings_'<xsl:value-of select='@separator'/>'_</xsl:when></xsl:choose><xsl:value-of select="@name"/>"]</xsl:attribute></xslt:value-of>
119 </xsl:template>
120
121 <xsl:template match="gsf:text">
122 <xslt:apply-templates select="nodeContent"/>
123 </xsl:template>
124
125 <xsl:template match="gsf:choose-metadata">
126 <xslt:choose>
127 <xsl:for-each select="gsf:metadata">
128 <xslt:when><xsl:attribute name="test">metadataList/metadata[@name='<xsl:apply-templates select="." mode="get-metadata-name"/>']</xsl:attribute>
129 <xsl:apply-templates select="."/>
130 </xslt:when>
131 </xsl:for-each>
132 <xsl:if test="gsf:default">
133 <xslt:otherwise><xsl:apply-templates select="gsf:default"/></xslt:otherwise>
134 </xsl:if>
135 </xslt:choose>
136 </xsl:template>
137
138 <xsl:template match="gsf:switch">
139 <xsl:variable name="meta-name"><xsl:apply-templates select="gsf:metadata" mode="get-metadata-name"/></xsl:variable>
140 <xslt:variable name="meta"><xsl:choose><xsl:when test="@preprocess"><xslt:value-of select="util:{@preprocess}(metadataList/metadata[@name='{$meta-name}'])"/></xsl:when><xsl:otherwise><xslt:value-of select="metadataList/metadata[@name='{$meta-name}']"/></xsl:otherwise></xsl:choose></xslt:variable>
141 <xslt:choose>
142 <xsl:for-each select="gsf:when">
143 <xslt:when test="util:{@test}($meta, '{@test-value}')">
144 <xsl:apply-templates/>
145 </xslt:when>
146 </xsl:for-each>
147 <xsl:if test="gsf:otherwise">
148 <xslt:otherwise>
149 <xsl:apply-templates select="gsf:otherwise/node()"/>
150 </xslt:otherwise>
151 </xsl:if>
152 </xslt:choose>
153 </xsl:template>
154
155 <xsl:template match="*">
156 <xsl:copy>
157 <xsl:copy-of select="@*"/>
158 <xsl:apply-templates/>
159 </xsl:copy>
160 </xsl:template>
161
162</xsl:stylesheet>
163
164
Note: See TracBrowser for help on using the repository browser.