]> Lady’s Gitweb - Shushe/blob - parsers/tsv.xslt
Add nfo:fileName to file metadata
[Shushe] / parsers / tsv.xslt
1 <?xml version="1.0"?>
2 <!--
3 SPDX-FileCopyrightText: 2023, 2024 Lady <https://www.ladys.computer/about/#lady>
4 SPDX-License-Identifier: MPL-2.0
5 -->
6 <!--
7 ⁌ ⛩📰 书社 ∷ parsers/tsv.xslt
8
9 © 2023–2024 Lady [@ Ladys 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:html="http://www.w3.org/1999/xhtml"
19 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
20 extension-element-prefixes="exsl exslstr"
21 version="1.0"
22 >
23 <import href="../lib/split.xslt"/>
24 <书社:id>urn:fdc:ladys.computer:20231231:Shu1She4:tsv.xslt</书社:id>
25 <template match="html:script[@type='text/tab-separated-values']">
26 <variable name="rows" select="exslstr:tokenize(., '&#xA;')[normalize-space(.)!='' and not(starts-with(., '#'))]"/>
27 <variable name="head" select="$rows[1]"/>
28 <variable name="headcols">
29 <call-template name="书社:split">
30 <with-param name="source" select="string($head)"/>
31 <with-param name="separator" select="'&#x9;'"/>
32 </call-template>
33 </variable>
34 <variable name="body" select="$rows[not(position()=1)]"/>
35 <html:table>
36 <html:thead>
37 <html:tr>
38 <for-each select="exsl:node-set($headcols)/*">
39 <html:th scope="col">
40 <value-of select="."/>
41 </html:th>
42 </for-each>
43 </html:tr>
44 </html:thead>
45 <html:tbody>
46 <for-each select="$body">
47 <variable name="cols">
48 <call-template name="书社:split">
49 <with-param name="source" select="string(.)"/>
50 <with-param name="separator" select="'&#x9;'"/>
51 </call-template>
52 </variable>
53 <html:tr>
54 <for-each select="exsl:node-set($cols)/*[count(exsl:node-set($headcols)/*)>=position()]">
55 <html:td>
56 <attribute name="data-tsv-header">
57 <value-of select="exsl:node-set($headcols)/*[count(current()/preceding-sibling::*)+1]"/>
58 </attribute>
59 <value-of select="."/>
60 <if test="position()=count(exsl:node-set($headcols)/*)">
61 <for-each select="following-sibling::*">
62 <text>&#x9;</text>
63 <value-of select="."/>
64 </for-each>
65 </if>
66 </html:td>
67 </for-each>
68 <for-each select="exsl:node-set($headcols)/*[position()>count(exsl:node-set($cols)/*)]">
69 <html:td/>
70 </for-each>
71 </html:tr>
72 </for-each>
73 </html:tbody>
74 </html:table>
75 </template>
76 </transform>
This page took 0.086478 seconds and 5 git commands to generate.