|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?>
|
2 | 2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:rng="http://relaxng.org/ns/structure/1.0" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" exclude-result-prefixes="xs tei" version="3.0">
|
| 3 | + <xsl:param name="output-result-document" select="'yes'"/><!-- set to 'yes' to use <result-document> --> |
3 | 4 | <xsl:output indent="no" omit-xml-declaration="yes" method="text" encoding="utf-8" />
|
4 |
| - <xsl:variable name="schemaFile" select="doc('../schemas/manuscripta.rng')"/> |
| 5 | + <xsl:variable name="schemaFile" select="if ($output-result-document='yes') then doc('../schemas/manuscripta.rng') else doc('../data/schemas/manuscripta.rng')"/> |
| 6 | + <xsl:variable name="iiifFolder"> |
| 7 | + <xsl:text>../../../../iiif/test2/</xsl:text> |
| 8 | + </xsl:variable> |
5 | 9 | <xsl:template match="/">
|
6 | 10 | <xsl:apply-templates />
|
7 | 11 | </xsl:template>
|
8 | 12 | <xsl:template match="tei:TEI">
|
9 | 13 | <xsl:variable name="repository" select="//tei:repository" />
|
10 | 14 | <xsl:variable name="msID" select="substring-after(@xml:id,'ms-')" />
|
11 |
| - <xsl:variable name="baseURL" select="//tei:facsimile/@xml:base"/> |
| 15 | + <!-- URI encode trailing slash in @xml:base as required by the IIIF Image API specification (https://iiif.io/api/image/2.0/#uri-encoding-and-decoding) --> |
| 16 | + <xsl:variable name="baseURL" select="concat(substring(//tei:facsimile/@xml:base, 1, string-length(//tei:facsimile/@xml:base)-1), '%2F')"/> |
12 | 17 | <!-- variables for metadata -->
|
13 | 18 | <xsl:variable name="shelfmark" select="//tei:idno[@type = 'shelfmark']" />
|
14 | 19 | <xsl:variable name="head" select="//tei:msDesc/tei:head/normalize-space()" />
|
|
57 | 62 | <xsl:variable name="first-folio" select="//tei:facsimile/(tei:surface[matches(@xml:id, '^ms-\d{6}(_\d{4})?_\dr?$')][1] | tei:surface[matches(@xml:id, '^ms-\d{6}(_\d{4})?_S?\dr?$')][1] | tei:surface[1])[last()]/tei:graphic/@url" />
|
58 | 63 | <xsl:variable name="first-folio-id" select="translate($first-folio, '.tif', '')" />
|
59 | 64 | <xsl:variable name="start-canvas" select="count(//tei:surface[following-sibling::tei:surface/tei:graphic[@url = $first-folio]])"/>
|
60 |
| - <xsl:if test="exists(//tei:facsimile)"><xsl:result-document href="{concat('../../../../iiif/temp/',$msID,'/manifest.json')}">{ |
| 65 | + <xsl:variable name="result-document-path" select="if ($output-result-document='yes') then concat($iiifFolder,$msID,'/manifest.json') else ()"/> |
| 66 | + <xsl:if test="exists(//tei:facsimile)"><xsl:result-document href="{$result-document-path}">{ |
61 | 67 | "@context": "http://iiif.io/api/presentation/2/context.json",
|
62 | 68 | "@id": "https://www.manuscripta.se/iiif/<xsl:value-of select="$msID" />/manifest.json",
|
63 | 69 | "@type": "sc:Manifest",
|
|
97 | 103 | "@id": "https://www.manuscripta.se/iiif/<xsl:value-of select="$msID" />/canvas/c-<xsl:value-of select="$start-canvas + 1"/>.json",
|
98 | 104 | "service": {
|
99 | 105 | "@context": "http://iiif.io/api/image/2/context.json",
|
100 |
| - "@id": "<xsl:value-of select="$baseURL" /><xsl:value-of select="$msID" />/<xsl:value-of select="$first-folio" />", |
| 106 | + "@id": "<xsl:value-of select="$baseURL" /><xsl:value-of select="$first-folio" />", |
101 | 107 | "profile": "http://iiif.io/api/image/2/level1.json"
|
102 | 108 | }
|
103 | 109 | },
|
|
132 | 138 | "height": <xsl:value-of select="$height" />,
|
133 | 139 | "width": <xsl:value-of select="$width" />,
|
134 | 140 | "thumbnail": {
|
135 |
| - "@id": "<xsl:value-of select="$baseURL" /><xsl:value-of select="$msID" />/<xsl:value-of select="$image" />/full/90,/0/default.jpg", |
| 141 | + "@id": "<xsl:value-of select="$baseURL" /><xsl:value-of select="$image" />/full/90,/0/default.jpg", |
136 | 142 | "service": {
|
137 | 143 | "@context": "http://iiif.io/api/image/2/context.json",
|
138 |
| - "@id": "<xsl:value-of select="$baseURL" /><xsl:value-of select="$msID" />/<xsl:value-of select="$image" />", |
| 144 | + "@id": "<xsl:value-of select="$baseURL" /><xsl:value-of select="$image" />", |
139 | 145 | "profile": "http://iiif.io/api/image/2/level1.json"
|
140 | 146 | }
|
141 | 147 | },
|
|
146 | 152 | "motivation": "sc:painting",
|
147 | 153 | "on": "https://www.manuscripta.se/iiif/<xsl:value-of select="$msID" />/canvas/c-<xsl:value-of select="$count-number" />.json",
|
148 | 154 | "resource": {
|
149 |
| - "@id": "<xsl:value-of select="$baseURL" /><xsl:value-of select="$msID" />/<xsl:value-of select="$image" />/full/full/0/default.jpg", |
| 155 | + "@id": "<xsl:value-of select="$baseURL" /><xsl:value-of select="$image" />/full/full/0/default.jpg", |
150 | 156 | "@type": "dctypes:Image",
|
151 | 157 | "format": "image/jpeg",
|
152 | 158 | "height": <xsl:value-of select="$height" />,
|
153 | 159 | "width": <xsl:value-of select="$width" />,
|
154 | 160 | "service": {
|
155 | 161 | "@context": "http://iiif.io/api/image/2/context.json",
|
156 |
| - "@id": "<xsl:value-of select="$baseURL" /><xsl:value-of select="$msID" />/<xsl:value-of select="$image" />", |
| 162 | + "@id": "<xsl:value-of select="$baseURL" /><xsl:value-of select="$image" />", |
157 | 163 | "profile": "http://iiif.io/api/image/2/level1.json"
|
158 | 164 | }
|
159 | 165 | }
|
|
0 commit comments