Ignore:
Timestamp:
2023-01-04T21:15:35+13:00 (16 months ago)
Author:
davidb
Message:

Changes made after introduction of CGI arg 'excerptid-text' and testing to ensure the generated IIIF Manifest was valid syntax

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/transform/pages/document-iiif-manifest.xsl

    r37094 r37099  
    2424  <xsl:include href="pages/document-vars.xsl" />
    2525
    26  
    27   <xsl:output method="html" version="1.0" encoding="utf-8"/>
    28  
     26  <!-- Additional changes needed to GS3 Java runtine for the following output tag to operate correctly -->
     27  <!-- Testing with o=xsl and the debug XML+XSL pair of files generated (when an error was encountred)
     28       showed that the Greenstone3 runtime does not currently honour the output tag, in fact gslib.xsl
     29       entries seem to turn up later on, and as this includes html-output.xsl, then a later xsl:output
     30       tag is generated.  The problems runner deeper than this however, with the XSLT output generated
     31       having a DTD.  Looks like gsdl3/TransformingReceptionist.java is geared to always generating
     32       XML output of some form of other (e.g. RSS XML output).  Generating raw text just doesn't
     33       seem to get through.  So to make progress have introduced CGI argument 'excerptid-text'
     34       as a way of getting to the text that is generated within, say, a <pre> elemlent with an id attribute -->
    2935  <!--
    3036  <xsl:output method="text" version="1.0" encoding="utf-8" omit-xml-declaration="yes"/>
     
    3339 
    3440  <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 
     41 
    3642  <xsl:template match="/">
    3743      <html>
    3844    <body>
    39       <pre>
    40       <xsl:apply-templates select="/page/pageResponse/document" />
     45      <pre id="iiif-manifest">
     46        <xsl:apply-templates select="/page/pageResponse/document" />
    4147    </pre>
    4248      </body>
    4349    </html>
    44    
    4550  </xsl:template>
    4651
     
    5964 
    6065  <xsl:template name="wrappedDocumentTopLevel">
    61 
    6266    <!-- <xsl:call-template name="documentPre"/> -->
    6367    <xsl:call-template name="wrappedDocument"/> <!-- without ed=1, this template misses the binds in of documentPre and documentPost -->
    6468    <!-- <xsl:call-template name="documentPost"/> -->
    65 
    66   </xsl:template>
    67 
     69  </xsl:template>
    6870
    6971  <xsl:template name="wrappedDocument">
    70 
    7172    <xsl:call-template name="documentPre"/>
    7273      <xsl:for-each select="documentNode">
    7374    <xsl:call-template name="wrapDocumentNodes"/>
    7475      </xsl:for-each>
    75     <xsl:call-template name="documentPost"/>                   
    76    
    77   </xsl:template>   
    78  
    79  
     76    <xsl:call-template name="documentPost"/>   
     77  </xsl:template>
     78 
     79 
    8080  <xsl:template name="iiif-other-content">
    81     <xsl:param name="optSection"/>
    82    
     81    <xsl:param name="optSection"/>   
    8382    <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",
     83    <xsl:if test="/page/pageResponse/format[@type='display']/gsf:option[@name='includeFileAssocOpenAnnotations']/@value='true'">
     84             "otherContent": [{
     85                    "@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",
    8786                    "@type": "sc:AnnotationList"
    8887              }],
     88    </xsl:if>
    8989  </xsl:template>
    9090 
     
    9393    <xsl:param name="identifier"/>
    9494    <xsl:param name="docType"/>
    95    
     95    <!-- -->
    9696    <xsl:variable name="iiifImageRootIdentifier">
    9797      <xsl:text>/gs-cantaloupe/iiif/2/</xsl:text><xsl:value-of select="$site_name"/>:<xsl:value-of select="$collNameChecked"/>:<xsl:value-of select="$identifier"/>
     
    100100    <!-- page/pageRequest[@baseURL]="//intermuse.sowemustthink.space/greenstone3/ -->
    101101    <!-- 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    
     102    <!-- ***** need to work out domain name to use from raw XML message, say processing something from the above -->   
    105103    <xsl:variable name="window-location-origin">https://intermuse.sowemustthink.space</xsl:variable>
    106104
     
    112110      </xsl:choose>
    113111    </xsl:variable>
    114 
    115 
    116112    <xsl:variable name="chosenTitle">
    117113      <xsl:choose>
     
    122118      </xsl:choose>
    123119    </xsl:variable>
    124 
    125120    <!-- The following is useful for debugging, nested in 'pre' tags -->
    126121    <!--
     
    137132    -->
    138133    <!-- 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 -->
     134    <!-- add a comma first, if it is not the first canvas element in the array -->
    140135      <xsl:if test="$section &gt; 1">
    141       ,
     136          ,
    142137      </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               &quot;width&quot;:  <gsf:metadata name="ImageWidth"/>,
    152               &quot;height&quot;: <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": {
    162             "@id":     "<xsl:value-of select="$window-location-origin" /><xsl:value-of select="$iiifImageRootIdentifier" />/full/full/0/default.jpg",
    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",
    169               "@id":      "<xsl:value-of select="$window-location-origin" /><xsl:value-of select="$iiifImageRootIdentifier" />",
    170               "profile":  "https://iiif.io/api/image/2/profiles/level2.json"
    171             }
    172           }
    173         }
    174           }],
    175           "thumbnail": {
    176             "@id":   "<xsl:value-of select="$window-location-origin" /><xsl:value-of select="$iiifImageRootIdentifier" />/full/,150/0/default.jpg",
    177         "@type": "dctypes:Image"
    178           }
     138            {
     139              "@context": "http://iiif.io/api/presentation/2/context.json",
     140              "@id"     : "<xsl:value-of select="$iiifPresentationRootIdentifier" />/canvas/<xsl:value-of select="$section"/>",
     141              "@type"   : "sc:Canvas",
     142              "label"   : "<xsl:value-of select="$chosenTitle"/>",
     143              <xsl:call-template name="iiif-other-content">
     144                <xsl:with-param name="optSection"><xsl:value-of select="$optSection"/></xsl:with-param>
     145              </xsl:call-template>
     146              "width"   : <gsf:metadata name="ImageWidth"/>,
     147              "height"  : <gsf:metadata name="ImageHeight"/>,             
     148              "images": [{
     149                  "@context":   "http://iiif.io/api/image/2/context.json",
     150                  "@id":        "<xsl:value-of select="$iiifPresentationRootIdentifier" />/annotation/<xsl:value-of select="$section"/>",
     151                  "@type":      "oa:Annotation",
     152                  "motivation": "sc:painting",
     153                  "on":         "<xsl:value-of select="$iiifPresentationRootIdentifier" />/canvas",
     154                  "resource": {
     155                    "@id":     "<xsl:value-of select="$window-location-origin" /><xsl:value-of select="$iiifImageRootIdentifier" />/full/full/0/default.jpg",
     156                    "@type":   "dctypes:Image",
     157                    "format":  "image/jpeg",
     158                    "width":   <gsf:metadata name="ImageWidth"/>,
     159                    "hieght":  <gsf:metadata name="ImageHeight"/>,
     160                    "service": {
     161                      "@context": "http://iiif.io/api/image/2/context.json",
     162                      "@id":      "<xsl:value-of select="$window-location-origin" /><xsl:value-of select="$iiifImageRootIdentifier" />",
     163                      "profile":  "https://iiif.io/api/image/2/profiles/level2.json"
     164                    }
     165                }
     166              }],
     167              "thumbnail": {
     168                "@id":   "<xsl:value-of select="$window-location-origin" /><xsl:value-of select="$iiifImageRootIdentifier" />/full/,150/0/default.jpg",
     169                "@type": "dctypes:Image"
     170              }
    179171            }     
    180172    <!-- Another field to consider in the above JSON is: -->
     
    207199    <xsl:variable name="toplevelChosenTitle">
    208200      <xsl:choose>
    209     <xsl:when test="@docType='simple'">
     201        <xsl:when test="@docType='simple'">
    210202      <xsl:call-template name="choose-title"/>
    211203    </xsl:when>
     
    219211    {
    220212        "@context": "http://iiif.io/api/presentation/2/context.json",
    221     "@type": "sc:Manifest",
    222     "@id": "<xsl:value-of select="$iiifPresentationRootIdentifier"/>/manifest",
    223     "label": "<xsl:value-of select="$toplevelChosenTitle"/>",
    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",
     213        "@type": "sc:Manifest",
     214        "@id": "<xsl:value-of select="$iiifPresentationRootIdentifier"/>/manifest",
     215        "label": "<xsl:value-of select="$toplevelChosenTitle"/>",
     216        "attribution": "The Internet of Musical Events (InterMusE): Digital Scholarship, Community, and the Archiving of Performance",
     217        "license": "https://**** To Be Determined ****",
     218        "logo": "https://intermuse.datatodata.org/wp-content/uploads/sites/4/2021/03/cropped-cropped-cropped-1.png",
    227219        "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",
     220          { "label": "creator", "value": ["aaa1","aaa2"] },
     221          { "label": "title", "value": ["chosen-title"] }
     222        ],
     223        <!-- trival IIIF sequences => has one IIIF canvas in it -->
     224        "sequences": [{
     225          "@context": "http://iiif.io/api/image/2/context.json",
    234226          "@id": "<xsl:value-of select="$iiifPresentationRootIdentifier"/>/sequence/normal",
    235227          "@type": "sc:Sequence",
    236       "canvases": [
    237 
     228          "canvases": [
    238229  </xsl:template>
    239230     
     
    264255    <xsl:if test="documentNode">
    265256      <xsl:for-each select="documentNode">
    266     <xsl:call-template name="wrapDocumentNodes"/>
     257        <xsl:call-template name="wrapDocumentNodes"/>
    267258      </xsl:for-each>
    268259    </xsl:if>
     
    281272    }]   
    282273    }       
    283    
    284274  </xsl:template>
    285275
Note: See TracChangeset for help on using the changeset viewer.