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