3 SPDX-FileCopyrightText: 2024 Lady <https://www.ladys.computer/about/#lady>
4 SPDX-License-Identifier: MPL-2.0
7 ⁌ ⛩️📰 书社 ∷ parsers/record-jar.xslt
9 © 2024 Lady [@ Lady’s 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:exsl="http://exslt.org/common"
17 xmlns:exslstr="http://exslt.org/strings"
18 xmlns:html="http://www.w3.org/1999/xhtml"
19 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
20 exclude-result-prefixes="exsl exslstr"
23 <书社:id>urn:fdc:ladys.computer:20231231:Shu1She4:record-jar.xslt</书社:id>
24 <template match="html:script[@type='text/record-jar']">
25 <variable name="lines" select="exslstr:tokenize(., '
')"/>
27 <for-each select="$lines[not(position()=1) and starts-with(., '%%')]">
28 <variable name="end" select="."/>
29 <variable name="start" select="preceding-sibling::*[starts-with(., '%%')][1]"/>
30 <variable name="fields" select="($start/following-sibling::*|$lines[not($start)])[not(preceding-sibling::*[generate-id()=generate-id($end)]) and not(starts-with(., '%%'))]"/>
33 <for-each select="$fields">
35 <when test="starts-with(., ' ') and $fields[generate-id()=generate-id(current()/preceding-sibling::*[1])]"/>
37 <variable name="next" select="following-sibling::*[not(starts-with(., ' '))]"/>
40 <value-of select="normalize-space(substring-before(., ':'))"/>
43 <variable name="firstline">
45 <when test="contains(., ':')">
46 <value-of select="normalize-space(substring-after(., ':'))"/>
49 <value-of select="normalize-space(.)"/>
54 <when test="substring($firstline, string-length($firstline))='\' and following-sibling::*[position()=1 and starts-with(., ' ')]">
55 <value-of select="substring($firstline, 1, string-length($firstline)-1)"/>
58 <value-of select="$firstline"/>
61 <for-each select="following-sibling::*[starts-with(., ' ') and not(preceding-sibling::*[generate-id()=generate-id($next)])]">
62 <variable name="nextline" select="normalize-space(.)"/>
64 <when test="substring($nextline, string-length($nextline))='\' and following-sibling::*[position()=1 and starts-with(., ' ')]">
65 <value-of select="substring($nextline, 1, string-length($nextline)-1)"/>
68 <value-of select="$nextline"/>