+++ /dev/null
-<?xml version="1.0"?>
-<!--
-SPDX-FileCopyrightText: 2024 Lady <https://www.ladys.computer/about/#lady>
-SPDX-License-Identifier: MPL-2.0
--->
-<!--
-⁌ ⛩️📰 书社 ∷ lib/paged2extractor.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:exsl="http://exslt.org/common"
- xmlns:exslstr="http://exslt.org/strings"
- 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"/>
- <param name="NAME"/>
- <template match="/">
- <xslt:transform extension-element-prefixes="exsl exslstr" version="1.0">
- <xslt:template match="@*|node()">
- <xslt:param name="destination" select="''"/>
- <xslt:choose>
- <xslt:when test="self::书社:page">
- <xslt:apply-templates>
- <xslt:with-param name="destination" select="$destination"/>
- </xslt:apply-templates>
- </xslt:when>
- <xslt:when test="$destination='' and not(ancestor::书社:page) or string(ancestor::书社:page[1]/@书社:destination)=$destination">
- <xslt:copy>
- <xslt:apply-templates>
- <xslt:with-param name="destination" select="$destination"/>
- </xslt:apply-templates>
- </xslt:copy>
- </xslt:when>
- <xslt:otherwise>
- <xslt:apply-templates>
- <xslt:with-param name="destination" select="$destination"/>
- </xslt:apply-templates>
- </xslt:otherwise>
- </xslt:choose>
- </xslt:template>
- <xslt:template match="/" priority="1">
- <exsl:document href="./pages/{$NAME}" method="xml" encoding="UTF-8">
- <xslt:apply-templates/>
- </exsl:document>
- <xslt:text>
- <text>./pages/</text>
- <value-of select="$NAME"/>
- <text>
</text>
- </xslt:text>
- <for-each select="//书社:page[@书社:destination]">
- <if test="not(ancestor::书社:page[@书社:destination=current()/@书社:destination] or preceding::书社:page[@书社:destination=current()/@书社:destination])">
- <variable name="href">
- <text>./pages/</text>
- <value-of select="exslstr:tokenize(@书社:destination, '/')[last()]"/>
- </variable>
- <exsl:document href="{$href}" method="xml" encoding="UTF-8">
- <xslt:apply-templates>
- <xslt:with-param name="destination">
- <value-of select="@书社:destination"/>
- </xslt:with-param>
- </xslt:apply-templates>
- </exsl:document>
- <xslt:text>
- <choose>
- <when test="contains($href, '%22%7B')">
- <value-of select="substring-before($href, '%22%7B')"/>
- <text>"{</text>
- <value-of select="substring-before(substring-after($href, '%22%7B'), '%7D%22')"/>
- <text>}"</text>
- <value-of select="substring-after(substring-after($href, '%22%7B'), '%7D%22')"/>
- </when>
- <otherwise>
- <value-of select="$href"/>
- </otherwise>
- </choose>
- <text>
</text>
- </xslt:text>
- </if>
- </for-each>
- </xslt:template>
- <xslt:output method="text" encoding="UTF-8"/>
- </xslt:transform>
- </template>
- <output method="xml" encoding="UTF-8"/>
-</transform>