]> Lady’s Gitweb - Shushe/commitdiff
Do not wrap results which contain no H·T·M·L
authorLady <redacted>
Mon, 27 May 2024 20:16:44 +0000 (16:16 -0400)
committerLady <redacted>
Thu, 11 Jul 2024 01:46:30 +0000 (21:46 -0400)
It’s much more likely that a result which is not H·T·M·L is intended to
remain that way; wrapping it in `<html:body>` can be used as a
work·around when H·T·M·L wrapping is desired.

README.markdown
lib/catalog2transform.xslt

index bed7a115a4f5fa6a1db7ab165669523d07e872f8..013e3ede21843de1ae5653e6928afe4e682d696d 100644 (file)
@@ -625,11 +625,17 @@ The following params are only available in transforms :⁠—
 
 ## Output Wrapping
 
-⛩📰 书社 will wrap the final output of the transforms in appropriate
-  `<html:html>` and `<html:body>` elements, so it is not necessary for
-  transforms to do this explicitly.
-After performing the initial transform, ⛩📰 书社 will match the root
-  node of the result in the following modes to fill in areas of the
+Provided at least one toplevel result element belongs to the H·T·M·L
+  namespace, ⛩📰 书社 will wrap the final output of the transforms in
+  appropriate `<html:html>` and `<html:body>` elements, so it is not
+  necessary for transforms to do this explicitly.
+If a toplevel result element _is_ a `<html:html>` and `<html:body>`
+  element, it will be merged with the one that ⛩📰 书社 creates.
+Consequently, wrapping the result in a `<html:body>` element can be
+  used to enable wrapping for non‐H·T·M·L content, when desired.
+
+As a part of this process, after performing the initial transform
+  ⛩📰 书社 will match in the following modes to fill in areas of the
   wrapper :⁠—
 
 - **`书社:header`:**
@@ -644,16 +650,14 @@ After performing the initial transform, ⛩📰 书社 will match the root
   The result of matching in this mode is inserted into the
     `<html:head>` of the output.
 
-In addition to being called with the transform result, each of these
-  modes will additionally be called with a `<xslt:include>` element
-  corresponding to each transform.
-If a transform has a `<书社:id>` top‐level element whose value is an
-  i·r·i, its `<xslt:include>` element will have a corresponding
-  `@书社:id` attribute.
-This mechanism can be used to allow transforms to insert content
-  without matching any elements in the result; for example, the
-  following transform adds a link to a stylesheet to the `<html:head>`
-  of every page :⁠—
+The document being matched will contain the full transform result
+  prior to wrapping as well as an `<xslt:include>` element (with an
+  `@书社:id` attribute) for each transform which has a valid
+  `<书社:id>`.
+The latter elements can be matched to enable transforms to provide
+  content _without_ matching any elements in the result; for example,
+  the following transform adds a link to a stylesheet to the
+  `<html:head>` of every page :⁠—
 
 ```xml
 <?xml version="1.0"?>
@@ -677,7 +681,8 @@ Output wrapping can be entirely disabled by adding a
   the result tree.
 It will not be performed on outputs whose root elements are
   `<书社:archive>`, `<书社:base64-binary>`, or `<书社:raw-text>`
-  (described below).
+  (described below), or on result trees which do not contain a toplevel
+  element in the H·T·M·L namespace.
 
 ## Applying Attributes
 
index 6479216fb915a8439b5194ba306bfa741ec66dc2..74f7f46b4edf3fdc5f78502664f7584ae58b9941 100644 (file)
@@ -265,7 +265,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                <xslt:variable name="result-nodes" select="$书社:result/node()[not(self::书社:apply-attributes-to-root)]|$书社:result/书社:apply-attributes-to-root/descendant::node()[not(self::书社:apply-attributes-to-root) and not(ancestor::*[not(self::书社:apply-attributes-to-root)])]"/>
                                <xslt:variable name="root-with-attributes">
                                        <xslt:choose>
-                                               <xslt:when test="$result-nodes/self::书社:*[local-name()='raw-text' or local-name()='base64-binary' or local-name()='archive']|$result-nodes/@书社:disable-output-wrapping|$书社:result//书社:apply-attributes-to-root/@书社:disable-output-wrapping">
+                                               <xslt:when test="not($result-nodes/self::html:*) or $result-nodes/self::书社:*[local-name()='raw-text' or local-name()='base64-binary' or local-name()='archive'] or $result-nodes/@书社:disable-output-wrapping or $书社:result//书社:apply-attributes-to-root/@书社:disable-output-wrapping">
                                                        <xslt:call-template name="书社:apply-attributes">
                                                                <xslt:with-param name="and-version" select="true()"/>
                                                                <xslt:with-param name="context-nodes" select="$书社:result//书社:apply-attributes-to-root"/>
This page took 0.078754 seconds and 4 git commands to generate.