]> Lady’s Gitweb - Shushe/blob - parsers/tsv.xslt
Allow creation of tarballs
[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 [@ Lady’s 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 <value-of select="."/>
57 <if test="position()=count(exsl:node-set($headcols)/*)">
58 <for-each select="following-sibling:*">
59 <text>&#x9;</text>
60 <value-of select="."/>
61 </for-each>
62 </if>
63 </html:td>
64 </for-each>
65 <for-each select="exsl:node-set($headcols)/*[position()>count(exsl:node-set($cols)/*)]">
66 <html:td/>
67 </for-each>
68 </html:tr>
69 </for-each>
70 </html:tbody>
71 </html:table>
72 </template>
73 </transform>
This page took 0.066806 seconds and 5 git commands to generate.