source: main/trunk/greenstone3/web/interfaces/basic/transform/expand-gsf.xsl@ 38056

Last change on this file since 38056 was 38056, checked in by kjdon, 9 months ago

made this interface work again with current greenstone. didn't do any prettying, just wanted to make it functional

File size: 8.5 KB
Line 
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 <!-- don't output anything for gsf:format-gs2 elements,
14 they just exist in collectionconfig files to keep the XML valid -->
15 <xsl:template match="gsf:format-gs2" />
16
17
18 <xsl:template match="format">
19 <format>
20 <xsl:apply-templates/>
21 </format>
22 </xsl:template>
23
24 <xsl:template match="gsf:template">
25 <xslt:template>
26 <xsl:copy-of select="@*"/>
27 <xsl:attribute name="priority">2</xsl:attribute>
28 <xsl:if test=".//gsf:link">
29 <xslt:param name="serviceName"/>
30 <xslt:param name="collName"/>
31 </xsl:if>
32 <xsl:apply-templates/>
33 </xslt:template>
34 </xsl:template>
35
36 <xsl:template match="gsf:link">
37 <xsl:choose>
38 <xsl:when test="@type='classifier'">
39 <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>
40 <xsl:apply-templates/>
41 </a>
42 </xsl:when>
43 <xsl:when test="@type='source'">
44 <a><xslt:attribute name='href'><xslt:value-of
45 disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']" />/index/assoc/<xslt:value-of
46 disable-output-escaping="yes" select="metadataList/metadata[@name='assocfilepath']" />/<xslt:value-of
47 disable-output-escaping="yes" select="metadataList/metadata[@name='srclinkFile']" /></xslt:attribute>
48 <xsl:apply-templates/>
49 </a>
50 </xsl:when>
51
52 <xsl:otherwise> <!-- a document link -->
53 <xslt:variable name="bookswitch"><xslt:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/></xslt:variable>
54 <xslt:choose>
55 <xslt:when test="$bookswitch = 'on' or $bookswitch = 'flashxml'">
56 <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>
57 </xslt:when>
58 <xslt:otherwise>
59 <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>
60 </xslt:otherwise>
61 </xslt:choose>
62 </xsl:otherwise>
63 </xsl:choose>
64 </xsl:template>
65
66 <xsl:template match="gsf:icon">
67 <xsl:choose>
68 <xsl:when test="@type='classifier'">
69 <xslt:call-template name="bookshelfimg"/>
70 </xsl:when>
71 <xsl:otherwise>
72 <xslt:apply-templates select="." mode="displayNodeIcon"/>
73 </xsl:otherwise>
74 </xsl:choose>
75 </xsl:template>
76
77 <!-- calls a template in icons.xsl in order to avoid xsl vs xslt issue -->
78 <xsl:template match="gsf:equivlinkgs3">
79 <xslt:call-template name="equivDocLinks">
80 <xslt:with-param name="count" select="0"/>
81 </xslt:call-template>
82 </xsl:template>
83
84 <!-- Another way: build all the equivalent document links for the current document in one go. No looping necessary: handled in function call. -->
85 <!--<xsl:template match="gsf:equivlinkgs3">
86 <xslt:variable name="docicon" select="metadataList/metadata[contains(@name, 'equivDocIcon')]"/>
87 <xslt:variable name="docStartlink" select="metadataList/metadata[contains(@name, 'all_*,*_equivDocLink')]"/>
88 <xslt:variable name="docEndlink" select="metadataList/metadata[contains(@name, '/equivDocLink')]"/>
89
90 <xslt:variable name="equivDocLinks" select="java:org.greenstone.gsdl3.util.XSLTUtil.getEquivDocLinks(',',$docicon, $docStartlink, $docEndlink, ' ')" />
91 <xslt:value-of disable-output-escaping="yes" select="$equivDocLinks"/>
92 </xsl:template>-->
93
94<!--
95In the collection's format statement, could have the following javascript+XSLT in place of
96the gsf:equivlinkgs3 element (which resolves to the XSLT in config_format.xsl and icons.xsl).
97<xsl:text disable-output-escaping="yes">&lt;script&gt;var equivDocIcon= [ &quot;
98</xsl:text>
99<gsf:metadata name="equivDocIcon" separator="&quot;, &quot;" multiple="true"/>
100<xsl:text disable-output-escaping="yes">&quot;];var equivDocStartLink= [ &quot;
101</xsl:text>
102<gsf:metadata name="equivDocLink" separator="&quot;,&quot;" multiple="true"/>
103<xsl:text disable-output-escaping="yes">&quot;];var equivDocEndLink= [ &quot;
104</xsl:text>
105<gsf:metadata name="/equivDocLink" separator="&quot;,&quot;" multiple="true"/>
106<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;
107</xsl:text>
108-->
109
110 <xsl:template match="gsf:metadata[@format]">
111 <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>
112 </xsl:template>
113
114 <xsl:template match="gsf:metadata">
115 <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>
116 </xsl:template>
117
118 <xsl:template match="gsf:metadata" mode="get-metadata-name">
119 <xsl:if test="@multiple='true'">all_</xsl:if><xsl:if test="starts-with(@multiple,'offset')"><xsl:value-of select='@multiple'/>_</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"/>
120 </xsl:template>
121
122 <xsl:template match="gsf:metadata-old">
123 <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>
124 </xsl:template>
125
126 <xsl:template match="gsf:text">
127 <xslt:apply-templates select="nodeContent"/>
128 </xsl:template>
129
130 <xsl:template match="gsf:choose-metadata">
131 <xslt:choose>
132 <xsl:for-each select="gsf:metadata">
133 <xslt:when><xsl:attribute name="test">metadataList/metadata[@name='<xsl:apply-templates select="." mode="get-metadata-name"/>']</xsl:attribute>
134 <xsl:apply-templates select="."/>
135 </xslt:when>
136 </xsl:for-each>
137 <xsl:if test="gsf:default">
138 <xslt:otherwise><xsl:apply-templates select="gsf:default"/></xslt:otherwise>
139 </xsl:if>
140 </xslt:choose>
141 </xsl:template>
142
143 <xsl:template match="gsf:switch">
144 <xsl:variable name="meta-name"><xsl:apply-templates select="gsf:metadata" mode="get-metadata-name"/></xsl:variable>
145 <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>
146 <xslt:choose>
147 <xsl:for-each select="gsf:when">
148 <xslt:when test="util:{@test}($meta, '{@test-value}')">
149 <xsl:apply-templates/>
150 </xslt:when>
151 </xsl:for-each>
152 <xsl:if test="gsf:otherwise">
153 <xslt:otherwise>
154 <xsl:apply-templates select="gsf:otherwise/node()"/>
155 </xslt:otherwise>
156 </xsl:if>
157 </xslt:choose>
158 </xsl:template>
159
160 <xsl:template match="*">
161 <xsl:copy>
162 <xsl:copy-of select="@*"/>
163 <xsl:apply-templates/>
164 </xsl:copy>
165 </xsl:template>
166
167</xsl:stylesheet>
168
169
Note: See TracBrowser for help on using the repository browser.