]> Lady’s Gitweb - Shushe/blob - lib/literally.xslt
Don’t use literal result elements in transforms
[Shushe] / lib / literally.xslt
1 <?xml version="1.0"?>
2 <!--
3 SPDX-FileCopyrightText: 2024 Lady <https://www.ladys.computer/about/#lady>
4 SPDX-License-Identifier: MPL-2.0
5 -->
6 <!--
7 ⁌ ⛩📰 书社 ∷ lib/literally.xslt
8
9 © 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:xslt="http://www.w3.org/1999/XSL/TransformAlias"
17 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
18 version="1.0"
19 >
20 <template match="node()" mode="书社:literally">
21 <param name="extension-element-namespaces"/>
22 <choose>
23 <when test="self::* and contains(concat(' http://www.w3.org/1999/XSL/Transform ', normalize-space($extension-element-namespaces), ' '), concat(' ', namespace-uri(), ' '))">
24 <xslt:element name="{name()}" namespace="{namespace-uri()}">
25 <for-each select="@*">
26 <xslt:attribute name="{name()}" namespace="{namespace-uri()}">
27 <xslt:text>
28 <value-of select="."/>
29 </xslt:text>
30 </xslt:attribute>
31 </for-each>
32 <apply-templates mode="书社:literally"/>
33 </xslt:element>
34 </when>
35 <when test="self::*">
36 <element name="{name()}" namespace="{namespace-uri()}">
37 <for-each select="@*[not(contains(., '{') or contains(., '}'))]">
38 <attribute name="{name()}" namespace="{namespace-uri()}">
39 <value-of select="."/>
40 </attribute>
41 </for-each>
42 <for-each select="@*[contains(., '{') or contains(., '}')]">
43 <xslt:attribute name="{name()}" namespace="{namespace-uri()}">
44 <xslt:text>
45 <value-of select="."/>
46 </xslt:text>
47 </xslt:attribute>
48 </for-each>
49 <apply-templates mode="书社:literally"/>
50 </element>
51 </when>
52 <when test="self::text()">
53 <xslt:text>
54 <value-of select="."/>
55 </xslt:text>
56 </when>
57 <when test="self::processing-instruction()">
58 <xslt:processing-instruction name="{local-name()}">
59 <xslt:text>
60 <value-of select="."/>
61 </xslt:text>
62 </xslt:processing-instruction>
63 </when>
64 <when test="self::comment()">
65 <xslt:comment>
66 <xslt:text>
67 <value-of select="."/>
68 </xslt:text>
69 </xslt:comment>
70 </when>
71 <otherwise>
72 <apply-templates mode="书社:literally"/>
73 </otherwise>
74 </choose>
75 </template>
76 </transform>
This page took 0.051635 seconds and 5 git commands to generate.