]> Lady’s Gitweb - Shushe/blob - lib/catalog2parser.xslt
ead56da91dab9bd2916beda213937a7100703e2c
[Shushe] / lib / catalog2parser.xslt
1 <?xml version="1.0"?>
2 <!--
3 ⁌ ⛩️📰 书社 ∷ lib/catalog2parser.xslt
4
5 © 2023–2024 Lady [@ Lady’s Computer]
6
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/>.
9 -->
10 <transform
11 xmlns="http://www.w3.org/1999/XSL/Transform"
12 xmlns:catalog="urn:oasis:names:tc:entity:xmlns:xml:catalog"
13 xmlns:exslstr="http://exslt.org/strings"
14 xmlns:html="http://www.w3.org/1999/xhtml"
15 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
16 xmlns:xslt="http://www.w3.org/1999/XSL/TransformAlias"
17 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
18 exclude-result-prefixes="catalog exslstr"
19 version="1.0"
20 >
21 <namespace-alias stylesheet-prefix="xslt" result-prefix="#default"/>
22 <template match="/">
23 <xslt:transform version="1.0">
24 <xslt:variable name="书社:parsers">
25 <html:dl>
26 <for-each select="//catalog:uri">
27 <variable name="parser" select="document(@uri, .)"/>
28 <html:div>
29 <html:dt>
30 <value-of select="@name"/>
31 </html:dt>
32 <choose>
33 <when test="$parser/*/@书社:supported-media-types">
34 <for-each select="exslstr:tokenize($parser/*/@书社:supported-media-types)">
35 <if test="not(translate(., '0123456789abcdefghijklmnopqrstuvwxyz!#$&#x26;-^_.+/', ''))">
36 <html:dd>
37 <value-of select="."/>
38 </html:dd>
39 </if>
40 </for-each>
41 </when>
42 <otherwise>
43 <for-each select="$parser//xsl:template[not(@name) and not(@mode)]">
44 <variable name="match" select="@match"/>
45 <for-each select="namespace::*[local-name() and string()='http://www.w3.org/1999/xhtml']">
46 <variable name="matchstart">
47 <value-of select="local-name()"/>
48 <text>:</text>
49 <text>script[@type=</text>
50 </variable>
51 <if test="starts-with($match, $matchstart) and substring($match, string-length($match))=']' and contains($match, '/')">
52 <variable name="inner" select="substring-before(substring-after($match, $matchstart), ']')"/>
53 <if test="starts-with($inner, '&#x22;') and substring($inner, string-length($inner))='&#x22;' or starts-with($inner, &#x22;'&#x22;) and substring($inner, string-length($inner))=&#x22;'&#x22;">
54 <variable name="type" select="substring($inner, 2, string-length($inner)-2)"/>
55 <if test="not(translate($type, '0123456789abcdefghijklmnopqrstuvwxyz!#$&#x26;-^_.+/', ''))">
56 <html:dd>
57 <value-of select="$type"/>
58 </html:dd>
59 </if>
60 </if>
61 </if>
62 </for-each>
63 </for-each>
64 </otherwise>
65 </choose>
66 </html:div>
67 </for-each>
68 </html:dl>
69 </xslt:variable>
70 <for-each select="//catalog:uri">
71 <xslt:include href="{@uri}">
72 <if test="contains(@name, ':')">
73 <attribute name="书社:id">
74 <value-of select="@name"/>
75 </attribute>
76 </if>
77 </xslt:include>
78 </for-each>
79 <xslt:template match="@*|node()" priority="-1">
80 <xslt:copy>
81 <xslt:apply-templates select="@*|node()"/>
82 </xslt:copy>
83 </xslt:template>
84 </xslt:transform>
85 </template>
86 <output method="xml" encoding="UTF-8"/>
87 </transform>
This page took 0.054455 seconds and 3 git commands to generate.