]> Lady’s Gitweb - Shushe/blobdiff - lib/archive2extractor.xslt
Allow creation of tarballs
[Shushe] / lib / archive2extractor.xslt
diff --git a/lib/archive2extractor.xslt b/lib/archive2extractor.xslt
new file mode 100644 (file)
index 0000000..b5fb703
--- /dev/null
@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+<!--
+SPDX-FileCopyrightText: 2024 Lady <https://www.ladys.computer/about/#lady>
+SPDX-License-Identifier: MPL-2.0
+-->
+<!--
+⁌ ⛩️📰 书社 ∷ lib/archive2extractor.xslt
+
+© 2024 Lady [@ Lady’s Computer].
+
+This Source Code Form is subject to the terms of the Mozilla Public License, v 2.0.
+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/>.
+-->
+<transform
+       xmlns="http://www.w3.org/1999/XSL/Transform"
+       xmlns:xslt="http://www.w3.org/1999/XSL/TransformAlias"
+       xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
+       version="1.0"
+>
+       <namespace-alias stylesheet-prefix="xslt" result-prefix="#default"/>
+       <template match="/">
+               <xslt:transform
+                       xmlns:exsl="http://exslt.org/common"
+                       extension-element-prefixes="exsl"
+                       version="1.0"
+               >
+                       <xslt:template match="/">
+                               <for-each select="书社:archive/*[@书社:archived-as and not(starts-with(@书社:archived-as, '../') or contains(@书社:archived-as, '/../'))]">
+                                       <variable name="href">
+                                               <text>./extracted/</text>
+                                               <choose>
+                                                       <when test="starts-with(@书社:archived-as, './')">
+                                                               <value-of select="substring-after(@书社:archived-as, './')"/>
+                                                       </when>
+                                                       <otherwise>
+                                                               <value-of select="@书社:archived-as"/>
+                                                       </otherwise>
+                                               </choose>
+                                       </variable>
+                                       <exsl:document href="{$href}" method="xml" encoding="UTF-8">
+                                               <xslt:variable name="href">
+                                                       <value-of select="@书社:archived-as"/>
+                                               </xslt:variable>
+                                               <xslt:copy-of select="书社:archive/*[@书社:archived-as=$href][1]"/>
+                                       </exsl:document>
+                                       <xslt:text>
+                                               <value-of select="$href"/>
+                                               <text>&#xA;</text>
+                                       </xslt:text>
+                               </for-each>
+                       </xslt:template>
+                       <xslt:output method="text" encoding="UTF-8"/>
+               </xslt:transform>
+       </template>
+       <output method="xml" encoding="UTF-8"/>
+</transform>
This page took 0.207234 seconds and 4 git commands to generate.