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