]> Lady’s Gitweb - Shushe/blob - lib/paged2extractor.xslt
Fix base64 decoding
[Shushe] / lib / paged2extractor.xslt
1 <?xml version="1.0"?>
2 <!--
3 SPDX-FileCopyrightText: 2024 Lady <https://www.ladys.computer/about/#lady>
4 SPDX-License-Identifier: MPL-2.0
5 -->
6 <!--
7 ⁌ ⛩️📰 书社 ∷ lib/paged2extractor.xslt
8
9 © 2024 Lady [@ Lady’s Computer].
10
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/>.
13 -->
14 <transform
15 xmlns="http://www.w3.org/1999/XSL/Transform"
16 xmlns:exsl="http://exslt.org/common"
17 xmlns:exslstr="http://exslt.org/strings"
18 xmlns:xslt="http://www.w3.org/1999/XSL/TransformAlias"
19 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
20 version="1.0"
21 >
22 <namespace-alias stylesheet-prefix="xslt" result-prefix="#default"/>
23 <param name="NAME"/>
24 <template match="/">
25 <xslt:transform extension-element-prefixes="exsl exslstr" version="1.0">
26 <xslt:template match="@*|node()">
27 <xslt:param name="destination" select="''"/>
28 <xslt:choose>
29 <xslt:when test="self::书社:page">
30 <xslt:apply-templates>
31 <xslt:with-param name="destination" select="$destination"/>
32 </xslt:apply-templates>
33 </xslt:when>
34 <xslt:when test="$destination='' and not(ancestor::书社:page) or string(ancestor::书社:page[1]/@书社:destination)=$destination">
35 <xslt:copy>
36 <xslt:apply-templates>
37 <xslt:with-param name="destination" select="$destination"/>
38 </xslt:apply-templates>
39 </xslt:copy>
40 </xslt:when>
41 <xslt:otherwise>
42 <xslt:apply-templates>
43 <xslt:with-param name="destination" select="$destination"/>
44 </xslt:apply-templates>
45 </xslt:otherwise>
46 </xslt:choose>
47 </xslt:template>
48 <xslt:template match="/" priority="1">
49 <exsl:document href="./pages/{$NAME}" method="xml" encoding="UTF-8">
50 <xslt:apply-templates/>
51 </exsl:document>
52 <xslt:text>
53 <text>./pages/</text>
54 <value-of select="$NAME"/>
55 <text>&#xA;</text>
56 </xslt:text>
57 <for-each select="//书社:page[@书社:destination]">
58 <if test="not(ancestor::书社:page[@书社:destination=current()/@书社:destination] or preceding::书社:page[@书社:destination=current()/@书社:destination])">
59 <variable name="href">
60 <text>./pages/</text>
61 <value-of select="exslstr:tokenize(@书社:destination, '/')[last()]"/>
62 </variable>
63 <exsl:document href="{$href}" method="xml" encoding="UTF-8">
64 <xslt:apply-templates>
65 <xslt:with-param name="destination">
66 <value-of select="@书社:destination"/>
67 </xslt:with-param>
68 </xslt:apply-templates>
69 </exsl:document>
70 <xslt:text>
71 <choose>
72 <when test="contains($href, '%22%7B')">
73 <value-of select="substring-before($href, '%22%7B')"/>
74 <text>&quot;{</text>
75 <value-of select="substring-before(substring-after($href, '%22%7B'), '%7D%22')"/>
76 <text>}&quot;</text>
77 <value-of select="substring-after(substring-after($href, '%22%7B'), '%7D%22')"/>
78 </when>
79 <otherwise>
80 <value-of select="$href"/>
81 </otherwise>
82 </choose>
83 <text>&#xA;</text>
84 </xslt:text>
85 </if>
86 </for-each>
87 </xslt:template>
88 <xslt:output method="text" encoding="UTF-8"/>
89 </xslt:transform>
90 </template>
91 <output method="xml" encoding="UTF-8"/>
92 </transform>
This page took 0.148667 seconds and 5 git commands to generate.