]> Lady’s Gitweb - Shushe/blob - lib/catalog2transform.xslt
40e40722e8556470b17464b5b9b84ff99d566156
[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="GENERATOR" select="false"/>
31 <xslt:param name="PATH" select="'/unknown'"/>
32 <xslt:param name="SRCREV" select="false"/>
33 <xslt:param name="SRCTIME" select="'1972-12-31T00:00:00Z'"/>
34 <xslt:param name="VERSION" select="false"/>
35 <xslt:variable name="书社:expansion">
36 <xslt:apply-templates select="/" mode="书社:expand"/>
37 </xslt:variable>
38 <xslt:variable name="书社:result">
39 <xslt:apply-templates select="exsl:node-set($书社:expansion)/*"/>
40 </xslt:variable>
41 <for-each select="//catalog:uri">
42 <xslt:include href="{@uri}">
43 <if test="contains(@name, ':')">
44 <attribute name="书社:id">
45 <value-of select="@name"/>
46 </attribute>
47 </if>
48 </xslt:include>
49 </for-each>
50 <xslt:template match="/" priority="1">
51 <xslt:choose>
52 <xslt:when test="exsl:node-set($书社:result)/*[@书社:disable-output-wrapping]">
53 <xslt:for-each select="exsl:node-set($书社:result)/*">
54 <xslt:copy>
55 <xslt:if test="$VERSION">
56 <xslt:attribute name="书社:version">
57 <xslt:value-of select="$VERSION"/>
58 </xslt:attribute>
59 </xslt:if>
60 <xslt:copy-of select="@*[not(namespace-uri()='&书社;' and contains('disable-output-wrapping version', local-name()))]|node()"/>
61 </xslt:copy>
62 </xslt:for-each>
63 </xslt:when>
64 <xslt:otherwise>
65 <xslt:apply-templates select="exsl:node-set($书社:result)" mode="书社:wrap"/>
66 </xslt:otherwise>
67 </xslt:choose>
68 </xslt:template>
69 <xslt:template match="/*/*//@书社:disable-output-wrapping|//@书社:destination" priority="0"/>
70 <xslt:template match="@*|node()" priority="-1">
71 <xslt:copy>
72 <xslt:apply-templates select="@*|node()"/>
73 </xslt:copy>
74 </xslt:template>
75 <xslt:template match="/*" mode="书社:expand" priority="0">
76 <xslt:copy>
77 <xslt:attribute name="itemscope">itemscope</xslt:attribute>
78 <xslt:attribute name="itemtype">
79 <xslt:text>&书社;:document</xslt:text>
80 <xslt:for-each select="exslstr:tokenize(@itemtype)/token">
81 <xslt:text> </xslt:text>
82 <xslt:value-of select="."/>
83 </xslt:for-each>
84 </xslt:attribute>
85 <xslt:apply-templates select="@*[not(namespace-uri()='' and (local-name()='itemscope' or local-name()='itemtype'))]|node()" mode="书社:expand"/>
86 </xslt:copy>
87 </xslt:template>
88 <xslt:template match="书社:link[@xlink:show='embed']" mode="书社:expand" priority="1">
89 <xslt:variable name="uri" select="substring-before(document($CATALOG)//catalog:uri[@name=current()/@xlink:href]/@uri[1], '#')"/>
90 <xslt:choose>
91 <xslt:when test="$uri">
92 <xslt:variable name="expanded">
93 <xslt:apply-templates select="document($uri)" mode="书社:expand"/>
94 </xslt:variable>
95 <xslt:for-each select="exsl:node-set($expanded)/*">
96 <xslt:copy>
97 <xslt:attribute name="itemscope">itemscope</xslt:attribute>
98 <xslt:attribute name="itemtype">
99 <xslt:text>&书社;:embed</xslt:text>
100 <xslt:for-each select="exslstr:tokenize(@itemtype)/token[string()!='&书社;:document']">
101 <xslt:text> </xslt:text>
102 <xslt:value-of select="."/>
103 </xslt:for-each>
104 </xslt:attribute>
105 <xslt:copy-of select="@*[not(namespace-uri()='' and (local-name()='itemscope' or local-name()='itemtype'))]|node()"/>
106 </xslt:copy>
107 </xslt:for-each>
108 </xslt:when>
109 <xslt:otherwise>
110 <xslt:copy>
111 <xslt:apply-templates select="@*|node()" mode="书社:expand"/>
112 </xslt:copy>
113 </xslt:otherwise>
114 </xslt:choose>
115 </xslt:template>
116 <xslt:template match="@*|text()|*[not(self::书社:link) or not(@xlink:show='embed')]" mode="书社:expand" priority="-1">
117 <xslt:copy>
118 <xslt:apply-templates select="@*|node()" mode="书社:expand"/>
119 </xslt:copy>
120 </xslt:template>
121 <xslt:template match="text()" mode="书社:header"/>
122 <xslt:template match="text()" mode="书社:footer"/>
123 <xslt:template match="text()" mode="书社:metadata"/>
124 <xslt:template match="/" mode="书社:wrap">
125 <xslt:variable name="modalinput">
126 <xslt:copy-of select="node()"/>
127 <xslt:copy-of select="document('')/xslt:transform/xslt:include"/>
128 </xslt:variable>
129 <xslt:variable name="metadata">
130 <xslt:copy-of select="html:html/html:head/node()|html:head/node()"/>
131 <xslt:apply-templates select="exsl:node-set($modalinput)" mode="书社:metadata"/>
132 </xslt:variable>
133 <html:html>
134 <xslt:if test="$VERSION">
135 <xslt:attribute name="书社:version">
136 <xslt:value-of select="$VERSION"/>
137 </xslt:attribute>
138 </xslt:if>
139 <xslt:copy-of select="html:html/@*"/>
140 <xslt:if test="not(html:html/@lang) and (html:*/@lang|svg:*/@lang|*/@xml:lang)">
141 <xslt:attribute name="lang">
142 <xslt:value-of select="html:*/@lang|svg:*/@lang|*/@xml:lang"/>
143 </xslt:attribute>
144 </xslt:if>
145 <xslt:if test="not(html:html/@xml:lang) and (html:*/@lang|svg:*/@lang|*/@xml:lang)">
146 <xslt:attribute name="xml:lang">
147 <xslt:value-of select="html:*/@lang|svg:*/@lang|*/@xml:lang"/>
148 </xslt:attribute>
149 </xslt:if>
150 <html:head>
151 <xslt:copy-of select="html:html/html:head/@*|html:head/@*"/>
152 <html:title>
153 <xslt:for-each select="exsl:node-set($metadata)/html:title">
154 <xslt:value-of select="."/>
155 </xslt:for-each>
156 </html:title>
157 <xslt:copy-of select="exsl:node-set($metadata)/node()[not(self::*) or not(self::html:title)]"/>
158 <xslt:if test="$GENERATOR and not(exsl:node-set($metadata)/html:meta[@name='generator'])">
159 <html:meta name="generator">
160 <xslt:attribute name="content">
161 <xslt:value-of select="$GENERATOR"/>
162 <xslt:if test="$VERSION">
163 <xslt:text> (</xslt:text>
164 <xslt:value-of select="$VERSION"/>
165 <xslt:text>)</xslt:text>
166 </xslt:if>
167 </xslt:attribute>
168 </html:meta>
169 </xslt:if>
170 </html:head>
171 <html:body>
172 <xslt:copy-of select="html:html/html:body/@*|html:body/@*"/>
173 <xslt:apply-templates select="exsl:node-set($modalinput)" mode="书社:header"/>
174 <xslt:copy-of select="node()[not(self::html:html or self::html:head or self::html:body)]|html:html/node()[not(self::html:head or self::html:body)]|html:html/html:body/node()|html:body/node()"/>
175 <xslt:apply-templates select="exsl:node-set($modalinput)" mode="书社:footer"/>
176 </html:body>
177 </html:html>
178 </xslt:template>
179 <xslt:output method="xml" encoding="UTF-8" cdata-section-elements="html:script html:style html:textarea"/>
180 </xslt:transform>
181 </template>
182 <output method="xml" encoding="UTF-8"/>
183 </transform>
This page took 0.059653 seconds and 3 git commands to generate.