]> Lady’s Gitweb - Shushe/commitdiff
Pass single result tree to modes in wrapper 0.4.2
authorLady <redacted>
Sat, 20 Jan 2024 17:02:33 +0000 (12:02 -0500)
committerLady <redacted>
Sat, 20 Jan 2024 17:06:56 +0000 (12:06 -0500)
When matching a `<xslt:include>` inside of a `书社:metadata` transform,
it’s useful to be able to easily match elements in the result. Right
now, that requires a reference to the little‐documented variable
`$书社:result`, because `<xslt:include>` elements don’t belong to the
same document as result tree elements.

This commit creates a new tree which simply copies over all the result
nodes and all of the `<xslt:include>` elements, and then passes that to
the modal templates. Consequently, matches like `/html:div` or
`/xslt:include` should work regardless of what the current context node
is.

lib/catalog2transform.xslt

index 1d36bb1ed9afa8b72facdd8885fcc3a73014b77b..92dcaf95cfa985fdd86d25b5bfba967406476789 100644 (file)
@@ -121,10 +121,13 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                        <xslt:template match="text()" mode="书社:footer"/>
                        <xslt:template match="text()" mode="书社:metadata"/>
                        <xslt:template match="/" mode="书社:wrap">
+                               <xslt:variable name="modalinput">
+                                       <xslt:copy-of select="node()"/>
+                                       <xslt:copy-of select="document('')/xslt:transform/xslt:include"/>
+                               </xslt:variable>
                                <xslt:variable name="metadata">
                                        <xslt:copy-of select="html:html/html:head/node()|html:head/node()"/>
-                                       <xslt:apply-templates select="." mode="书社:metadata"/>
-                                       <xslt:apply-templates select="document('')/xslt:transform/xslt:include" mode="书社:metadata"/>
+                                       <xslt:apply-templates select="exsl:node-set($modalinput)" mode="书社:metadata"/>
                                </xslt:variable>
                                <html:html>
                                        <xslt:if test="$VERSION">
@@ -166,11 +169,9 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                        </html:head>
                                        <html:body>
                                                <xslt:copy-of select="html:html/html:body/@*|html:body/@*"/>
-                                               <xslt:apply-templates select="document('')/xslt:transform/xslt:include" mode="书社:header"/>
-                                               <xslt:apply-templates select="." mode="书社:header"/>
+                                               <xslt:apply-templates select="exsl:node-set($modalinput)" mode="书社:header"/>
                                                <xslt:copy-of select="node()[not(self::html:html or self::html:head or self::html:body)]|html:html/node()[not(self::html:head or self::html:body)]|html:html/html:body/node()|html:body/node()"/>
-                                               <xslt:apply-templates select="." mode="书社:footer"/>
-                                               <xslt:apply-templates select="document('')/xslt:transform/xslt:include" mode="书社:footer"/>
+                                               <xslt:apply-templates select="exsl:node-set($modalinput)" mode="书社:footer"/>
                                        </html:body>
                                </html:html>
                        </xslt:template>
This page took 0.027162 seconds and 4 git commands to generate.