3 SPDX-FileCopyrightText: 2023, 2024 Lady <https://www.ladys.computer/about/#lady>
4 SPDX-License-Identifier: MPL-2.0
7 ⁌ ⛩📰 书社 ∷ lib/metadata2dependencies.xslt
9 © 2023–2024 Lady [@ Ladys 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:dct="http://purl.org/dc/terms/"
17 xmlns:exsl="http://exslt.org/common"
18 xmlns:nie="http://www.semanticdesktop.org/ontologies/2007/01/19/nie#"
19 xmlns:nfo="http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#"
20 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
21 xmlns:xlink="http://www.w3.org/1999/xlink"
22 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
25 <variable name="files" select="/rdf:RDF/nfo:LocalFileDataObject"/>
26 <template name="书社:process-dependencies">
27 <param name="processed"/>
28 <param name="unprocessed"/>
29 <variable name="queue">
30 <copy-of select="exsl:node-set($unprocessed)/书社:dependency-root"/>
31 <for-each select="exsl:node-set($unprocessed)/书社:dependency">
32 <if test="not((exsl:node-set($processed)/书社:*|preceding-sibling::书社:*|following-sibling::书社:recursive-dependency)[string()=string(current())])">
38 <copy-of select="exsl:node-set($processed)/书社:dependency-root"/>
39 <copy-of select="exsl:node-set($processed)/书社:recursive-dependency"/>
40 <for-each select="exsl:node-set($unprocessed)/书社:recursive-dependency">
41 <if test="not((exsl:node-set($processed)/书社:recursive-dependency|preceding-sibling::书社:recursive-dependency)[string()=string(current())])">
45 <for-each select="exsl:node-set($processed)/书社:dependency">
46 <if test="not(exsl:node-set($unprocessed)/书社:recursive-dependency[string()=string(current())])">
50 <copy-of select="$queue"/>
53 <for-each select="exsl:node-set($queue)/书社:*">
54 <for-each select="$files[@rdf:about=string(current()) and nie:interpretedAs/nfo:PlainTextDocument and dct:hasFormat/*/nie:interpretedAs/*[@nie:mimeType='application/xml']]">
55 <variable name="parent" select="@rdf:about"/>
56 <for-each select="document(dct:hasFormat/*[nie:interpretedAs/*[@nie:mimeType='application/xml']]/@nfo:fileUrl[1])//书社:link[@xlink:show='embed']">
57 <if test="exsl:node-set($old)/书社:dependency-root[string()=string(current()/@xlink:href)]">
58 <书社:recursive-dependency>
59 <value-of select="$parent"/>
60 </书社:recursive-dependency>
62 <if test="$files/@rdf:about[string()=string(current()/@xlink:href)]">
64 <value-of select="@xlink:href"/>
72 <when test="exsl:node-set($new)/书社:dependency">
73 <call-template name="书社:process-dependencies">
74 <with-param name="processed">
75 <copy-of select="$old"/>
77 <with-param name="unprocessed">
78 <copy-of select="$new"/>
83 <copy-of select="$old"/>
87 <template match="nfo:LocalFileDataObject" mode="书社:dependencies">
88 <if test="nie:interpretedAs/nfo:PlainTextDocument">
89 <call-template name="书社:process-dependencies">
90 <with-param name="unprocessed">
92 <value-of select="@rdf:about"/>
99 <for-each select="$files[nie:interpretedAs/nfo:PlainTextDocument]">
100 <variable name="parent" select="@rdf:about"/>
101 <variable name="dependencies">
102 <apply-templates select="." mode="书社:dependencies"/>
104 <value-of select="@rdf:about"/>
106 <for-each select="exsl:node-set($dependencies)/书社:recursive-dependency">
109 <value-of select="."/>
112 <for-each select="exsl:node-set($dependencies)/书社:dependency">
114 <value-of select="."/>
119 <output method="text" encoding="UTF-8"/>