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[@xlink:show='embed' and (not(@xlink:actuate) or @xlink:actuate='none')]" mode="书社:expand" priority="1">
33 <variable name="link" select="."/>
34 <variable name="identifier" select="string(@xlink:href)"/>
35 <variable name="is-dir" select="substring($identifier, string-length($identifier))='/'"/>
36 <variable name="included" select="$书社:about//*[@rdf:about=$identifier or $is-dir and starts-with(@rdf:about, $identifier)]"/>
38 <when test="$included">
39 <for-each select="$included">
40 <sort select="@rdf:about" data-type="text" lang="zxx" case-order="upper-first"/>
41 <variable name="uri" select="书社vocab:hasParsedFile/@nfo:fileUrl"/>
42 <variable name="expanded">
43 <apply-templates select="document($uri)" mode="书社:expand">
44 <with-param name="identifier" select="string(@rdf:about)"/>
47 <for-each select="exsl:node-set($expanded)/node()">
50 <when test="self::html:*">
51 <variable name="existing-types" select="exslstr:tokenize(@itemtype)"/>
52 <attribute name="itemscope">itemscope</attribute>
53 <attribute name="itemtype">
54 <for-each select="$existing-types/token[string()!='&书社;:document']">
55 <if test="position()!=1">
58 <value-of select="."/>
60 <if test="not($existing-types/token[string()='&书社;:embed'])">
61 <if test="$existing-types/token[string()!='&书社;:document']">
64 <text>&书社;:embed</text>
68 <when test="$link/@书社:archived-as">
69 <copy-of select="$link/@书社:archived-as"/>
71 <when test="@书社:archived-as">
72 <copy-of select="@书社:archived-as"/>
75 <copy-of select="@*[not(namespace-uri()='' and (local-name()='itemscope' or local-name()='itemtype')) and not(namespace-uri()='&书社;' and local-name()='archived-as')]|node()"/>
79 <when test="self::* and $link/@书社:archived-as">
80 <copy-of select="$link/@书社:archived-as"/>
82 <when test="@书社:archived-as">
83 <copy-of select="@书社:archived-as"/>
86 <copy-of select="@*[not(namespace-uri()='&书社;' and local-name()='archived-as')]|node()"/>
95 <apply-templates select="@*|node()" mode="书社:expand"/>
100 <template match="/node()" mode="书社:expand" priority="0">
101 <param name="identifier" select="$IDENTIFIER"/>
104 <attribute name="书社:cksum">
105 <value-of select="$书社:about//*[@rdf:about=$identifier]/nfo:hasHash[@nfo:hashAlgorithm='CRC32']/@nfo:hashValue"/>
107 <attribute name="书社:identifier">
108 <value-of select="$identifier"/>
110 <attribute name="书社:mtime">
111 <value-of select="$书社:about//*[@rdf:about=$identifier]/nfo:fileLastModified"/>
115 <when test="self::html:*">
116 <variable name="existing-types" select="exslstr:tokenize(@itemtype)"/>
117 <attribute name="itemscope">itemscope</attribute>
118 <attribute name="itemtype">
119 <for-each select="$existing-types/token">
120 <if test="position()!=1">
123 <value-of select="."/>
125 <if test="not($existing-types/token[string()='&书社;:embed' or string()='&书社;:document'])">
126 <if test="$existing-types/token">
129 <text>&书社;:document</text>
132 <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"/>
135 <apply-templates select="@*[not(namespace-uri()='&书社;' and (local-name()='cksum' or local-name()='identifier' or local-name()='mtime'))]|node()" mode="书社:expand"/>