]> Lady’s Gitweb - Shushe/blob - lib/catalog2dependencies.xslt
Redirect messages to stderr & support disabling
[Shushe] / lib / catalog2dependencies.xslt
1 <?xml version="1.0"?>
2 <!--
3 SPDX-FileCopyrightText: 2023, 2024 Lady <https://www.ladys.computer/about/#lady>
4 SPDX-License-Identifier: MPL-2.0
5 -->
6 <!--
7 ⁌ ⛩️📰 书社 ∷ lib/catalog2dependencies.xslt
8
9 © 2023–2024 Lady [@ Lady’s Computer].
10
11 This Source Code Form is subject to the terms of the Mozilla Public License, v 2.0.
12 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/>.
13 -->
14 <transform
15 xmlns="http://www.w3.org/1999/XSL/Transform"
16 xmlns:catalog="urn:oasis:names:tc:entity:xmlns:xml:catalog"
17 xmlns:exsl="http://exslt.org/common"
18 xmlns:xlink="http://www.w3.org/1999/xlink"
19 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
20 version="1.0"
21 >
22 <variable name="uris" select="//catalog:uri"/>
23 <template name="书社:process-dependencies">
24 <param name="processed"/>
25 <param name="unprocessed"/>
26 <variable name="queue">
27 <copy-of select="exsl:node-set($unprocessed)/书社:dependency-root"/>
28 <for-each select="exsl:node-set($unprocessed)/书社:dependency">
29 <if test="not((exsl:node-set($processed)/书社:*|preceding-sibling::书社:*|following-sibling::书社:recursive-dependency)[string()=string(current())])">
30 <copy-of select="."/>
31 </if>
32 </for-each>
33 </variable>
34 <variable name="old">
35 <copy-of select="exsl:node-set($processed)/书社:dependency-root"/>
36 <copy-of select="exsl:node-set($processed)/书社:recursive-dependency"/>
37 <for-each select="exsl:node-set($unprocessed)/书社:recursive-dependency">
38 <if test="not((exsl:node-set($processed)/书社:recursive-dependency|preceding-sibling::书社:recursive-dependency)[string()=string(current())])">
39 <copy-of select="."/>
40 </if>
41 </for-each>
42 <for-each select="exsl:node-set($processed)/书社:dependency">
43 <if test="not(exsl:node-set($unprocessed)/书社:recursive-dependency[string()=string(current())])">
44 <copy-of select="."/>
45 </if>
46 </for-each>
47 <copy-of select="$queue"/>
48 </variable>
49 <variable name="new">
50 <for-each select="exsl:node-set($queue)/书社:*">
51 <for-each select="$uris[@name=string(current()) and substring-after(@uri, '#')!='asset']">
52 <variable name="parent" select="@name"/>
53 <for-each select="document(substring-before(@uri, '#'), .)//书社:link[@xlink:show='embed']">
54 <if test="exsl:node-set($old)/书社:dependency-root[string()=string(current()/@xlink:href)]">
55 <书社:recursive-dependency>
56 <value-of select="$parent"/>
57 </书社:recursive-dependency>
58 </if>
59 <if test="$uris/@name[string()=string(current()/@xlink:href)]">
60 <书社:dependency>
61 <value-of select="@xlink:href"/>
62 </书社:dependency>
63 </if>
64 </for-each>
65 </for-each>
66 </for-each>
67 </variable>
68 <choose>
69 <when test="exsl:node-set($new)/书社:dependency">
70 <call-template name="书社:process-dependencies">
71 <with-param name="processed">
72 <copy-of select="$old"/>
73 </with-param>
74 <with-param name="unprocessed">
75 <copy-of select="$new"/>
76 </with-param>
77 </call-template>
78 </when>
79 <otherwise>
80 <copy-of select="$old"/>
81 </otherwise>
82 </choose>
83 </template>
84 <template match="catalog:uri" mode="书社:dependencies">
85 <if test="substring-after(@uri, '#')!='asset'">
86 <call-template name="书社:process-dependencies">
87 <with-param name="unprocessed">
88 <书社:dependency-root>
89 <value-of select="@name"/>
90 </书社:dependency-root>
91 </with-param>
92 </call-template>
93 </if>
94 </template>
95 <template match="/">
96 <for-each select="$uris[not(substring-after(@uri, '#')='asset')]">
97 <variable name="parent" select="@name"/>
98 <variable name="dependencies">
99 <apply-templates select="." mode="书社:dependencies"/>
100 </variable>
101 <value-of select="@name"/>
102 <text>&#xA;</text>
103 <for-each select="exsl:node-set($dependencies)/书社:recursive-dependency">
104 <text>&#x9;</text>
105 <text>-</text>
106 <value-of select="."/>
107 <text>&#xA;</text>
108 </for-each>
109 <for-each select="exsl:node-set($dependencies)/书社:dependency">
110 <text>&#x9;</text>
111 <value-of select="."/>
112 <text>&#xA;</text>
113 </for-each>
114 </for-each>
115 </template>
116 <output method="text" encoding="UTF-8"/>
117 </transform>
This page took 0.067703 seconds and 5 git commands to generate.