3 ⁌ ⛩️📰 书社 ∷ lib/catalog2parser.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: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"
21 <namespace-alias stylesheet-prefix="xslt" result-prefix="#default"/>
23 <xslt:transform version="1.0">
24 <xslt:variable name="书社:parsers">
26 <for-each select="//catalog:uri">
27 <variable name="parser" select="document(@uri, .)"/>
30 <value-of select="@name"/>
33 <when test="$parser/*/@书社:supported-media-types">
34 <for-each select="exslstr:tokenize($parser/*/@书社:supported-media-types)">
35 <if test="not(translate(., '0123456789abcdefghijklmnopqrstuvwxyz!#$&-^_.+/', ''))">
37 <value-of select="."/>
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()"/>
49 <text>script[@type=</text>
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, '"') and substring($inner, string-length($inner))='"' or starts-with($inner, "'") and substring($inner, string-length($inner))="'"">
54 <variable name="type" select="substring($inner, 2, string-length($inner)-2)"/>
55 <if test="not(translate($type, '0123456789abcdefghijklmnopqrstuvwxyz!#$&-^_.+/', ''))">
57 <value-of select="$type"/>
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"/>
79 <xslt:template match="@*|node()" priority="-1">
81 <xslt:apply-templates select="@*|node()"/>
86 <output method="xml" encoding="UTF-8"/>