]> Lady’s Gitweb - Shushe/blob - lib/catalog2transform.xslt
2c555e32c189c0ade8b54990a7ed439910f40b46
[Shushe] / lib / catalog2transform.xslt
1 <?xml version="1.0"?>
2 <!--
3 SPDX-FileCopyrightText: 2023, 2024 Lady <https://www.ladys.computer/about/#lady>
4 SPDX-License-Identifier: MPL-2.0
5 -->
6 <!--
7 ⁌ ⛩📰 书社 ∷ lib/catalog2transform.xslt
8
9 © 2023–2024 Lady [@ Ladys Computer].
10
11 This Source Code Form is subject to the terms of the Mozilla Public License, v 2.0.
12 If a copy of the M·P·L was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
13 -->
14 <!DOCTYPE transform [
15 <!ENTITY 书社 "urn:fdc:ladys.computer:20231231:Shu1She4">
16 <!ENTITY xml "http://www.w3.org/XML/1998/namespace">
17 ]>
18 <transform
19 xmlns="http://www.w3.org/1999/XSL/Transform"
20 xmlns:catalog="urn:oasis:names:tc:entity:xmlns:xml:catalog"
21 xmlns:exsl="http://exslt.org/common"
22 xmlns:exslstr="http://exslt.org/strings"
23 xmlns:html="http://www.w3.org/1999/xhtml"
24 xmlns:nie="http://www.semanticdesktop.org/ontologies/2007/01/19/nie#"
25 xmlns:nfo="http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#"
26 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
27 xmlns:svg="http://www.w3.org/2000/svg"
28 xmlns:xlink="http://www.w3.org/1999/xlink"
29 xmlns:xslt="http://www.w3.org/1999/XSL/TransformAlias"
30 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
31 xmlns:书社vocab="urn:fdc:ladys.computer:20231231:Shu1She4:vocab:"
32 exclude-result-prefixes="catalog"
33 version="1.0"
34 >
35 <include href="literally.xslt"/>
36 <namespace-alias stylesheet-prefix="xslt" result-prefix="#default"/>
37 <param name="METADATA" select="'about:blank'"/>
38 <variable name="builddir" select="document($METADATA)//书社vocab:BuildDirectory/@nfo:fileUrl"/>
39 <template match="/">
40 <variable name="ids">
41 <for-each select="//catalog:uri[@name]">
42 <书社:id>
43 <value-of select="@name"/>
44 </书社:id>
45 </for-each>
46 </variable>
47 <variable name="unique-ids">
48 <for-each select="exsl:node-set($ids)/*">
49 <if test="not(preceding-sibling::*[string(.)=string(current())])">
50 <copy-of select="."/>
51 </if>
52 </for-each>
53 </variable>
54 <xslt:transform exclude-result-prefixes="nie nfo" extension-element-prefixes="exsl exslstr" version="1.0">
55 <xslt:param name="BUILDTIME" select="'1972-12-31T00:00:00Z'"/>
56 <xslt:param name="IDENTIFIER" select="false()"/>
57 <xslt:param name="SRCREV" select="false()"/>
58 <xslt:param name="THISREV" select="false()"/>
59 <xslt:variable name="书社:source" select="/"/>
60 <xslt:variable name="书社:about-fragment">
61 <apply-templates select="document($METADATA)" mode="书社:literally">
62 <with-param name="extension-element-namespaces" select="'http://exslt.org/common http://exslt.org/strings'"/>
63 </apply-templates>
64 </xslt:variable>
65 <xslt:variable name="书社:about" select="exsl:node-set($书社:about-fragment)"/>
66 <xslt:variable name="书社:expansion-fragment">
67 <xslt:apply-templates select="$书社:source/node()" mode="书社:expand"/>
68 </xslt:variable>
69 <xslt:variable name="书社:expansion" select="exsl:node-set($书社:expansion-fragment)"/>
70 <xslt:variable name="书社:result-fragment">
71 <xslt:apply-templates select="$书社:expansion/node()"/>
72 </xslt:variable>
73 <xslt:variable name="书社:result" select="exsl:node-set($书社:result-fragment)"/>
74 <xslt:variable name="书社:destination" select="string($书社:about//*[@rdf:about=$IDENTIFIER]/@书社vocab:destination)"/>
75 <for-each select="//catalog:uri">
76 <xslt:include href="{@uri}">
77 <attribute name="书社:id">
78 <value-of select="@name"/>
79 </attribute>
80 </xslt:include>
81 </for-each>
82 <xslt:template name="书社:apply-attributes">
83 <xslt:param name="and-version" select="false()"/>
84 <xslt:param name="context-nodes" select="/.."/>
85 <xslt:param name="destination-nodes" select="/.."/>
86 <xslt:variable name="additional-attributes" select="$context-nodes/@*"/>
87 <xslt:for-each select="$destination-nodes">
88 <xslt:variable name="existing-attributes" select="@*"/>
89 <xslt:choose>
90 <xslt:when test="self::*">
91 <xslt:variable name="context" select="."/>
92 <xslt:variable name="attribute-names">
93 <xslt:for-each select="$existing-attributes|$additional-attributes">
94 <书社:attribute>
95 <attribute name="local-name">
96 <text>{local-name()}</text>
97 </attribute>
98 <attribute name="name">
99 <text>{name()}</text>
100 </attribute>
101 <attribute name="namespace-uri">
102 <text>{namespace-uri()}</text>
103 </attribute>
104 </书社:attribute>
105 </xslt:for-each>
106 </xslt:variable>
107 <xslt:variable name="lang">
108 <xslt:choose>
109 <xslt:when test="(self::html:*|self::svg:*)/@lang">
110 <xslt:value-of select="@lang"/>
111 </xslt:when>
112 <xslt:when test="@xml:lang">
113 <xslt:value-of select="@xml:lang"/>
114 </xslt:when>
115 <xslt:when test="$additional-attributes[(parent::html:* or parent::svg:*) and namespace-uri()='' and local-name()='lang']">
116 <xslt:value-of select="$additional-attributes[(parent::html:* or parent::svg:*) and namespace-uri()='' and local-name()='lang']"/>
117 </xslt:when>
118 <xslt:when test="(self::html:* or self::svg:*) and $additional-attributes[(parent::书社:apply-attributes or parent::书社:apply-attributes-to-root) and namespace-uri()='' and local-name()='lang']">
119 <xslt:value-of select="$additional-attributes[(parent::书社:apply-attributes or parent::书社:apply-attributes-to-root) and namespace-uri()='' and local-name()='lang']"/>
120 </xslt:when>
121 <xslt:when test="$additional-attributes[namespace-uri()='&xml;' and local-name()='lang']">
122 <xslt:value-of select="$additional-attributes[namespace-uri()='&xml;' and local-name()='lang']"/>
123 </xslt:when>
124 </xslt:choose>
125 </xslt:variable>
126 <xslt:copy>
127 <xslt:if test="$and-version and $THISREV">
128 <xslt:attribute name="书社:version">
129 <xslt:value-of select="$THISREV"/>
130 </xslt:attribute>
131 </xslt:if>
132 <xslt:if test="string($lang)!=''">
133 <xslt:if test="self::html:* or self::svg:*">
134 <xslt:attribute name="lang">
135 <xslt:value-of select="$lang"/>
136 </xslt:attribute>
137 </xslt:if>
138 <xslt:attribute name="xml:lang">
139 <xslt:value-of select="$lang"/>
140 </xslt:attribute>
141 </xslt:if>
142 <xslt:for-each select="exsl:node-set($attribute-names)/*">
143 <xslt:choose>
144 <xslt:when test="@namespace-uri='&xml;'"/>
145 <xslt:when test="$context[self::html:* or self::svg:*] and @namespace-uri='' and @local-name='lang'"/>
146 <xslt:when test="@namespace-uri='&书社;' and @local-name='archived-as' and $context-nodes/ancestor::*[not(self::书社:apply-attributes-to-root or self::书社:apply-attributes)][position()=1 and not(self::书社:archive)]"/>
147 <xslt:when test="@namespace-uri='&书社;' and (@local-name='destination' or @local-name='disable-output-wrapping' or @local-name='version')"/>
148 <xslt:when test="preceding-sibling::*[@local-name=current()/@local-name and @namespace-uri=current()/@namespace-uri]"/>
149 <xslt:otherwise>
150 <xslt:attribute>
151 <attribute name="name">
152 <text>{@name}</text>
153 </attribute>
154 <attribute name="namespace">
155 <text>{@namespace-uri}</text>
156 </attribute>
157 <xslt:for-each select="$existing-attributes[local-name()=current()/@local-name and namespace-uri()=current()/@namespace-uri]">
158 <xslt:value-of select="."/>
159 <xslt:if test="position()!=last()">
160 <xslt:text>
161 <text> </text>
162 </xslt:text>
163 </xslt:if>
164 </xslt:for-each>
165 <xslt:if test="$existing-attributes[local-name()=current()/@local-name and namespace-uri()=current()/@namespace-uri] and $additional-attributes[local-name()=current()/@local-name and namespace-uri()=current()/@namespace-uri]">
166 <xslt:text>
167 <text> </text>
168 </xslt:text>
169 </xslt:if>
170 <xslt:for-each select="$additional-attributes[local-name()=current()/@local-name and namespace-uri()=current()/@namespace-uri]">
171 <xslt:value-of select="."/>
172 <xslt:if test="position()!=last()">
173 <xslt:text>
174 <text> </text>
175 </xslt:text>
176 </xslt:if>
177 </xslt:for-each>
178 </xslt:attribute>
179 </xslt:otherwise>
180 </xslt:choose>
181 </xslt:for-each>
182 <xslt:copy-of select="node()"/>
183 </xslt:copy>
184 </xslt:when>
185 <xslt:otherwise>
186 <xslt:copy-of select="."/>
187 </xslt:otherwise>
188 </xslt:choose>
189 </xslt:for-each>
190 </xslt:template>
191 <xslt:template name="书社:wrap">
192 <xslt:param name="nodes" select="/.."/>
193 <xslt:variable name="modalinput-fragment">
194 <xslt:copy-of select="$nodes"/>
195 <apply-templates select="exsl:node-set($unique-ids)" mode="书社:literally"/>
196 </xslt:variable>
197 <xslt:variable name="modalinput" select="exsl:node-set($modalinput-fragment)"/>
198 <xslt:variable name="metadata-fragment">
199 <xslt:copy-of select="$nodes[self::html:html]/html:head/node()|$nodes[self::html:head]/node()"/>
200 <xslt:apply-templates select="$modalinput/node()" mode="书社:metadata"/>
201 </xslt:variable>
202 <xslt:variable name="metadata" select="exsl:node-set($metadata-fragment)"/>
203 <html:html>
204 <xslt:copy-of select="$nodes[self::html:html]/@*"/>
205 <xslt:if test="not($nodes[self::html:html]/@书社:archived-as) and $nodes/@书社:archived-as">
206 <xslt:attribute name="书社:archived-as">
207 <xslt:value-of select="$nodes/@书社:archived-as"/>
208 </xslt:attribute>
209 </xslt:if>
210 <xslt:if test="not($nodes[self::html:html]/@lang) and $nodes[self::html:*]/@lang|$nodes[self::svg:*]/@lang|$nodes/@xml:lang">
211 <xslt:attribute name="lang">
212 <xslt:value-of select="$nodes[self::html:*]/@lang|$nodes[self::svg:*]/@lang|$nodes/@xml:lang"/>
213 </xslt:attribute>
214 </xslt:if>
215 <xslt:if test="not($nodes[self::html:html]/@xml:lang) and $nodes[self::html:*]/@lang|$nodes[self::svg:*]/@lang|$nodes/@xml:lang">
216 <xslt:attribute name="xml:lang">
217 <xslt:value-of select="$nodes[self::html:*]/@lang|$nodes[self::svg:*]/@lang|$nodes/@xml:lang"/>
218 </xslt:attribute>
219 </xslt:if>
220 <html:head>
221 <xslt:copy-of select="$nodes[self::html:html]/html:head/@*|$nodes[self::html:head]/@*"/>
222 <html:title>
223 <xslt:for-each select="$metadata/html:title">
224 <xslt:value-of select="."/>
225 <xslt:if test="position()!=last()">
226 <xslt:text>
227 <text> </text>
228 </xslt:text>
229 </xslt:if>
230 </xslt:for-each>
231 </html:title>
232 <xslt:copy-of select="$metadata/node()[not(self::html:title or self::html:meta and @name='generator')]"/>
233 <html:meta name="generator">
234 <xslt:attribute name="content">
235 <xslt:for-each select="$metadata/html:meta[@name='generator']">
236 <xslt:value-of select="@content"/>
237 <xslt:text>
238 <text>, </text>
239 </xslt:text>
240 </xslt:for-each>
241 <xslt:text>
242 <text>⛩📰 书社</text>
243 </xslt:text>
244 <xslt:if test="$THISREV">
245 <xslt:text>
246 <text> (</text>
247 </xslt:text>
248 <xslt:value-of select="$THISREV"/>
249 <xslt:text>
250 <text>)</text>
251 </xslt:text>
252 </xslt:if>
253 </xslt:attribute>
254 </html:meta>
255 </html:head>
256 <html:body>
257 <xslt:copy-of select="$nodes[self::html:html]/html:body/@*|$nodes[self::html:body]/@*"/>
258 <xslt:apply-templates select="$modalinput/node()" mode="书社:header"/>
259 <xslt:copy-of select="$nodes[not(self::html:html or self::html:head or self::html:body)]|$nodes[self::html:html]/node()[not(self::html:head or self::html:body)]|$nodes[self::html:html]/html:body/node()|$nodes[self::html:body]/node()"/>
260 <xslt:apply-templates select="$modalinput/node()" mode="书社:footer"/>
261 </html:body>
262 </html:html>
263 </xslt:template>
264 <xslt:template match="/" priority="1">
265 <xslt:variable name="result-nodes" select="$书社:result/node()[not(self::书社:apply-attributes-to-root)]|$书社:result/书社:apply-attributes-to-root//node()[not(self::书社:apply-attributes-to-root) and not(ancestor::*[not(self::书社:apply-attributes-to-root)])]"/>
266 <xslt:variable name="significant-nodes" select="$result-nodes/descendant-or-self::*[not(self::书社:apply-attributes) and not(ancestor::*[not(self::书社:apply-attributes)])]"/>
267 <xslt:variable name="root-with-attributes">
268 <xslt:choose>
269 <xslt:when test="not($significant-nodes/self::html:*) or $significant-nodes/self::书社:*[local-name()='raw-text' or local-name()='base64-binary' or local-name()='archive'] or $significant-nodes/@书社:disable-output-wrapping or $书社:result//书社:apply-attributes-to-root/@书社:disable-output-wrapping">
270 <xslt:call-template name="书社:apply-attributes">
271 <xslt:with-param name="and-version" select="true()"/>
272 <xslt:with-param name="context-nodes" select="$书社:result//书社:apply-attributes-to-root"/>
273 <xslt:with-param name="destination-nodes" select="$result-nodes"/>
274 </xslt:call-template>
275 </xslt:when>
276 <xslt:otherwise>
277 <xslt:variable name="wrapped-result">
278 <xslt:call-template name="书社:wrap">
279 <xslt:with-param name="nodes" select="$result-nodes"/>
280 </xslt:call-template>
281 </xslt:variable>
282 <xslt:call-template name="书社:apply-attributes">
283 <xslt:with-param name="and-version" select="true()"/>
284 <xslt:with-param name="context-nodes" select="$书社:result//书社:apply-attributes-to-root"/>
285 <xslt:with-param name="destination-nodes" select="exsl:node-set($wrapped-result)/node()"/>
286 </xslt:call-template>
287 </xslt:otherwise>
288 </xslt:choose>
289 </xslt:variable>
290 <xslt:apply-templates select="exsl:node-set($root-with-attributes)/node()" mode="书社:apply"/>
291 </xslt:template>
292 <xslt:template match="@*|node()" priority="-1">
293 <xslt:copy>
294 <xslt:apply-templates select="@*|node()"/>
295 </xslt:copy>
296 </xslt:template>
297 <xslt:template match="@书社:destination|@书社:disable-output-wrapping|@书社:archived-as[../ancestor::*[not(self::书社:apply-attributes-to-root or self::书社:apply-attributes)]]" mode="书社:apply" priority="1"/>
298 <xslt:template match="书社:archive" mode="书社:apply" priority="1">
299 <xslt:copy>
300 <xslt:for-each select="@*">
301 <xslt:choose>
302 <xslt:when test="local-name()='archived-as' and namespace-uri()='&书社;' and ../ancestor::*[not(self::书社:apply-attributes-to-root or self::书社:apply-attributes)]"/>
303 <xslt:otherwise>
304 <xslt:apply-templates select="." mode="书社:apply"/>
305 </xslt:otherwise>
306 </xslt:choose>
307 </xslt:for-each>
308 <xslt:for-each select="node()">
309 <xslt:choose>
310 <xslt:when test="self::*">
311 <xslt:variable name="component-fragment">
312 <xslt:copy>
313 <xslt:choose>
314 <xslt:when test="self::html:*">
315 <xslt:variable name="existing-types" select="exslstr:tokenize(@itemtype)"/>
316 <xslt:attribute name="itemscope">itemscope</xslt:attribute>
317 <xslt:attribute name="itemtype">
318 <xslt:for-each select="$existing-types/token">
319 <xslt:if test="position()!=1">
320 <xslt:text>
321 <text> </text>
322 </xslt:text>
323 </xslt:if>
324 <xslt:value-of select="."/>
325 </xslt:for-each>
326 <xslt:if test="not($existing-types/token[string()='&书社;:embed' or string()='&书社;:document'])">
327 <xslt:if test="$existing-types/token">
328 <xslt:text>
329 <text> </text>
330 </xslt:text>
331 </xslt:if>
332 <xslt:text>
333 <text>&书社;:document</text>
334 </xslt:text>
335 </xslt:if>
336 </xslt:attribute>
337 <xslt:copy-of select="@*[not(namespace-uri()='' and (local-name()='itemscope' or local-name()='itemtype'))]|node()"/>
338 </xslt:when>
339 <xslt:otherwise>
340 <xslt:copy-of select="@*|node()"/>
341 </xslt:otherwise>
342 </xslt:choose>
343 </xslt:copy>
344 </xslt:variable>
345 <xslt:variable name="wrapped-component-fragment">
346 <xslt:for-each select="exsl:node-set($component-fragment)/*">
347 <xslt:variable name="result-nodes" select="self::*[not(self::书社:apply-attributes-to-root)]|self::书社:apply-attributes-to-root//node()[not(self::书社:apply-attributes-to-root) and not(ancestor::*[not(self::书社:apply-attributes-to-root)])]"/>
348 <xslt:variable name="significant-nodes" select="$result-nodes/descendant-or-self::*[not(self::书社:apply-attributes) and not(ancestor::*[not(self::书社:apply-attributes)])]"/>
349 <xslt:choose>
350 <xslt:when test="not($significant-nodes/self::html:*) or $significant-nodes/self::书社:*[local-name()='raw-text' or local-name()='base64-binary' or local-name()='archive'] or $significant-nodes/@书社:disable-output-wrapping">
351 <xslt:copy-of select="."/>
352 </xslt:when>
353 <xslt:otherwise>
354 <xslt:call-template name="书社:wrap">
355 <xslt:with-param name="nodes" select="$result-nodes"/>
356 </xslt:call-template>
357 </xslt:otherwise>
358 </xslt:choose>
359 </xslt:for-each>
360 </xslt:variable>
361 <xslt:apply-templates select="exsl:node-set($wrapped-component-fragment)/node()" mode="书社:apply"/>
362 </xslt:when>
363 <xslt:otherwise>
364 <xslt:apply-templates select="." mode="书社:apply"/>
365 </xslt:otherwise>
366 </xslt:choose>
367 </xslt:for-each>
368 </xslt:copy>
369 </xslt:template>
370 <xslt:template match="书社:apply-attributes" mode="书社:apply" priority="1">
371 <xslt:variable name="children">
372 <xslt:apply-templates mode="书社:apply"/>
373 </xslt:variable>
374 <xslt:call-template name="书社:apply-attributes">
375 <xslt:with-param name="context-nodes" select="."/>
376 <xslt:with-param name="destination-nodes" select="exsl:node-set($children)/node()"/>
377 </xslt:call-template>
378 </xslt:template>
379 <xslt:template match="书社:apply-attributes-to-root" mode="书社:apply" priority="1">
380 <xslt:apply-templates mode="书社:apply"/>
381 </xslt:template>
382 <xslt:template match="@*|node()" mode="书社:apply" priority="-1">
383 <xslt:copy>
384 <xslt:apply-templates select="@*|node()" mode="书社:apply"/>
385 </xslt:copy>
386 </xslt:template>
387 <xslt:template match="书社:link[@xlink:show='embed' and (not(@xlink:actuate) or @xlink:actuate='none')]" mode="书社:expand" priority="1">
388 <xslt:variable name="link" select="."/>
389 <xslt:variable name="identifier" select="string(@xlink:href)"/>
390 <xslt:variable name="is-dir" select="substring($identifier, string-length($identifier))='/'"/>
391 <xslt:variable name="included" select="$书社:about//*[@rdf:about=$identifier or $is-dir and starts-with(@rdf:about, $identifier)]"/>
392 <xslt:choose>
393 <xslt:when test="$included">
394 <xslt:for-each select="$included">
395 <xslt:sort select="@rdf:about" data-type="text" lang="zxx" case-order="upper-first"/>
396 <xslt:variable name="uri" select="书社vocab:hasParsedFile/@nfo:fileUrl"/>
397 <xslt:variable name="expanded">
398 <xslt:apply-templates select="document($uri)" mode="书社:expand">
399 <xslt:with-param name="identifier" select="string(@rdf:about)"/>
400 </xslt:apply-templates>
401 </xslt:variable>
402 <xslt:for-each select="exsl:node-set($expanded)/node()">
403 <xslt:copy>
404 <xslt:choose>
405 <xslt:when test="self::html:*">
406 <xslt:variable name="existing-types" select="exslstr:tokenize(@itemtype)"/>
407 <xslt:attribute name="itemscope">itemscope</xslt:attribute>
408 <xslt:attribute name="itemtype">
409 <xslt:for-each select="$existing-types/token[string()!='&书社;:document']">
410 <xslt:if test="position()!=1">
411 <xslt:text>
412 <text> </text>
413 </xslt:text>
414 </xslt:if>
415 <xslt:value-of select="."/>
416 </xslt:for-each>
417 <xslt:if test="not($existing-types/token[string()='&书社;:embed'])">
418 <xslt:if test="$existing-types/token[string()!='&书社;:document']">
419 <xslt:text>
420 <text> </text>
421 </xslt:text>
422 </xslt:if>
423 <xslt:text>
424 <text>&书社;:embed</text>
425 </xslt:text>
426 </xslt:if>
427 </xslt:attribute>
428 <xslt:choose>
429 <xslt:when test="$link/@书社:archived-as">
430 <xslt:copy-of select="$link/@书社:archived-as"/>
431 </xslt:when>
432 <xslt:when test="@书社:archived-as">
433 <xslt:copy-of select="@书社:archived-as"/>
434 </xslt:when>
435 </xslt:choose>
436 <xslt:copy-of select="@*[not(namespace-uri()='' and (local-name()='itemscope' or local-name()='itemtype')) and not(namespace-uri()='&书社;' and local-name()='archived-as')]|node()"/>
437 </xslt:when>
438 <xslt:otherwise>
439 <xslt:choose>
440 <xslt:when test="self::* and $link/@书社:archived-as">
441 <xslt:copy-of select="$link/@书社:archived-as"/>
442 </xslt:when>
443 <xslt:when test="@书社:archived-as">
444 <xslt:copy-of select="@书社:archived-as"/>
445 </xslt:when>
446 </xslt:choose>
447 <xslt:copy-of select="@*[not(namespace-uri()='&书社;' and local-name()='archived-as')]|node()"/>
448 </xslt:otherwise>
449 </xslt:choose>
450 </xslt:copy>
451 </xslt:for-each>
452 </xslt:for-each>
453 </xslt:when>
454 <xslt:otherwise>
455 <xslt:copy>
456 <xslt:apply-templates select="@*|node()" mode="书社:expand"/>
457 </xslt:copy>
458 </xslt:otherwise>
459 </xslt:choose>
460 </xslt:template>
461 <xslt:template match="/node()" mode="书社:expand" priority="0">
462 <xslt:param name="identifier" select="$IDENTIFIER"/>
463 <xslt:copy>
464 <xslt:if test="self::*">
465 <xslt:attribute name="书社:cksum">
466 <xslt:value-of select="$书社:about//*[@rdf:about=$identifier]/nfo:hasHash[@nfo:hashAlgorithm='CRC32']/@nfo:hashValue"/>
467 </xslt:attribute>
468 <xslt:attribute name="书社:identifier">
469 <xslt:value-of select="$identifier"/>
470 </xslt:attribute>
471 <xslt:attribute name="书社:mtime">
472 <xslt:value-of select="$书社:about//*[@rdf:about=$identifier]/nfo:fileLastModified"/>
473 </xslt:attribute>
474 </xslt:if>
475 <xslt:choose>
476 <xslt:when test="self::html:*">
477 <xslt:variable name="existing-types" select="exslstr:tokenize(@itemtype)"/>
478 <xslt:attribute name="itemscope">itemscope</xslt:attribute>
479 <xslt:attribute name="itemtype">
480 <xslt:for-each select="$existing-types/token">
481 <xslt:if test="position()!=1">
482 <xslt:text>
483 <text> </text>
484 </xslt:text>
485 </xslt:if>
486 <xslt:value-of select="."/>
487 </xslt:for-each>
488 <xslt:if test="not($existing-types/token[string()='&书社;:embed' or string()='&书社;:document'])">
489 <xslt:if test="$existing-types/token">
490 <xslt:text>
491 <text> </text>
492 </xslt:text>
493 </xslt:if>
494 <xslt:text>
495 <text>&书社;:document</text>
496 </xslt:text>
497 </xslt:if>
498 </xslt:attribute>
499 <xslt:apply-templates select="@*[not(namespace-uri()='' and (local-name()='itemscope' or local-name()='itemtype') or namespace-uri()='&书社;' and (local-name()='cksum' or local-name()='identifier' or local-name()='mtime'))]|node()" mode="书社:expand"/>
500 </xslt:when>
501 <xslt:otherwise>
502 <xslt:apply-templates select="@*[not(namespace-uri()='&书社;' and (local-name()='cksum' or local-name()='identifier' or local-name()='mtime'))]|node()" mode="书社:expand"/>
503 </xslt:otherwise>
504 </xslt:choose>
505 </xslt:copy>
506 </xslt:template>
507 <xslt:template match="@*|node()" mode="书社:expand" priority="-1">
508 <xslt:copy>
509 <xslt:apply-templates select="@*|node()" mode="书社:expand"/>
510 </xslt:copy>
511 </xslt:template>
512 <xslt:template match="text()" mode="书社:header"/>
513 <xslt:template match="text()" mode="书社:footer"/>
514 <xslt:template match="text()" mode="书社:metadata"/>
515 <xslt:output method="xml" encoding="UTF-8" cdata-section-elements="html:script html:style html:textarea 书社:raw-output 书社:raw-text"/>
516 </xslt:transform>
517 </template>
518 <output method="xml" encoding="UTF-8"/>
519 </transform>
This page took 0.072557 seconds and 3 git commands to generate.