]> Lady’s Gitweb - Shushe/blob - lib/catalog2transform.xslt
2be92185f5e4b25f57ba822f2d96805b1a81ccc5
[Shushe] / lib / catalog2transform.xslt
1 <?xml version="1.0"?>
2 <!--
3 ⁌ ⛩️📰 书社 ∷ lib/catalog2transform.xslt
4
5 © 2023–2024 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 <!DOCTYPE transform [
11 <!ENTITY 书社 "urn:fdc:ladys.computer:20231231:Shu1She4">
12 ]>
13 <transform
14 xmlns="http://www.w3.org/1999/XSL/Transform"
15 xmlns:html="http://www.w3.org/1999/xhtml"
16 xmlns:catalog="urn:oasis:names:tc:entity:xmlns:xml:catalog"
17 xmlns:exsl="http://exslt.org/common"
18 xmlns:exslstr="http://exslt.org/strings"
19 xmlns:svg="http://www.w3.org/2000/svg"
20 xmlns:xlink="http://www.w3.org/1999/xlink"
21 xmlns:xslt="http://www.w3.org/1999/XSL/TransformAlias"
22 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
23 version="1.0"
24 >
25 <namespace-alias stylesheet-prefix="xslt" result-prefix="#default"/>
26 <template match="/">
27 <xslt:transform exclude-result-prefixes="catalog exsl exslstr" version="1.0">
28 <xslt:param name="buildtime" select="'1972-12-31T00:00:00Z'"/>
29 <xslt:param name="catalog" select="'catalog'"/>
30 <xslt:param name="srctime" select="'1972-12-31T00:00:00Z'"/>
31 <xslt:param name="path" select="'/unknown'"/>
32 <xslt:variable name="书社:expansion">
33 <xslt:apply-templates select="/" mode="书社:expand"/>
34 </xslt:variable>
35 <xslt:variable name="书社:result">
36 <xslt:apply-templates select="exsl:node-set($书社:expansion)/*"/>
37 </xslt:variable>
38 <for-each select="//catalog:uri">
39 <xslt:include href="{@uri}">
40 <if test="contains(@name, ':')">
41 <attribute name="书社:id">
42 <value-of select="@name"/>
43 </attribute>
44 </if>
45 </xslt:include>
46 </for-each>
47 <xslt:template match="/" priority="1">
48 <xslt:choose>
49 <xslt:when test="exsl:node-set($书社:result)/*[@书社:disable-output-wrapping]">
50 <xslt:for-each select="exsl:node-set($书社:result)/*">
51 <xslt:copy>
52 <xslt:copy-of select="@*[not(namespace-uri()='&书社;' and local-name()='disable-output-wrapping')]|node()"/>
53 </xslt:copy>
54 </xslt:for-each>
55 </xslt:when>
56 <xslt:otherwise>
57 <xslt:apply-templates select="exsl:node-set($书社:result)" mode="书社:wrap"/>
58 </xslt:otherwise>
59 </xslt:choose>
60 </xslt:template>
61 <xslt:template match="/*/*//@书社:disable-output-wrapping|//@书社:destination" priority="0"/>
62 <xslt:template match="@*|node()" priority="-1">
63 <xslt:copy>
64 <xslt:apply-templates select="@*|node()"/>
65 </xslt:copy>
66 </xslt:template>
67 <xslt:template match="/*" mode="书社:expand" priority="0">
68 <xslt:copy>
69 <xslt:attribute name="itemscope">itemscope</xslt:attribute>
70 <xslt:attribute name="itemtype">
71 <xslt:text>&书社;:document</xslt:text>
72 <xslt:for-each select="exslstr:tokenize(@itemtype)/token">
73 <xslt:text> </xslt:text>
74 <xslt:value-of select="."/>
75 </xslt:for-each>
76 </xslt:attribute>
77 <xslt:apply-templates select="@*[not(namespace-uri()='' and (local-name()='itemscope' or local-name()='itemtype'))]|node()" mode="书社:expand"/>
78 </xslt:copy>
79 </xslt:template>
80 <xslt:template match="书社:link[@xlink:show='embed']" mode="书社:expand" priority="1">
81 <xslt:variable name="uri" select="substring-before(document($catalog)//catalog:uri[@name=current()/@xlink:href]/@uri[1], '#')"/>
82 <xslt:choose>
83 <xslt:when test="$uri">
84 <xslt:variable name="expanded">
85 <xslt:apply-templates select="document($uri)" mode="书社:expand"/>
86 </xslt:variable>
87 <xslt:for-each select="exsl:node-set($expanded)/*">
88 <xslt:copy>
89 <xslt:attribute name="itemscope">itemscope</xslt:attribute>
90 <xslt:attribute name="itemtype">
91 <xslt:text>&书社;:embed</xslt:text>
92 <xslt:for-each select="exslstr:tokenize(@itemtype)/token[string()!='&书社;:document']">
93 <xslt:text> </xslt:text>
94 <xslt:value-of select="."/>
95 </xslt:for-each>
96 </xslt:attribute>
97 <xslt:copy-of select="@*[not(namespace-uri()='' and (local-name()='itemscope' or local-name()='itemtype'))]|node()"/>
98 </xslt:copy>
99 </xslt:for-each>
100 </xslt:when>
101 <xslt:otherwise>
102 <xslt:copy>
103 <xslt:apply-templates select="@*|node()" mode="书社:expand"/>
104 </xslt:copy>
105 </xslt:otherwise>
106 </xslt:choose>
107 </xslt:template>
108 <xslt:template match="@*|text()|*[not(self::书社:link) or not(@xlink:show='embed')]" mode="书社:expand" priority="-1">
109 <xslt:copy>
110 <xslt:apply-templates select="@*|node()" mode="书社:expand"/>
111 </xslt:copy>
112 </xslt:template>
113 <xslt:template match="text()" mode="书社:header"/>
114 <xslt:template match="text()" mode="书社:footer"/>
115 <xslt:template match="text()" mode="书社:metadata"/>
116 <xslt:template match="/" mode="书社:wrap">
117 <xslt:variable name="metadata">
118 <xslt:copy-of select="html:html/html:head/*"/>
119 <xslt:apply-templates select="." mode="书社:metadata"/>
120 <xslt:apply-templates select="document('')/xslt:transform/xslt:include" mode="书社:metadata"/>
121 </xslt:variable>
122 <html:html>
123 <xslt:copy-of select="html:html/@*|*/@xml:lang|html:*/@lang|svg:*/@lang"/>
124 <html:head>
125 <xslt:copy-of select="html:html/html:head/@*"/>
126 <html:title>
127 <xslt:for-each select="exsl:node-set($metadata)/html:title">
128 <xslt:value-of select="."/>
129 </xslt:for-each>
130 </html:title>
131 <xslt:copy-of select="exsl:node-set($metadata)/node()[self::comment() or self::* and not(self::html:title)]"/>
132 <xslt:if test="not(exsl:node-set($metadata)/html:meta[@name='generator'])">
133 <html:meta name="generator" content="⛩️📰 书社"/>
134 </xslt:if>
135 </html:head>
136 <html:body>
137 <xslt:copy-of select="html:html/html:body/@*|html:body/@*"/>
138 <xslt:apply-templates select="document('')/xslt:transform/xslt:include" mode="书社:header"/>
139 <xslt:apply-templates select="." mode="书社:header"/>
140 <xslt:copy-of select="*[not(self::html:html or self::html:body)]|html:html/*[not(self::html:head or self::html:body)]|html:html/html:body/*|html:body/*"/>
141 <xslt:apply-templates select="." mode="书社:footer"/>
142 <xslt:apply-templates select="document('')/xslt:transform/xslt:include" mode="书社:footer"/>
143 </html:body>
144 </html:html>
145 </xslt:template>
146 <xslt:output method="xml" encoding="UTF-8" cdata-section-elements="html:script html:style html:textarea"/>
147 </xslt:transform>
148 </template>
149 <output method="xml" encoding="UTF-8"/>
150 </transform>
This page took 0.096018 seconds and 3 git commands to generate.