]> Lady’s Gitweb - Shushe/blob - lib/catalog2transform.xslt
4a09235475aef4d5556f172843342bc47c5918db
[Shushe] / lib / catalog2transform.xslt
1 <?xml version="1.0"?>
2 <!--
3 ⁌ ⛩️📰 书社 ∷ lib/catalog2transform.xslt
4
5 © 2023 Lady [@ Lady’s Computer]
6
7 This Source Code Form is subject to the terms of the Mozilla Public License, v 2.0.
8 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/>.
9 -->
10 <transform
11 xmlns="http://www.w3.org/1999/XSL/Transform"
12 xmlns:html="http://www.w3.org/1999/xhtml"
13 xmlns:catalog="urn:oasis:names:tc:entity:xmlns:xml:catalog"
14 xmlns:exsl="http://exslt.org/common"
15 xmlns:xlink="http://www.w3.org/1999/xlink"
16 xmlns:xslt="http://www.w3.org/1999/XSL/TransformAlias"
17 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
18 version="1.0"
19 >
20 <namespace-alias stylesheet-prefix="xslt" result-prefix="#default"/>
21 <template match="/">
22 <xslt:transform exclude-result-prefixes="catalog exsl" version="1.0">
23 <xslt:param name="catalog" select="'catalog'"/>
24 <for-each select="//catalog:uri">
25 <xslt:include href="{@uri}"/>
26 </for-each>
27 <xslt:template match="/" priority="1">
28 <xslt:variable name="expansion">
29 <xslt:apply-templates select="." mode="书社:expand"/>
30 </xslt:variable>
31 <xslt:variable name="result">
32 <xslt:apply-templates select="exsl:node-set($expansion)/*"/>
33 </xslt:variable>
34 <xslt:variable name="metadata">
35 <xslt:copy-of select="exsl:node-set($result)/html/head/*"/>
36 <xslt:apply-templates select="exsl:node-set($result)" mode="书社:metadata"/>
37 </xslt:variable>
38 <html:html>
39 <xslt:copy-of select="exsl:node-set($result)/html:html/@*"/>
40 <html:head>
41 <xslt:copy-of select="exsl:node-set($result)/html:html/html:head/@*"/>
42 <html:title>
43 <xslt:for-each select="exsl:node-set($metadata)/html:title">
44 <xslt:value-of select="."/>
45 </xslt:for-each>
46 </html:title>
47 <xslt:copy-of select="exsl:node-set($metadata)/*[not(self::html:title)]"/>
48 <xslt:if test="not(exsl:node-set($metadata)/html:meta[@name='generator'])">
49 <html:meta name="generator" content="⛩️📰 书社"/>
50 </xslt:if>
51 </html:head>
52 <html:body>
53 <xslt:copy-of select="exsl:node-set($result)/*[not(self::html:html or self::html:body)]|exsl:node-set($result)/html:html/*[not(self::html:head or self::html:body)]|exsl:node-set($result)/html:html/html:body/*|exsl:node-set($result)/html:body/*"/>
54 </html:body>
55 </html:html>
56 </xslt:template>
57 <xslt:template match="@*|node()" priority="-1">
58 <xslt:copy>
59 <xslt:apply-templates select="@*|node()"/>
60 </xslt:copy>
61 </xslt:template>
62 <xslt:template match="书社:link[@xlink:show='embed']" mode="书社:expand">
63 <xslt:variable name="uri" select="substring-before(document($catalog)//catalog:uri[@name=current()/@xlink:href]/@uri[1], '#')"/>
64 <xslt:choose>
65 <xslt:when test="$uri">
66 <xslt:apply-templates select="document($uri)" mode="书社:expand"/>
67 </xslt:when>
68 <xslt:otherwise>
69 <xslt:copy>
70 <xslt:apply-templates select="@*|node()" mode="书社:expand"/>
71 </xslt:copy>
72 </xslt:otherwise>
73 </xslt:choose>
74 </xslt:template>
75 <xslt:template match="@*|text()|*[not(self::书社:link) or not(@xlink:show='embed')]" mode="书社:expand">
76 <xslt:copy>
77 <xslt:apply-templates select="@*|node()" mode="书社:expand"/>
78 </xslt:copy>
79 </xslt:template>
80 <xslt:template match="text()" mode="书社:metadata"/>
81 <xslt:output method="xml" encoding="UTF-8" cdata-section-elements="html:script html:style html:textarea"/>
82 </xslt:transform>
83 </template>
84 </transform>
This page took 0.04711 seconds and 3 git commands to generate.