3 ⁌ ⛩️📰 书社 ∷ lib/catalog2transform.xslt
5 © 2023–2024 Lady [@ Lady’s Computer]
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/>.
11 <!ENTITY 书社 "urn:fdc:ladys.computer:20231231:Shu1She4">
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"
24 <namespace-alias stylesheet-prefix="xslt" result-prefix="#default"/>
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"/>
34 <xslt:variable name="书社:result">
35 <xslt:apply-templates select="exsl:node-set($书社:expansion)/*"/>
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"/>
46 <xslt:template match="/" priority="1">
48 <xslt:when test="exsl:node-set($书社:result)/*[@书社:disable-output-wrapping]">
49 <xslt:for-each select="exsl:node-set($书社:result)/*">
51 <xslt:copy-of select="@*[not(namespace-uri()='&书社;' and local-name()='disable-output-wrapping')]|node()"/>
56 <xslt:apply-templates select="exsl:node-set($书社:result)" mode="书社:wrap"/>
60 <xslt:template match="/*/*//@书社:disable-output-wrapping" priority="0"/>
61 <xslt:template match="@*|node()" priority="-1">
63 <xslt:apply-templates select="@*|node()"/>
66 <xslt:template match="/*" mode="书社:expand" priority="0">
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="."/>
76 <xslt:apply-templates select="@*[not(namespace-uri()='' and (local-name()='itemscope' or local-name()='itemtype'))]|node()" mode="书社:expand"/>
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], '#')"/>
82 <xslt:when test="$uri">
83 <xslt:variable name="expanded">
84 <xslt:apply-templates select="document($uri)" mode="书社:expand"/>
86 <xslt:for-each select="exsl:node-set($expanded)/*">
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="."/>
96 <xslt:copy-of select="@*[not(namespace-uri()='' and (local-name()='itemscope' or local-name()='itemtype'))]|node()"/>
102 <xslt:apply-templates select="@*|node()" mode="书社:expand"/>
107 <xslt:template match="@*|text()|*[not(self::书社:link) or not(@xlink:show='embed')]" mode="书社:expand" priority="-1">
109 <xslt:apply-templates select="@*|node()" mode="书社:expand"/>
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:html/html:head/*"/>
118 <xslt:apply-templates select="." mode="书社:metadata"/>
119 <xslt:apply-templates select="document('')/xslt:transform/xslt:include" mode="书社:metadata"/>
122 <xslt:copy-of select="html:html/@*"/>
124 <xslt:copy-of select="html:html/html:head/@*"/>
126 <xslt:for-each select="exsl:node-set($metadata)/html:title">
127 <xslt:value-of select="."/>
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="⛩️📰 书社"/>
136 <xslt:copy-of select="html:html/html:body/@*|html:body/@*"/>
137 <xslt:apply-templates select="document('')/xslt:transform/xslt:include" mode="书社:header"/>
138 <xslt:apply-templates select="." mode="书社:header"/>
139 <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/*"/>
140 <xslt:apply-templates select="." mode="书社:footer"/>
141 <xslt:apply-templates select="document('')/xslt:transform/xslt:include" mode="书社:footer"/>
145 <xslt:output method="xml" encoding="UTF-8" cdata-section-elements="html:script html:style html:textarea"/>