X-Git-Url: https://git.ladys.computer/Shushe/blobdiff_plain/af8b42c720c6aaa54199b556a656d40e8b8951a6..7338b131dca1dee3159488ef23b8d2545f1a5289:/transforms/asset.xslt?ds=inline

diff --git a/transforms/asset.xslt b/transforms/asset.xslt
index 90c8dbd..89f1475 100644
--- a/transforms/asset.xslt
+++ b/transforms/asset.xslt
@@ -1,30 +1,84 @@
 <?xml version="1.0"?>
 <!--
-⁌ ⛩️📰 书社 ∷ transforms/asset.xslt
+SPDX-FileCopyrightText: 2023, 2024 Lady <https://www.ladys.computer/about/#lady>
+SPDX-License-Identifier: MPL-2.0
+-->
+<!--
+⁌ ⛩📰 书社 ∷ transforms/asset.xslt
 
-© 2023–2024 Lady [@ Lady’s Computer]
+© 2023–2024 Lady [@ Ladys 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/>.
 -->
+<!DOCTYPE transform [
+	<!ENTITY wrapped "ancestor::html:html[not(parent::* or @书社:disable-output-wrapping)]">
+	<!ENTITY xhtml "http://www.w3.org/1999/xhtml">
+]>
 <transform
 	xmlns="http://www.w3.org/1999/XSL/Transform"
-	xmlns:html="http://www.w3.org/1999/xhtml"
+	xmlns:exsl="http://exslt.org/common"
+	xmlns:html="&xhtml;"
 	xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
-	exclude-result-prefixes="书社"
+	extension-element-prefixes="exsl"
 	version="1.0"
 >
 	<书社:id>urn:fdc:ladys.computer:20231231:Shu1She4:asset.xslt</书社:id>
-	<template match="html:object[@type='text/css']">
-		<comment>
-			<text>[书社:CSS] </text>
-			<value-of select="@data"/>
-		</comment>
+	<template match="html:style[&wrapped; and not(ancestor::html:head)]|html:object[@type='text/css' and &wrapped;]" mode="书社:finalize" priority="0"/>
+	<template match="html:object[@type='text/javascript']" mode="书社:finalize" priority="0">
+		<element name="script" namespace="&xhtml;">
+			<attribute name="type">
+				<value-of select="@type"/>
+			</attribute>
+			<attribute name="src">
+				<value-of select="@data"/>
+			</attribute>
+			<copy-of select="@书社:identifier"/>
+		</element>
+	</template>
+	<template match="html:object[starts-with(@type, 'audio/')]" mode="书社:finalize" priority="0">
+		<element name="audio" namespace="&xhtml;">
+			<attribute name="controls"/>
+			<attribute name="src">
+				<value-of select="@data"/>
+			</attribute>
+			<copy-of select="@书社:identifier"/>
+		</element>
+	</template>
+	<template match="html:object[starts-with(@type, 'image/') and not(@type='image/svg+xml')]" mode="书社:finalize" priority="0">
+		<element name="img" namespace="&xhtml;">
+			<attribute name="src">
+				<value-of select="@data"/>
+			</attribute>
+			<copy-of select="@书社:identifier|@width|@height"/>
+		</element>
 	</template>
-	<template match="comment()[starts-with(., '[书社:CSS] ')]" mode="书社:metadata">
-		<html:link rel="stylesheet" type="text/css" href="{substring-after(., '[书社:CSS] ')}"/>
+	<template match="html:object[starts-with(@type, 'video/')]" mode="书社:finalize" priority="0">
+		<element name="video" namespace="&xhtml;">
+			<attribute name="controls"/>
+			<attribute name="src">
+				<value-of select="@data"/>
+			</attribute>
+			<copy-of select="@书社:identifier|@width|@height"/>
+		</element>
 	</template>
-	<template match="html:object[@type='text/javascript']">
-		<html:script type="{@type}" src="{@data}"/>
+	<template match="书社:id[string(.)='urn:fdc:ladys.computer:20231231:Shu1She4:asset.xslt']" mode="书社:metadata">
+		<for-each select="$书社:expansion//html:object[@type='text/css']">
+			<element name="link" namespace="&xhtml;">
+				<attribute name="rel">
+					<text>stylesheet</text>
+				</attribute>
+				<attribute name="type">
+					<text>text/css</text>
+				</attribute>
+				<attribute name="href">
+					<value-of select="@data"/>
+				</attribute>
+				<copy-of select="@书社:identifier"/>
+			</element>
+		</for-each>
+		<for-each select="$书社:expansion//html:style[not(ancestor::html:head)]">
+			<copy-of select="."/>
+		</for-each>
 	</template>
 </transform>