]> Lady’s Gitweb - Shushe/commitdiff
Simplify 书社:literally transform output
authorLady <redacted>
Mon, 27 May 2024 19:46:56 +0000 (15:46 -0400)
committerLady <redacted>
Thu, 11 Jul 2024 01:46:30 +0000 (21:46 -0400)
Use literal result elements and attributes in cases where it is safe to
do so.

lib/catalog2transform.xslt
lib/literally.xslt

index af7fd6fc87e25bc787b0fbb27743b409c4338dc8..6479216fb915a8439b5194ba306bfa741ec66dc2 100644 (file)
@@ -44,7 +44,9 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                        <xslt:param name="THISREV" select="false()"/>
                        <xslt:variable name="书社:source" select="/"/>
                        <xslt:variable name="书社:about-fragment">
-                               <apply-templates select="document($METADATA)" mode="书社:literally"/>
+                               <apply-templates select="document($METADATA)" mode="书社:literally">
+                                       <with-param name="extension-element-namespaces" select="'http://exslt.org/common http://exslt.org/strings'"/>
+                               </apply-templates>
                        </xslt:variable>
                        <xslt:variable name="书社:about" select="exsl:node-set($书社:about-fragment)"/>
                        <xslt:variable name="书社:expansion-fragment">
index 203dfd30d9b018615e1b988fed354a42f3d03eed..d929f2f61a5a63e1f8f28f95d7b1445221d94585 100644 (file)
@@ -18,8 +18,9 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        version="1.0"
 >
        <template match="node()" mode="书社:literally">
+               <param name="extension-element-namespaces"/>
                <choose>
-                       <when test="self::*">
+                       <when test="self::* and contains(concat(' http://www.w3.org/1999/XSL/Transform ', normalize-space($extension-element-namespaces), ' '), concat(' ', namespace-uri(), ' '))">
                                <xslt:element name="{name()}" namespace="{namespace-uri()}">
                                        <for-each select="@*">
                                                <xslt:attribute name="{name()}" namespace="{namespace-uri()}">
@@ -31,6 +32,23 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                        <apply-templates mode="书社:literally"/>
                                </xslt:element>
                        </when>
+                       <when test="self::*">
+                               <element name="{name()}" namespace="{namespace-uri()}">
+                                       <for-each select="@*[not(contains(., '{') or contains(., '}'))]">
+                                               <attribute name="{name()}" namespace="{namespace-uri()}">
+                                                       <value-of select="."/>
+                                               </attribute>
+                                       </for-each>
+                                       <for-each select="@*[contains(., '{') or contains(., '}')]">
+                                               <xslt:attribute name="{name()}" namespace="{namespace-uri()}">
+                                                       <xslt:text>
+                                                               <value-of select="."/>
+                                                       </xslt:text>
+                                               </xslt:attribute>
+                                       </for-each>
+                                       <apply-templates mode="书社:literally"/>
+                               </element>
+                       </when>
                        <when test="self::text()">
                                <xslt:text>
                                        <value-of select="."/>
This page took 0.029082 seconds and 4 git commands to generate.