3 ⁌ ⛩️📰 书社 ∷ parsers/record-jar.xslt
5 © 2024 Lady [@ Lady’s Computer]
7 This Source Code Form is subject to the terms of the Mozilla Public License, v 2.0.
8 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/>.
11 xmlns="http://www.w3.org/1999/XSL/Transform"
12 xmlns:exsl="http://exslt.org/common"
13 xmlns:exslstr="http://exslt.org/strings"
14 xmlns:html="http://www.w3.org/1999/xhtml"
15 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
16 exclude-result-prefixes="exsl exslstr"
19 <书社:id>urn:fdc:ladys.computer:20231231:Shu1She4:record-jar.xslt</书社:id>
20 <template match="html:script[@type='text/record-jar']">
21 <variable name="lines" select="exslstr:tokenize(., '
')"/>
22 <html:div class="record-jar">
23 <for-each select="$lines[not(position()=1) and starts-with(., '%%')]">
24 <variable name="end" select="."/>
25 <variable name="start" select="preceding-sibling::*[starts-with(., '%%')][1]"/>
26 <variable name="fields" select="($start/following-sibling::*|$lines[not($start)])[not(preceding-sibling::*[generate-id()=generate-id($end)]) and not(starts-with(., '%%'))]"/>
29 <for-each select="$fields">
31 <when test="starts-with(., ' ') and $fields[generate-id()=generate-id(current()/preceding-sibling::*[1])]"/>
33 <variable name="next" select="following-sibling::*[not(starts-with(., ' '))]"/>
36 <value-of select="normalize-space(substring-before(., ':'))"/>
39 <variable name="firstline">
41 <when test="contains(., ':')">
42 <value-of select="normalize-space(substring-after(., ':'))"/>
45 <value-of select="normalize-space(.)"/>
50 <when test="substring($firstline, string-length($firstline))='\' and following-sibling::*[position()=1 and starts-with(., ' ')]">
51 <value-of select="substring($firstline, 1, string-length($firstline)-1)"/>
54 <value-of select="$firstline"/>
57 <for-each select="following-sibling::*[starts-with(., ' ') and not(preceding-sibling::*[generate-id()=generate-id($next)])]">
58 <variable name="nextline" select="normalize-space(.)"/>
60 <when test="substring($nextline, string-length($nextline))='\' and following-sibling::*[position()=1 and starts-with(., ' ')]">
61 <value-of select="substring($nextline, 1, string-length($nextline)-1)"/>
64 <value-of select="$nextline"/>