]> Lady’s Gitweb - Shushe/blob - lib/catalog2transform.xslt
e7640e8c97e606f51899eee34c1324803e86ac54
[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 <transform
11 xmlns="http://www.w3.org/1999/XSL/Transform"
12 xmlns:html="http://www.w3.org/1999/xhtml"
13 xmlns:catalog="urn:oasis:names:tc:entity:xmlns:xml:catalog"
14 xmlns:exsl="http://exslt.org/common"
15 xmlns:xlink="http://www.w3.org/1999/xlink"
16 xmlns:xslt="http://www.w3.org/1999/XSL/TransformAlias"
17 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
18 version="1.0"
19 >
20 <namespace-alias stylesheet-prefix="xslt" result-prefix="#default"/>
21 <template match="/">
22 <xslt:transform exclude-result-prefixes="catalog exsl" version="1.0">
23 <xslt:param name="catalog" select="'catalog'"/>
24 <xslt:variable name="书社:expansion">
25 <xslt:apply-templates select="/" mode="书社:expand"/>
26 </xslt:variable>
27 <xslt:variable name="书社:result">
28 <xslt:apply-templates select="exsl:node-set($书社:expansion)/*"/>
29 </xslt:variable>
30 <for-each select="//catalog:uri">
31 <xslt:include href="{@uri}">
32 <if test="contains(@name, ':')">
33 <attribute name="书社:id">
34 <value-of select="@name"/>
35 </attribute>
36 </if>
37 </xslt:include>
38 </for-each>
39 <xslt:template match="/" priority="1">
40 <xslt:variable name="metadata">
41 <xslt:copy-of select="exsl:node-set($书社:result)/html/head/*"/>
42 <xslt:apply-templates select="exsl:node-set($书社:result)" mode="书社:metadata"/>
43 <xslt:apply-templates select="document('')/xslt:transform/xslt:include" mode="书社:metadata"/>
44 </xslt:variable>
45 <html:html>
46 <xslt:copy-of select="exsl:node-set($书社:result)/html:html/@*"/>
47 <html:head>
48 <xslt:copy-of select="exsl:node-set($书社:result)/html:html/html:head/@*"/>
49 <html:title>
50 <xslt:for-each select="exsl:node-set($metadata)/html:title">
51 <xslt:value-of select="."/>
52 </xslt:for-each>
53 </html:title>
54 <xslt:copy-of select="exsl:node-set($metadata)/node()[self::comment() or self::* and not(self::html:title)]"/>
55 <xslt:if test="not(exsl:node-set($metadata)/html:meta[@name='generator'])">
56 <html:meta name="generator" content="⛩️📰 书社"/>
57 </xslt:if>
58 </html:head>
59 <html:body>
60 <xslt:copy-of select="exsl:node-set($书社:result)/*[not(self::html:html or self::html:body)]|exsl:node-set($书社:result)/html:html/*[not(self::html:head or self::html:body)]|exsl:node-set($书社:result)/html:html/html:body/*|exsl:node-set($书社:result)/html:body/*"/>
61 </html:body>
62 </html:html>
63 </xslt:template>
64 <xslt:template match="@*|node()" priority="-1">
65 <xslt:copy>
66 <xslt:apply-templates select="@*|node()"/>
67 </xslt:copy>
68 </xslt:template>
69 <xslt:template match="书社:link[@xlink:show='embed']" mode="书社:expand">
70 <xslt:variable name="uri" select="substring-before(document($catalog)//catalog:uri[@name=current()/@xlink:href]/@uri[1], '#')"/>
71 <xslt:choose>
72 <xslt:when test="$uri">
73 <xslt:apply-templates select="document($uri)" mode="书社:expand"/>
74 </xslt:when>
75 <xslt:otherwise>
76 <xslt:copy>
77 <xslt:apply-templates select="@*|node()" mode="书社:expand"/>
78 </xslt:copy>
79 </xslt:otherwise>
80 </xslt:choose>
81 </xslt:template>
82 <xslt:template match="@*|text()|*[not(self::书社:link) or not(@xlink:show='embed')]" mode="书社:expand">
83 <xslt:copy>
84 <xslt:apply-templates select="@*|node()" mode="书社:expand"/>
85 </xslt:copy>
86 </xslt:template>
87 <xslt:template match="text()" mode="书社:metadata"/>
88 <xslt:output method="xml" encoding="UTF-8" cdata-section-elements="html:script html:style html:textarea"/>
89 </xslt:transform>
90 </template>
91 </transform>
This page took 0.063302 seconds and 3 git commands to generate.