1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
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 | xmlns:gslib="http://www.greenstone.org/skinning"
|
---|
7 | xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
|
---|
8 | extension-element-prefixes="java util"
|
---|
9 | exclude-result-prefixes="java util gsf">
|
---|
10 |
|
---|
11 | <!--
|
---|
12 | Key goal: generate a IIIF v2 compliant manifest file in JSON format based on the document
|
---|
13 | -->
|
---|
14 |
|
---|
15 | <!-- Similar in spirit to document.xsl (catering for 'simple' and complex document structures such as 'pages'),
|
---|
16 | but considerably tailored down to produce the raw IIIF-manifest JSON format:
|
---|
17 | (i) focus on just the (potientailly hierachically nested) pages
|
---|
18 | (ii) so a bit like ed=1, but implied rather than needing to be set
|
---|
19 | -->
|
---|
20 |
|
---|
21 | <xsl:include href="layouts/header-vars.xsl"/>
|
---|
22 |
|
---|
23 | <!--
|
---|
24 | <xsl:include href="pages/document-shared.xsl" />
|
---|
25 | -->
|
---|
26 |
|
---|
27 | <xsl:include href="pages/document-vars.xsl" />
|
---|
28 |
|
---|
29 | <!-- Additional changes needed to GS3 Java runtine for the following output tag to operate correctly -->
|
---|
30 | <!-- Testing with o=xsl and the debug XML+XSL pair of files generated (when an error was encountred)
|
---|
31 | showed that the Greenstone3 runtime does not currently honour the output tag, in fact gslib.xsl
|
---|
32 | entries seem to turn up later on, and as this includes html-output.xsl, then a later xsl:output
|
---|
33 | tag is generated. The problems runner deeper than this however, with the XSLT output generated
|
---|
34 | having a DTD. Looks like gsdl3/TransformingReceptionist.java is geared to always generating
|
---|
35 | XML output of some form of other (e.g. RSS XML output). Generating raw text just doesn't
|
---|
36 | seem to get through. So to make progress have introduced CGI argument 'excerptid-text'
|
---|
37 | as a way of getting to the text that is generated within, say, a <pre> elemlent with an id attribute -->
|
---|
38 | <!--
|
---|
39 | <xsl:output method="text" version="1.0" encoding="utf-8" omit-xml-declaration="yes"/>
|
---|
40 | <xsl:strip-space elements="*"/>
|
---|
41 | -->
|
---|
42 |
|
---|
43 | <!-- page/pageRequest[@baseURL]="//intermuse.sowemustthink.space/greenstone3/ -->
|
---|
44 | <!-- page/pageRequest[@fullURL]="//intermuse.sowemustthink.space/greenstone3/library?a=d.... -->
|
---|
45 | <!-- ***** need to work out domain name to use from raw XML message, say processing something from the above -->
|
---|
46 | <xsl:variable name="window-location-origin">https://intermuse.sowemustthink.space</xsl:variable>
|
---|
47 |
|
---|
48 |
|
---|
49 | <xsl:variable name="iiifPresentationRootIdentifier">http-greenstone://<xsl:value-of select="$site_name"/>/<xsl:value-of select="$collNameChecked"/>/<xsl:value-of select="$docID"/></xsl:variable>
|
---|
50 |
|
---|
51 | <xsl:template match="/">
|
---|
52 | <html>
|
---|
53 | <body>
|
---|
54 | <pre id="iiif-manifest">
|
---|
55 | <xsl:apply-templates select="/page/pageResponse/document" />
|
---|
56 | </pre>
|
---|
57 | </body>
|
---|
58 | </html>
|
---|
59 | </xsl:template>
|
---|
60 |
|
---|
61 | <xsl:template match="/page/pageResponse/document">
|
---|
62 | <!-- display the document -->
|
---|
63 | <xsl:choose>
|
---|
64 | <xsl:when test="@docType='simple'">
|
---|
65 | <xsl:call-template name="documentContent"/>
|
---|
66 | </xsl:when>
|
---|
67 | <xsl:otherwise> <!-- kick off the recursive call for a more complex structured document-->
|
---|
68 | <xsl:call-template name="wrappedDocumentTopLevel"/>
|
---|
69 | </xsl:otherwise>
|
---|
70 | </xsl:choose>
|
---|
71 | </xsl:template>
|
---|
72 |
|
---|
73 |
|
---|
74 | <xsl:template name="wrappedDocumentTopLevel">
|
---|
75 | <!-- <xsl:call-template name="documentPre"/> -->
|
---|
76 | <xsl:call-template name="wrappedDocument"/> <!-- without ed=1, this template misses the binds in of documentPre and documentPost -->
|
---|
77 | <!-- <xsl:call-template name="documentPost"/> -->
|
---|
78 | </xsl:template>
|
---|
79 |
|
---|
80 | <xsl:template name="wrappedDocument">
|
---|
81 | <xsl:call-template name="documentPre"/>
|
---|
82 | <xsl:for-each select="documentNode">
|
---|
83 | <xsl:call-template name="wrapDocumentNodes"/>
|
---|
84 | </xsl:for-each>
|
---|
85 | <xsl:call-template name="documentPost"/>
|
---|
86 | </xsl:template>
|
---|
87 |
|
---|
88 |
|
---|
89 | <xsl:template name="iiif-other-content">
|
---|
90 | <xsl:param name="optSection"/>
|
---|
91 | <xsl:variable name="baseURL">https:<xsl:value-of select="/page/pageRequest/@baseURL"/></xsl:variable> <!-- **** had to hardwire https: -->
|
---|
92 | <xsl:if test="/page/pageResponse/format[@type='display']/gsf:option[@name='includeFileAssocOpenAnnotations']/@value='true'">
|
---|
93 | "otherContent": [{
|
---|
94 | "@id": "<xsl:value-of select="$baseURL"/><xsl:value-of select="$library_name"/>/sites/<xsl:value-of select="$site_name"/>/collect/<xsl:value-of select="$collNameChecked"/>/index/assoc/<gsf:metadata name="assocfilepath" select="root"/>/openannotation-list<xsl:value-of select="$optSection"/>.json",
|
---|
95 | "@type": "sc:AnnotationList"
|
---|
96 | }],
|
---|
97 | </xsl:if>
|
---|
98 | </xsl:template>
|
---|
99 |
|
---|
100 |
|
---|
101 | <xsl:template name="iiif-canvas-image">
|
---|
102 | <xsl:param name="identifier"/>
|
---|
103 | <xsl:param name="docType"/>
|
---|
104 | <!-- -->
|
---|
105 | <xsl:variable name="iiifImageRootIdentifier">
|
---|
106 | <xsl:text>/gs-cantaloupe/iiif/2/</xsl:text><xsl:value-of select="$site_name"/>:<xsl:value-of select="$collNameChecked"/>:<xsl:value-of select="$identifier"/>
|
---|
107 | </xsl:variable>
|
---|
108 |
|
---|
109 | <xsl:variable name="section"><xsl:value-of select="position()" /></xsl:variable>
|
---|
110 | <xsl:variable name="optSection">
|
---|
111 | <xsl:choose>
|
---|
112 | <xsl:when test="$docType = 'simple'"></xsl:when><!-- i.e. empty -->
|
---|
113 | <xsl:otherwise><xsl:value-of select="position()" /></xsl:otherwise>
|
---|
114 | </xsl:choose>
|
---|
115 | </xsl:variable>
|
---|
116 | <xsl:variable name="chosenTitle">
|
---|
117 | <xsl:choose>
|
---|
118 | <xsl:when test="$docType = 'simple'">
|
---|
119 | <xsl:call-template name="choose-title"/>
|
---|
120 | </xsl:when>
|
---|
121 | <xsl:otherwise>page <xsl:value-of select="$section"/></xsl:otherwise>
|
---|
122 | </xsl:choose>
|
---|
123 | </xsl:variable>
|
---|
124 | <!-- The following is useful for debugging, nested in 'pre' tags -->
|
---|
125 | <!--
|
---|
126 | docType = <xsl:value-of select="$docType"/>
|
---|
127 | docID = <xsl:value-of select="$docID"/>
|
---|
128 | position = <xsl:value-of select="position()" />
|
---|
129 |
|
---|
130 | identifer = <xsl:value-of select="$identifier"/>
|
---|
131 | section = <xsl:value-of select="$section"/>
|
---|
132 | optSection = <xsl:value-of select="$optSection"/>
|
---|
133 |
|
---|
134 | iiifPresRootIdentifier = <xsl:value-of select="$iiifPresentationRootIdentifier" />
|
---|
135 | iiifImageRootIdentifier = <xsl:value-of select="$iiifImageRootIdentifier" />
|
---|
136 | -->
|
---|
137 | <!-- an array entry in 'canvases': { @content, @id, @type, label, width, height, images[{}], thumbnail {@id,@type} } -->
|
---|
138 | <!-- add a comma first, if it is not the first canvas element in the array -->
|
---|
139 | <xsl:if test="$section > 1">
|
---|
140 | ,
|
---|
141 | </xsl:if>
|
---|
142 | {
|
---|
143 | "@context": "http://iiif.io/api/presentation/2/context.json",
|
---|
144 | "@id" : "<xsl:value-of select="$iiifPresentationRootIdentifier" />/canvas/<xsl:value-of select="$section"/>",
|
---|
145 | "@type" : "sc:Canvas",
|
---|
146 | "label" : "<xsl:value-of select="$chosenTitle"/>",
|
---|
147 | <xsl:call-template name="iiif-other-content">
|
---|
148 | <xsl:with-param name="optSection"><xsl:value-of select="$optSection"/></xsl:with-param>
|
---|
149 | </xsl:call-template>
|
---|
150 | "width" : <gsf:metadata name="ImageWidth"/>,
|
---|
151 | "height" : <gsf:metadata name="ImageHeight"/>,
|
---|
152 | "images": [{
|
---|
153 | "@context": "http://iiif.io/api/image/2/context.json",
|
---|
154 | "@id": "<xsl:value-of select="$iiifPresentationRootIdentifier" />/annotation/<xsl:value-of select="$section"/>",
|
---|
155 | "@type": "oa:Annotation",
|
---|
156 | "motivation": "sc:painting",
|
---|
157 | "on": "<xsl:value-of select="$iiifPresentationRootIdentifier" />/canvas",
|
---|
158 | "resource": {
|
---|
159 | "@id": "<xsl:value-of select="$window-location-origin" /><xsl:value-of select="$iiifImageRootIdentifier" />/full/full/0/default.jpg",
|
---|
160 | "@type": "dctypes:Image",
|
---|
161 | "format": "image/jpeg",
|
---|
162 | "width": <gsf:metadata name="ImageWidth"/>,
|
---|
163 | "hieght": <gsf:metadata name="ImageHeight"/>,
|
---|
164 | "service": {
|
---|
165 | "@context": "http://iiif.io/api/image/2/context.json",
|
---|
166 | "@id": "<xsl:value-of select="$window-location-origin" /><xsl:value-of select="$iiifImageRootIdentifier" />",
|
---|
167 | "profile": "https://iiif.io/api/image/2/profiles/level2.json"
|
---|
168 | }
|
---|
169 | }
|
---|
170 | }],
|
---|
171 | "thumbnail": {
|
---|
172 | "@id": "<xsl:value-of select="$window-location-origin" /><xsl:value-of select="$iiifImageRootIdentifier" />/full/,150/0/default.jpg",
|
---|
173 | "@type": "dctypes:Image"
|
---|
174 | }
|
---|
175 | }
|
---|
176 | <!-- Another field to consider in the above JSON is: -->
|
---|
177 | <!-- "format": mime_type, // ???? or is it OK to always have this as image/jpeg and rely on IIIF Image Server coverting as/when needed??? -->
|
---|
178 | </xsl:template>
|
---|
179 |
|
---|
180 |
|
---|
181 | <xsl:template name="wrappedSectionPost">
|
---|
182 |
|
---|
183 | <!-- add in IIIF Server link for section image -->
|
---|
184 | <xsl:variable name="nodeID" select="@nodeID"/>
|
---|
185 | <xsl:call-template name="iiif-canvas-image">
|
---|
186 | <xsl:with-param name="identifier" select="$nodeID" />
|
---|
187 | <xsl:with-param name="docType" select="@docType" />
|
---|
188 | </xsl:call-template>
|
---|
189 | </xsl:template>
|
---|
190 |
|
---|
191 | <xsl:template name="sectionImage">
|
---|
192 | <!-- don't need this template to generate anything in the IIIF-Manifest JSON case -->
|
---|
193 | </xsl:template>
|
---|
194 |
|
---|
195 | <xsl:template name="sectionContent">
|
---|
196 | <xsl:call-template name="wrappedSectionPost"/>
|
---|
197 | </xsl:template>
|
---|
198 |
|
---|
199 |
|
---|
200 | <xsl:template name="documentPre">
|
---|
201 | <xsl:variable name="httpCollection">library/sites/<xsl:value-of select="$site_name"/>/collect/<xsl:value-of select="/page/pageResponse/collection/@name"/></xsl:variable>
|
---|
202 |
|
---|
203 | <xsl:variable name="toplevelChosenTitle">
|
---|
204 | <xsl:choose>
|
---|
205 | <xsl:when test="@docType='simple'">
|
---|
206 | <xsl:call-template name="choose-title"/>
|
---|
207 | </xsl:when>
|
---|
208 | <xsl:otherwise>
|
---|
209 | <xsl:value-of disable-output-escaping="yes" select="/page/pageResponse/document/documentNode/metadataList/metadata[@name='Title']" />
|
---|
210 | </xsl:otherwise>
|
---|
211 | </xsl:choose>
|
---|
212 | </xsl:variable>
|
---|
213 |
|
---|
214 | <!-- start of iiif_manifest: -->
|
---|
215 | {
|
---|
216 | "@context": "http://iiif.io/api/presentation/2/context.json",
|
---|
217 | "@type": "sc:Manifest",
|
---|
218 | "@id": "<xsl:value-of select="$iiifPresentationRootIdentifier"/>/manifest",
|
---|
219 | "label": "<xsl:value-of select="$toplevelChosenTitle"/>",
|
---|
220 | "attribution": "The Internet of Musical Events (InterMusE): Digital Scholarship, Community, and the Archiving of Performance",
|
---|
221 | "license": "https://**** To Be Determined ****",
|
---|
222 | "logo": "https://intermuse.datatodata.org/wp-content/uploads/sites/4/2021/03/cropped-cropped-cropped-1.png",
|
---|
223 | "metadata": [
|
---|
224 | { "label": "creator", "value": ["aaa1","aaa2"] },
|
---|
225 | { "label": "title", "value": ["chosen-title"] }
|
---|
226 | ],
|
---|
227 | <!-- trival IIIF sequences => has one IIIF canvas in it -->
|
---|
228 | "sequences": [{
|
---|
229 | "@context": "http://iiif.io/api/image/2/context.json",
|
---|
230 | "@id": "<xsl:value-of select="$iiifPresentationRootIdentifier"/>/sequence/normal",
|
---|
231 | "@type": "sc:Sequence",
|
---|
232 | "canvases": [
|
---|
233 | </xsl:template>
|
---|
234 |
|
---|
235 |
|
---|
236 | <xsl:template name="documentContentSimpleIIIFImage">
|
---|
237 | <xsl:call-template name="iiif-canvas-image">
|
---|
238 | <xsl:with-param name="identifier" select="$docID" />
|
---|
239 | <xsl:with-param name="docType" select="@docType" />
|
---|
240 | </xsl:call-template>
|
---|
241 | </xsl:template>
|
---|
242 |
|
---|
243 | <xsl:template name="documentContent">
|
---|
244 | <!-- The way document.xsl templates are structured, only get to here is if @docType = 'simple' -->
|
---|
245 | <!-- A 'paged' (or 'hierarical') document goes throgh 'wrappedContent' -->
|
---|
246 | <xsl:call-template name="documentPre"/>
|
---|
247 | <xsl:call-template name="documentContentSimpleIIIFImage"/>
|
---|
248 | <xsl:call-template name="documentPost"/>
|
---|
249 | </xsl:template>
|
---|
250 |
|
---|
251 |
|
---|
252 | <xsl:template name="wrapDocumentNodes">
|
---|
253 |
|
---|
254 | <xsl:if test="@nodeType = 'leaf'">
|
---|
255 | <!-- for iiif-manifest JSON, put out a flat-list of images => only interested in leaf nodes -->
|
---|
256 | <xsl:call-template name="sectionContent"/>
|
---|
257 | </xsl:if>
|
---|
258 |
|
---|
259 | <xsl:if test="documentNode">
|
---|
260 | <xsl:for-each select="documentNode">
|
---|
261 | <xsl:call-template name="wrapDocumentNodes"/>
|
---|
262 | </xsl:for-each>
|
---|
263 | </xsl:if>
|
---|
264 | </xsl:template>
|
---|
265 |
|
---|
266 | <xsl:template name="wrappedSectionImage">
|
---|
267 | <!-- don't need this template to generate anything in the IIIF-Manifest JSON case -->
|
---|
268 | </xsl:template>
|
---|
269 |
|
---|
270 |
|
---|
271 |
|
---|
272 | <xsl:template name="documentPost">
|
---|
273 | <!-- end of iiif_manifest: -->
|
---|
274 | <!-- close of canvases, then close higher level blocks to complete the JSON file -->
|
---|
275 | ]
|
---|
276 | }]
|
---|
277 | }
|
---|
278 | </xsl:template>
|
---|
279 |
|
---|
280 |
|
---|
281 | </xsl:stylesheet>
|
---|