3 ⁌ ⛩️📰 书社 ∷ parsers/tsv.xslt
5 © 2023–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 <import href="../lib/split.xslt"/>
20 <书社:id>urn:fdc:ladys.computer:20231231:Shu1She4:tsv.xslt</书社:id>
21 <template match="html:script[@type='text/tab-separated-values']">
22 <variable name="rows" select="exslstr:tokenize(., '
')[normalize-space(.)!='' and not(starts-with(., '#'))]"/>
23 <variable name="head" select="$rows[1]"/>
24 <variable name="headcols">
25 <call-template name="书社:split">
26 <with-param name="source" select="string($head)"/>
27 <with-param name="separator" select="'	'"/>
30 <variable name="body" select="$rows[not(position()=1)]"/>
34 <for-each select="exsl:node-set($headcols)/*">
36 <value-of select="."/>
42 <for-each select="$body">
43 <variable name="cols">
44 <call-template name="书社:split">
45 <with-param name="source" select="string(.)"/>
46 <with-param name="separator" select="'	'"/>
50 <for-each select="exsl:node-set($cols)/*[count(exsl:node-set($headcols)/*)>position()]">
52 <value-of select="."/>
53 <if test="position()=count(exsl:node-set($headcols)/*)">
54 <for-each select="following-sibling:*">
56 <value-of select="."/>
61 <for-each select="exsl:node-set($headcols)/*[position()>count(exsl:node-set($cols)/*)]">