]> Lady’s Gitweb - Shushe/blob - transforms/serialization.xslt
Redirect messages to stderr & support disabling
[Shushe] / transforms / serialization.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 ⁌ ⛩️📰 书社 ∷ transforms/serialization.xslt
8
9 © 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/serialize.xslt"/>
24 <书社:id>urn:fdc:ladys.computer:20231231:Shu1She4:serialization.xslt</书社:id>
25 <template match="书社:serialize-xml" mode="书社:application" priority="1">
26 <variable name="namespaces" select="namespace::*"/>
27 <variable name="contents">
28 <apply-templates mode="书社:application"/>
29 </variable>
30 <variable name="passthru-namespaces" select="exslstr:tokenize(string(@with-namespaces))"/>
31 <apply-templates select="exsl:node-set($contents)" mode="书社:serialize">
32 <with-param name="namespace">
33 <value-of select="namespace::*[local-name()='']"/>
34 </with-param>
35 <with-param name="declare-namespaces">
36 <if test="$passthru-namespaces[string(.)='xml']">
37 <text> http://www.w3.org/XML/1998/namespace</text>
38 </if>
39 <for-each select="namespace::*[local-name()!='xml']">
40 <if test="local-name()='' and $passthru-namespaces[string(.)='#default'] or $passthru-namespaces[string(.)=local-name(current())]">
41 <text> </text>
42 <value-of select="string(.)"/>
43 </if>
44 </for-each>
45 <text> </text>
46 </with-param>
47 <with-param name="prefix-map">
48 <html:dl>
49 <html:div>
50 <html:dt>xml</html:dt>
51 <html:dd>http://www.w3.org/XML/1998/namespace</html:dd>
52 </html:div>
53 <for-each select="namespace::*[local-name()!='' and local-name()!='xml']">
54 <html:div>
55 <html:dt>
56 <value-of select="local-name()"/>
57 </html:dt>
58 <html:dd>
59 <value-of select="string(.)"/>
60 </html:dd>
61 </html:div>
62 </for-each>
63 </html:dl>
64 </with-param>
65 </apply-templates>
66 </template>
67 <template match="书社:raw-output" mode="书社:serialize" priority="1">
68 <copy-of select=".//text()"/>
69 </template>
70 </transform>
This page took 0.091164 seconds and 5 git commands to generate.