3 SPDX-FileCopyrightText: 2023, 2024 Lady <https://www.ladys.computer/about/#lady>
4 SPDX-License-Identifier: MPL-2.0
7 ⁌ ⛩️📰 书社 ∷ lib/catalog2dependencies.xslt
9 © 2023–2024 Lady [@ Lady’s Computer].
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/>.
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"
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())])">
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())])">
42 <for-each select="exsl:node-set($processed)/书社:dependency">
43 <if test="not(exsl:node-set($unprocessed)/书社:recursive-dependency[string()=string(current())])">
47 <copy-of select="$queue"/>
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>
59 <if test="$uris/@name[string()=string(current()/@xlink:href)]">
61 <value-of select="@xlink:href"/>
69 <when test="exsl:node-set($new)/书社:dependency">
70 <call-template name="书社:process-dependencies">
71 <with-param name="processed">
72 <copy-of select="$old"/>
74 <with-param name="unprocessed">
75 <copy-of select="$new"/>
80 <copy-of select="$old"/>
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">
89 <value-of select="@name"/>
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"/>
101 <value-of select="@name"/>
103 <for-each select="exsl:node-set($dependencies)/书社:recursive-dependency">
106 <value-of select="."/>
109 <for-each select="exsl:node-set($dependencies)/书社:dependency">
111 <value-of select="."/>
116 <output method="text" encoding="UTF-8"/>