3 SPDX-FileCopyrightText: 2023, 2024, 2025 Lady <https://www.ladys.computer/about/#lady>
4 SPDX-License-Identifier: MPL-2.0
7 ⁌ ⛩📰 书社 ∷ transforms/expansion.xslt
9 © 2023–2025 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 <!ENTITY 书社 'urn:fdc:ladys.computer:20231231:Shu1She4'>
18 xmlns="http://www.w3.org/1999/XSL/Transform"
19 xmlns:exsl="http://exslt.org/common"
20 xmlns:exslstr="http://exslt.org/strings"
21 xmlns:html="http://www.w3.org/1999/xhtml"
22 xmlns:nfo="http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#"
23 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
24 xmlns:xlink="http://www.w3.org/1999/xlink"
26 xmlns:书社vocab="urn:fdc:ladys.computer:20231231:Shu1She4:vocab:"
27 exclude-result-prefixes="nfo 书社vocab"
28 extension-element-prefixes="exsl exslstr"
31 <书社:id>urn:fdc:ladys.computer:20231231:Shu1She4:expansion.xslt</书社:id>
32 <template match="书社:link[(not(@xlink:show) or @xlink:show='none' or @xlink:show='other') and (not(@xlink:actuate) or @xlink:actuate='none')]" mode="书社:expand" priority="1"/>
33 <template match="书社:link[@xlink:show='embed' and (not(@xlink:actuate) or @xlink:actuate='none')]" mode="书社:expand" priority="1">
34 <variable name="link" select="."/>
35 <variable name="identifier" select="string(@xlink:href)"/>
36 <variable name="is-dir" select="substring($identifier, string-length($identifier))='/'"/>
37 <variable name="included" select="$书社:about//*[@rdf:about=$identifier or $is-dir and starts-with(@rdf:about, $identifier)]"/>
39 <when test="$included">
40 <for-each select="$included">
41 <sort select="@rdf:about" data-type="text" lang="zxx" case-order="upper-first"/>
42 <variable name="uri" select="书社vocab:hasParsedFile/@nfo:fileUrl"/>
43 <variable name="expanded">
44 <apply-templates select="document($uri)" mode="书社:expand">
45 <with-param name="identifier" select="string(@rdf:about)"/>
48 <for-each select="exsl:node-set($expanded)/node()">
51 <when test="self::html:*">
52 <variable name="existing-types" select="exslstr:tokenize(@itemtype)"/>
53 <attribute name="itemscope">itemscope</attribute>
54 <attribute name="itemtype">
55 <for-each select="$existing-types/token[string()!='&书社;:document']">
56 <if test="position()!=1">
59 <value-of select="."/>
61 <if test="not($existing-types/token[string()='&书社;:embed'])">
62 <if test="$existing-types/token[string()!='&书社;:document']">
65 <text>&书社;:embed</text>
69 <when test="$link/@书社:archived-as">
70 <copy-of select="$link/@书社:archived-as"/>
72 <when test="@书社:archived-as">
73 <copy-of select="@书社:archived-as"/>
76 <copy-of select="@*[not(namespace-uri()='' and (local-name()='itemscope' or local-name()='itemtype')) and not(namespace-uri()='&书社;' and local-name()='archived-as')]|node()"/>
80 <when test="self::* and $link/@书社:archived-as">
81 <copy-of select="$link/@书社:archived-as"/>
83 <when test="@书社:archived-as">
84 <copy-of select="@书社:archived-as"/>
87 <copy-of select="@*[not(namespace-uri()='&书社;' and local-name()='archived-as')]|node()"/>
96 <apply-templates select="@*|node()" mode="书社:expand"/>
101 <template match="/node()" mode="书社:expand" priority="0">
102 <param name="identifier" select="$IDENTIFIER"/>
105 <attribute name="书社:cksum">
106 <value-of select="$书社:about//*[@rdf:about=$identifier]/nfo:hasHash[@nfo:hashAlgorithm='CRC32']/@nfo:hashValue"/>
108 <attribute name="书社:identifier">
109 <value-of select="$identifier"/>
111 <attribute name="书社:mtime">
112 <value-of select="$书社:about//*[@rdf:about=$identifier]/nfo:fileLastModified"/>
116 <when test="self::html:*">
117 <variable name="existing-types" select="exslstr:tokenize(@itemtype)"/>
118 <attribute name="itemscope">itemscope</attribute>
119 <attribute name="itemtype">
120 <for-each select="$existing-types/token">
121 <if test="position()!=1">
124 <value-of select="."/>
126 <if test="not($existing-types/token[string()='&书社;:embed' or string()='&书社;:document'])">
127 <if test="$existing-types/token">
130 <text>&书社;:document</text>
133 <apply-templates select="@*[not(namespace-uri()='' and (local-name()='itemscope' or local-name()='itemtype') or namespace-uri()='&书社;' and (local-name()='cksum' or local-name()='identifier' or local-name()='mtime'))]|node()" mode="书社:expand"/>
136 <apply-templates select="@*[not(namespace-uri()='&书社;' and (local-name()='cksum' or local-name()='identifier' or local-name()='mtime'))]|node()" mode="书社:expand"/>