[37090] | 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 |
|
---|
[37093] | 21 | <xsl:include href="layouts/header-vars.xsl"/>
|
---|
[37090] | 22 |
|
---|
| 23 | <xsl:include href="pages/document-shared.xsl" />
|
---|
[37093] | 24 | <xsl:include href="pages/document-vars.xsl" />
|
---|
[37090] | 25 |
|
---|
| 26 |
|
---|
| 27 | <xsl:output method="html" version="1.0" encoding="utf-8"/>
|
---|
| 28 |
|
---|
| 29 | <!--
|
---|
| 30 | <xsl:output method="text" version="1.0" encoding="utf-8" omit-xml-declaration="yes"/>
|
---|
| 31 | <xsl:strip-space elements="*"/>
|
---|
| 32 | -->
|
---|
| 33 |
|
---|
| 34 | <xsl:variable name="iiifPresentationRootIdentifier">http-greenstone://<xsl:value-of select="$site_name"/>/<xsl:value-of select="$collNameChecked"/>/<xsl:value-of select="$docID"/></xsl:variable>
|
---|
| 35 |
|
---|
| 36 | <xsl:template match="/">
|
---|
| 37 | <html>
|
---|
| 38 | <body>
|
---|
| 39 | <pre>
|
---|
| 40 | <xsl:apply-templates select="/page/pageResponse/document" />
|
---|
| 41 | </pre>
|
---|
| 42 | </body>
|
---|
| 43 | </html>
|
---|
| 44 |
|
---|
| 45 | </xsl:template>
|
---|
| 46 |
|
---|
| 47 | <xsl:template match="/page/pageResponse/document">
|
---|
| 48 | <!-- display the document -->
|
---|
| 49 | <xsl:choose>
|
---|
| 50 | <xsl:when test="@docType='simple'">
|
---|
| 51 | <xsl:call-template name="documentContent"/>
|
---|
| 52 | </xsl:when>
|
---|
| 53 | <xsl:otherwise> <!-- kick off the recursive call for a more complex structured document-->
|
---|
| 54 | <xsl:call-template name="wrappedDocumentTopLevel"/>
|
---|
| 55 | </xsl:otherwise>
|
---|
| 56 | </xsl:choose>
|
---|
| 57 | </xsl:template>
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | <xsl:template name="wrappedDocumentTopLevel">
|
---|
| 61 |
|
---|
| 62 | <!-- <xsl:call-template name="documentPre"/> -->
|
---|
| 63 | <xsl:call-template name="wrappedDocument"/> <!-- without ed=1, this template misses the binds in of documentPre and documentPost -->
|
---|
| 64 | <!-- <xsl:call-template name="documentPost"/> -->
|
---|
| 65 |
|
---|
| 66 | </xsl:template>
|
---|
| 67 |
|
---|
| 68 |
|
---|
| 69 | <xsl:template name="wrappedDocument">
|
---|
| 70 |
|
---|
| 71 | <xsl:call-template name="documentPre"/>
|
---|
| 72 | <xsl:for-each select="documentNode">
|
---|
| 73 | <xsl:call-template name="wrapDocumentNodes"/>
|
---|
| 74 | </xsl:for-each>
|
---|
| 75 | <xsl:call-template name="documentPost"/>
|
---|
| 76 |
|
---|
| 77 | </xsl:template>
|
---|
| 78 |
|
---|
| 79 |
|
---|
| 80 | <xsl:template name="iiif-other-content">
|
---|
| 81 | <xsl:param name="optSection"/>
|
---|
| 82 |
|
---|
| 83 | <xsl:variable name="baseURL">https:<xsl:value-of select="/page/pageRequest/@baseURL"/></xsl:variable> <!-- **** had to hardwire https: -->
|
---|
| 84 | <!-- **** test for a gsf-option before include !!!! -->
|
---|
| 85 | "otherContent": [{
|
---|
| 86 | "@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",
|
---|
| 87 | "@type": "sc:AnnotationList"
|
---|
| 88 | }],
|
---|
| 89 | </xsl:template>
|
---|
| 90 |
|
---|
| 91 |
|
---|
| 92 | <xsl:template name="iiif-canvas-image">
|
---|
| 93 | <xsl:param name="identifier"/>
|
---|
| 94 | <xsl:param name="docType"/>
|
---|
| 95 |
|
---|
| 96 | <xsl:variable name="iiifImageRootIdentifier">
|
---|
| 97 | <xsl:text>/gs-cantaloupe/iiif/2/</xsl:text><xsl:value-of select="$site_name"/>:<xsl:value-of select="$collNameChecked"/>:<xsl:value-of select="$identifier"/>
|
---|
| 98 | </xsl:variable>
|
---|
| 99 |
|
---|
| 100 | <!-- page/pageRequest[@baseURL]="//intermuse.sowemustthink.space/greenstone3/ -->
|
---|
| 101 | <!-- page/pageRequest[@fullURL]="//intermuse.sowemustthink.space/greenstone3/library?a=d.... -->
|
---|
| 102 |
|
---|
| 103 | <!-- ***** need to work out domain name to use from raw XML message, say processing something from the above -->
|
---|
| 104 |
|
---|
[37094] | 105 | <xsl:variable name="window-location-origin">https://intermuse.sowemustthink.space</xsl:variable>
|
---|
[37090] | 106 |
|
---|
| 107 | <xsl:variable name="section"><xsl:value-of select="position()" /></xsl:variable>
|
---|
| 108 | <xsl:variable name="optSection">
|
---|
| 109 | <xsl:choose>
|
---|
| 110 | <xsl:when test="$docType = 'simple'"></xsl:when><!-- i.e. empty -->
|
---|
| 111 | <xsl:otherwise><xsl:value-of select="position()" /></xsl:otherwise>
|
---|
| 112 | </xsl:choose>
|
---|
| 113 | </xsl:variable>
|
---|
| 114 |
|
---|
| 115 |
|
---|
| 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 |
|
---|
| 125 | <!-- The following is useful for debugging, nested in 'pre' tags -->
|
---|
| 126 | <!--
|
---|
| 127 | docType = <xsl:value-of select="$docType"/>
|
---|
| 128 | docID = <xsl:value-of select="$docID"/>
|
---|
| 129 | position = <xsl:value-of select="position()" />
|
---|
| 130 |
|
---|
| 131 | identifer = <xsl:value-of select="$identifier"/>
|
---|
| 132 | section = <xsl:value-of select="$section"/>
|
---|
| 133 | optSection = <xsl:value-of select="$optSection"/>
|
---|
| 134 |
|
---|
| 135 | iiifPresRootIdentifier = <xsl:value-of select="$iiifPresentationRootIdentifier" />
|
---|
| 136 | iiifImageRootIdentifier = <xsl:value-of select="$iiifImageRootIdentifier" />
|
---|
| 137 | -->
|
---|
| 138 | <!-- an array entry in 'canvases': { @content, @id, @type, label, width, height, images[{}], thumbnail {@id,@type} } -->
|
---|
| 139 | <!-- add a comma first, if it is not the first canvas element in the array -->
|
---|
| 140 | <xsl:if test="$section > 1">
|
---|
| 141 | ,
|
---|
| 142 | </xsl:if>
|
---|
| 143 | {
|
---|
| 144 | "@context": "http://iiif.io/api/presentation/2/context.json",
|
---|
| 145 | "@id": "<xsl:value-of select="$iiifPresentationRootIdentifier" />/canvas/<xsl:value-of select="$section"/>",
|
---|
| 146 | "@type": "sc:Canvas",
|
---|
| 147 | "label": "<xsl:value-of select="$chosenTitle"/>",
|
---|
| 148 | <xsl:call-template name="iiif-other-content">
|
---|
| 149 | <xsl:with-param name="optSection"><xsl:value-of select="$optSection"/></xsl:with-param>
|
---|
| 150 | </xsl:call-template>
|
---|
| 151 | "width": <gsf:metadata name="ImageWidth"/>,
|
---|
| 152 | "height": <gsf:metadata name="ImageHeight"/>,
|
---|
| 153 |
|
---|
| 154 | "images": [{
|
---|
| 155 | "image": {
|
---|
| 156 | "@context": "http://iiif.io/api/image/2/context.json",
|
---|
| 157 | "@type": "oa:Annotation",
|
---|
| 158 | "motivation": "sc:painting",
|
---|
| 159 | "on": "<xsl:value-of select="$iiifPresentationRootIdentifier" />/annotation/<xsl:value-of select="$section"/>",
|
---|
| 160 |
|
---|
| 161 | "resource": {
|
---|
[37094] | 162 | "@id": "<xsl:value-of select="$window-location-origin" /><xsl:value-of select="$iiifImageRootIdentifier" />/full/full/0/default.jpg",
|
---|
[37090] | 163 | "@type": "dctypes:Image",
|
---|
| 164 | "format": "image/jpeg",
|
---|
| 165 | "width": <gsf:metadata name="ImageWidth"/>,
|
---|
| 166 | "hieght": <gsf:metadata name="ImageHeight"/>,
|
---|
| 167 | "service": {
|
---|
| 168 | "@context": "http://iiif.io/api/image/2/context.json",
|
---|
[37094] | 169 | "@id": "<xsl:value-of select="$window-location-origin" /><xsl:value-of select="$iiifImageRootIdentifier" />",
|
---|
[37090] | 170 | "profile": "https://iiif.io/api/image/2/profiles/level2.json"
|
---|
| 171 | }
|
---|
| 172 | }
|
---|
| 173 | }
|
---|
| 174 | }],
|
---|
| 175 | "thumbnail": {
|
---|
[37094] | 176 | "@id": "<xsl:value-of select="$window-location-origin" /><xsl:value-of select="$iiifImageRootIdentifier" />/full/,150/0/default.jpg",
|
---|
[37090] | 177 | "@type": "dctypes:Image"
|
---|
| 178 | }
|
---|
| 179 | }
|
---|
| 180 | <!-- Another field to consider in the above JSON is: -->
|
---|
| 181 | <!-- "format": mime_type, // ???? or is it OK to always have this as image/jpeg and rely on IIIF Image Server coverting as/when needed??? -->
|
---|
| 182 | </xsl:template>
|
---|
| 183 |
|
---|
| 184 |
|
---|
| 185 | <xsl:template name="wrappedSectionPost">
|
---|
| 186 |
|
---|
| 187 | <!-- add in IIIF Server link for section image -->
|
---|
| 188 | <xsl:variable name="nodeID" select="@nodeID"/>
|
---|
| 189 | <xsl:call-template name="iiif-canvas-image">
|
---|
| 190 | <xsl:with-param name="identifier" select="$nodeID" />
|
---|
| 191 | <xsl:with-param name="docType" select="@docType" />
|
---|
| 192 | </xsl:call-template>
|
---|
| 193 | </xsl:template>
|
---|
| 194 |
|
---|
| 195 | <xsl:template name="sectionImage">
|
---|
| 196 | <!-- don't need this template to generate anything in the IIIF-Manifest JSON case -->
|
---|
| 197 | </xsl:template>
|
---|
| 198 |
|
---|
| 199 | <xsl:template name="sectionContent">
|
---|
| 200 | <xsl:call-template name="wrappedSectionPost"/>
|
---|
| 201 | </xsl:template>
|
---|
| 202 |
|
---|
| 203 |
|
---|
| 204 | <xsl:template name="documentPre">
|
---|
| 205 | <xsl:variable name="httpCollection">library/sites/<xsl:value-of select="$site_name"/>/collect/<xsl:value-of select="/page/pageResponse/collection/@name"/></xsl:variable>
|
---|
| 206 |
|
---|
[37093] | 207 | <xsl:variable name="toplevelChosenTitle">
|
---|
[37090] | 208 | <xsl:choose>
|
---|
| 209 | <xsl:when test="@docType='simple'">
|
---|
| 210 | <xsl:call-template name="choose-title"/>
|
---|
| 211 | </xsl:when>
|
---|
| 212 | <xsl:otherwise>
|
---|
| 213 | <xsl:value-of disable-output-escaping="yes" select="/page/pageResponse/document/documentNode/metadataList/metadata[@name='Title']" />
|
---|
| 214 | </xsl:otherwise>
|
---|
| 215 | </xsl:choose>
|
---|
| 216 | </xsl:variable>
|
---|
| 217 |
|
---|
| 218 | <!-- start of iiif_manifest: -->
|
---|
| 219 | {
|
---|
| 220 | "@context": "http://iiif.io/api/presentation/2/context.json",
|
---|
| 221 | "@type": "sc:Manifest",
|
---|
| 222 | "@id": "<xsl:value-of select="$iiifPresentationRootIdentifier"/>/manifest",
|
---|
[37093] | 223 | "label": "<xsl:value-of select="$toplevelChosenTitle"/>",
|
---|
[37090] | 224 | "attribution": "The Internet of Musical Events (InterMusE): Digital Scholarship, Community, and the Archiving of Performance",
|
---|
| 225 | "license": "https://**** To Be Determined ****",
|
---|
| 226 | "logo": "https://intermuse.datatodata.org/wp-content/uploads/sites/4/2021/03/cropped-cropped-cropped-1.png",
|
---|
| 227 | "metadata": [
|
---|
| 228 | { "label": "creator", "value": ["aaa1","aaa2"] },
|
---|
| 229 | { "label": "title", "value": ["chosen-title"] }
|
---|
| 230 | ],
|
---|
| 231 | <!-- trival IIIF sequences => has one IIIF canvas in it -->
|
---|
| 232 | "sequences": [{
|
---|
| 233 | "@context": "http://iiif.io/api/image/2/context.json",
|
---|
| 234 | "@id": "<xsl:value-of select="$iiifPresentationRootIdentifier"/>/sequence/normal",
|
---|
| 235 | "@type": "sc:Sequence",
|
---|
| 236 | "canvases": [
|
---|
| 237 |
|
---|
| 238 | </xsl:template>
|
---|
| 239 |
|
---|
| 240 |
|
---|
| 241 | <xsl:template name="documentContentSimpleIIIFImage">
|
---|
| 242 | <xsl:call-template name="iiif-canvas-image">
|
---|
| 243 | <xsl:with-param name="identifier" select="$docID" />
|
---|
| 244 | <xsl:with-param name="docType" select="@docType" />
|
---|
| 245 | </xsl:call-template>
|
---|
| 246 | </xsl:template>
|
---|
| 247 |
|
---|
| 248 | <xsl:template name="documentContent">
|
---|
| 249 | <!-- The way document.xsl templates are structured, only get to here is if @docType = 'simple' -->
|
---|
| 250 | <!-- A 'paged' (or 'hierarical') document goes throgh 'wrappedContent' -->
|
---|
| 251 | <xsl:call-template name="documentPre"/>
|
---|
| 252 | <xsl:call-template name="documentContentSimpleIIIFImage"/>
|
---|
| 253 | <xsl:call-template name="documentPost"/>
|
---|
| 254 | </xsl:template>
|
---|
| 255 |
|
---|
| 256 |
|
---|
| 257 | <xsl:template name="wrapDocumentNodes">
|
---|
| 258 |
|
---|
[37093] | 259 | <xsl:if test="@nodeType = 'leaf'">
|
---|
| 260 | <!-- for iiif-manifest JSON, put out a flat-list of images => only interested in leaf nodes -->
|
---|
| 261 | <xsl:call-template name="sectionContent"/>
|
---|
| 262 | </xsl:if>
|
---|
[37090] | 263 |
|
---|
| 264 | <xsl:if test="documentNode">
|
---|
| 265 | <xsl:for-each select="documentNode">
|
---|
| 266 | <xsl:call-template name="wrapDocumentNodes"/>
|
---|
| 267 | </xsl:for-each>
|
---|
| 268 | </xsl:if>
|
---|
| 269 | </xsl:template>
|
---|
| 270 |
|
---|
| 271 | <xsl:template name="wrappedSectionImage">
|
---|
| 272 | <!-- don't need this template to generate anything in the IIIF-Manifest JSON case -->
|
---|
| 273 | </xsl:template>
|
---|
| 274 |
|
---|
| 275 |
|
---|
| 276 |
|
---|
| 277 | <xsl:template name="documentPost">
|
---|
| 278 | <!-- end of iiif_manifest: -->
|
---|
| 279 | <!-- close of canvases, then close higher level blocks to complete the JSON file -->
|
---|
| 280 | ]
|
---|
| 281 | }]
|
---|
| 282 | }
|
---|
| 283 |
|
---|
| 284 | </xsl:template>
|
---|
| 285 |
|
---|
| 286 |
|
---|
| 287 | </xsl:stylesheet>
|
---|