]> Lady’s Gitweb - Shushe/blob - lib/catalog2dependencies.xslt
Consider destinations akin to dependencies
[Shushe] / lib / catalog2dependencies.xslt
1 <?xml version="1.0"?>
2 <!--
3 ⁌ ⛩️📰 书社 ∷ lib/catalog2dependencies.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: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"
16 version="1.0"
17 >
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())])">
26 <copy-of select="."/>
27 </if>
28 </for-each>
29 </variable>
30 <variable name="old">
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())])">
35 <copy-of select="."/>
36 </if>
37 </for-each>
38 <for-each select="exsl:node-set($processed)/书社:dependency">
39 <if test="not(exsl:node-set($unprocessed)/书社:recursive-dependency[string()=string(current())])">
40 <copy-of select="."/>
41 </if>
42 </for-each>
43 <copy-of select="$queue"/>
44 </variable>
45 <variable name="new">
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>
54 </if>
55 <if test="$uris/@name[string()=string(current()/@xlink:href)]">
56 <书社:dependency>
57 <value-of select="@xlink:href"/>
58 </书社:dependency>
59 </if>
60 </for-each>
61 </for-each>
62 </for-each>
63 </variable>
64 <choose>
65 <when test="exsl:node-set($new)/书社:dependency">
66 <call-template name="书社:process-dependencies">
67 <with-param name="processed">
68 <copy-of select="$old"/>
69 </with-param>
70 <with-param name="unprocessed">
71 <copy-of select="$new"/>
72 </with-param>
73 </call-template>
74 </when>
75 <otherwise>
76 <copy-of select="$old"/>
77 </otherwise>
78 </choose>
79 </template>
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">
84 <书社:dependency-root>
85 <value-of select="@name"/>
86 </书社:dependency-root>
87 </with-param>
88 </call-template>
89 </if>
90 </template>
91 <template match="/">
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"/>
96 </variable>
97 <value-of select="@name"/>
98 <text>&#xA;</text>
99 <for-each select="exsl:node-set($dependencies)/书社:recursive-dependency">
100 <text>&#x9;</text>
101 <text>-</text>
102 <value-of select="."/>
103 <text>&#xA;</text>
104 </for-each>
105 <for-each select="exsl:node-set($dependencies)/书社:dependency">
106 <text>&#x9;</text>
107 <value-of select="."/>
108 <text>&#xA;</text>
109 </for-each>
110 </for-each>
111 </template>
112 <output method="text" encoding="UTF-8"/>
113 </transform>
This page took 0.143151 seconds and 5 git commands to generate.