3 ⁌ ⛩️📰 书社 ∷ lib/catalog2dependencies.xslt
5 © 2023 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 xmlns="http://www.w3.org/1999/XSL/Transform"
12 xmlns:catalog="urn:oasis:names:tc:entity:xmlns:xml:catalog"
13 xmlns:exsl="http://exslt.org/common"
14 xmlns:xlink="http://www.w3.org/1999/xlink"
15 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
18 <variable name="uris" select="//catalog:uri"/>
19 <template name="书社:process-dependencies">
20 <param name="processed"/>
21 <param name="unprocessed"/>
22 <variable name="queue">
23 <copy-of select="exsl:node-set($unprocessed)/书社:dependency-root"/>
24 <for-each select="exsl:node-set($unprocessed)/书社:dependency">
25 <if test="not((exsl:node-set($processed)/书社:*|preceding-sibling::书社:*|following-sibling::书社:recursive-dependency)[string()=string(current())])">
31 <copy-of select="exsl:node-set($processed)/书社:dependency-root"/>
32 <copy-of select="exsl:node-set($processed)/书社:recursive-dependency"/>
33 <for-each select="exsl:node-set($unprocessed)/书社:recursive-dependency">
34 <if test="not((exsl:node-set($processed)/书社:recursive-dependency|preceding-sibling::书社:recursive-dependency)[string()=string(current())])">
38 <for-each select="exsl:node-set($processed)/书社:dependency">
39 <if test="not(exsl:node-set($unprocessed)/书社:recursive-dependency[string()=string(current())])">
43 <copy-of select="$queue"/>
46 <for-each select="exsl:node-set($queue)/书社:*">
47 <for-each select="$uris[@name=string(current()) and substring-after(@uri, '#')!='asset']">
48 <variable name="parent" select="@name"/>
49 <for-each select="document(substring-before(@uri, '#'), .)//书社:link[@xlink:show='embed']">
50 <if test="exsl:node-set($old)/书社:dependency-root[string()=string(current()/@xlink:href)]">
51 <书社:recursive-dependency>
52 <value-of select="$parent"/>
53 </书社:recursive-dependency>
55 <if test="$uris/@name[string()=string(current()/@xlink:href)]">
57 <value-of select="@xlink:href"/>
65 <when test="exsl:node-set($new)/书社:dependency">
66 <call-template name="书社:process-dependencies">
67 <with-param name="processed">
68 <copy-of select="$old"/>
70 <with-param name="unprocessed">
71 <copy-of select="$new"/>
76 <copy-of select="$old"/>
80 <template match="catalog:uri" mode="书社:dependencies">
81 <if test="substring-after(@uri, '#')!='asset'">
82 <call-template name="书社:process-dependencies">
83 <with-param name="unprocessed">
85 <value-of select="@name"/>
92 <for-each select="$uris[not(substring-after(@uri, '#')='asset')]">
93 <variable name="parent" select="@name"/>
94 <variable name="dependencies">
95 <apply-templates select="." mode="书社:dependencies"/>
97 <value-of select="@name"/>
99 <for-each select="exsl:node-set($dependencies)/书社:recursive-dependency">
102 <value-of select="."/>
105 <for-each select="exsl:node-set($dependencies)/书社:dependency">
107 <value-of select="."/>
112 <output method="text" encoding="UTF-8"/>