3 SPDX-FileCopyrightText: 2024, 2026 Lady <https://www.ladys.computer/about/#lady>
4 SPDX-License-Identifier: MPL-2.0
7 ⁌ ⛩📰 书社 ∷ parsers/record-jar.xslt
9 © 2024, 2026 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 xhtml 'http://www.w3.org/1999/xhtml'>
18 xmlns="http://www.w3.org/1999/XSL/Transform"
19 xmlns:exsl="http://exslt.org/common"
20 xmlns:exslset="http://exslt.org/sets"
21 xmlns:exslstr="http://exslt.org/strings"
23 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
24 extension-element-prefixes="exsl exslset exslstr"
27 <书社:id>urn:fdc:ladys.computer:20231231:Shu1She4:record-jar.xslt</书社:id>
28 <template match="html:script[@type='text/record-jar']">
29 <variable name="lines" select="exslstr:tokenize(., '

')[not(normalize-space(.)='')]"/>
30 <element name="div" namespace="&xhtml;">
31 <if test="starts-with($lines[1], '%%') and $lines[1]!='%%'">
33 <value-of select="substring-after($lines[1], '%%')"/>
36 <for-each select="$lines[not(position()=1) and starts-with(., '%%')]">
37 <variable name="end" select="."/>
38 <variable name="start" select="preceding-sibling::*[starts-with(., '%%')][1]"/>
39 <variable name="fields" select="exslset:intersection(exslset:trailing($end/preceding-sibling::*, $start), $lines)"/>
41 <element name="dl" namespace="&xhtml;">
42 <for-each select="$fields">
43 <variable name="following" select="exslset:intersection($fields, following-sibling::*)"/>
45 <when test="contains(' 	', substring(., 1, 1)) and exslset:has-same-node($fields, preceding-sibling::*[1])"/>
47 <variable name="next" select="$following[not(contains(' 	', substring(., 1, 1)))][1]"/>
48 <element name="div" namespace="&xhtml;">
49 <element name="dt" namespace="&xhtml;">
50 <value-of select="normalize-space(substring-before(., ':'))"/>
52 <element name="dd" namespace="&xhtml;">
53 <variable name="firstline">
55 <when test="contains(., ':')">
56 <value-of select="normalize-space(substring-after(., ':'))"/>
59 <value-of select="normalize-space(.)"/>
64 <when test="substring($firstline, string-length($firstline))='\' and $following[position()=1 and contains(' 	', substring(., 1, 1))]">
65 <value-of select="substring($firstline, 1, string-length($firstline)-1)"/>
68 <value-of select="$firstline"/>
71 <for-each select="exslset:leading($following, $next)[contains(' 	', substring(., 1, 1))]">
72 <variable name="nextline" select="normalize-space(.)"/>
74 <when test="substring($nextline, string-length($nextline))='\' and exslset:intersection($fields, following-sibling::*)[position()=1 and contains(' 	', substring(., 1, 1))]">
75 <value-of select="substring($nextline, 1, string-length($nextline)-1)"/>
78 <value-of select="$nextline"/>
89 <if test="substring-after(., '%%')!=''">
91 <value-of select="substring-after(., '%%')"/>