+ </xslt:when>
+ <xslt:otherwise>
+ <xslt:copy-of select="."/>
+ </xslt:otherwise>
+ </xslt:choose>
+ </xslt:for-each>
+ </xslt:template>
+ <xslt:template name="书社:wrap">
+ <xslt:param name="nodes" select="/.."/>
+ <xslt:variable name="modalinput">
+ <xslt:copy-of select="$nodes"/>
+ <xslt:copy-of select="document('')/xslt:transform/xslt:include"/>
+ </xslt:variable>
+ <xslt:variable name="metadata">
+ <xslt:copy-of select="$nodes[self::html:html]/html:head/node()|$nodes[self::html:head]/node()"/>
+ <xslt:apply-templates select="exsl:node-set($modalinput)/node()" mode="书社:metadata"/>
+ </xslt:variable>
+ <html:html>
+ <xslt:copy-of select="$nodes[self::html:html]/@*"/>
+ <xslt:if test="not($nodes[self::html:html]/@书社:archived-as) and $nodes/@书社:archived-as">
+ <xslt:attribute name="书社:archived-as">
+ <xslt:value-of select="$nodes/@书社:archived-as"/>
+ </xslt:attribute>
+ </xslt:if>
+ <xslt:if test="not($nodes[self::html:html]/@lang) and $nodes[self::html:*]/@lang|$nodes[self::svg:*]/@lang|$nodes/@xml:lang">
+ <xslt:attribute name="lang">
+ <xslt:value-of select="$nodes[self::html:*]/@lang|$nodes[self::svg:*]/@lang|$nodes/@xml:lang"/>
+ </xslt:attribute>
+ </xslt:if>
+ <xslt:if test="not($nodes[self::html:html]/@xml:lang) and $nodes[self::html:*]/@lang|$nodes[self::svg:*]/@lang|$nodes/@xml:lang">
+ <xslt:attribute name="xml:lang">
+ <xslt:value-of select="$nodes[self::html:*]/@lang|$nodes[self::svg:*]/@lang|$nodes/@xml:lang"/>
+ </xslt:attribute>
+ </xslt:if>
+ <html:head>
+ <xslt:copy-of select="$nodes[self::html:html]/html:head/@*|$nodes[self::html:head]/@*"/>
+ <html:title>
+ <xslt:for-each select="exsl:node-set($metadata)/html:title">
+ <xslt:value-of select="."/>
+ <xslt:if test="position()!=last()">
+ <xslt:text>
+ <text> </text>
+ </xslt:text>
+ </xslt:if>
+ </xslt:for-each>
+ </html:title>
+ <xslt:copy-of select="exsl:node-set($metadata)/node()[not(self::html:title)]"/>
+ <html:meta name="generator">
+ <xslt:attribute name="content">
+ <xslt:for-each select="exsl:node-set($metadata)/html:meta[@name='generator']">
+ <xslt:value-of select="@content"/>
+ <xslt:text>
+ <text>, </text>
+ </xslt:text>
+ </xslt:for-each>
+ <xslt:text>
+ <text>⛩️📰 书社</text>
+ </xslt:text>
+ <xslt:if test="$THISREV">
+ <xslt:text>
+ <text> (</text>
+ </xslt:text>
+ <xslt:value-of select="$THISREV"/>
+ <xslt:text>
+ <text>)</text>
+ </xslt:text>
+ </xslt:if>
+ </xslt:attribute>
+ </html:meta>
+ </html:head>
+ <html:body>
+ <xslt:copy-of select="$nodes[self::html:html]/html:body/@*|$nodes[self::html:body]/@*"/>
+ <xslt:apply-templates select="exsl:node-set($modalinput)/node()" mode="书社:header"/>
+ <xslt:copy-of select="$nodes[not(self::html:html or self::html:head or self::html:body)]|$nodes[self::html:html]/node()[not(self::html:head or self::html:body)]|$nodes[self::html:html]/html:body/node()|$nodes[self::html:body]/node()"/>
+ <xslt:apply-templates select="exsl:node-set($modalinput)/node()" mode="书社:footer"/>
+ </html:body>
+ </html:html>
+ </xslt:template>
+ <xslt:template match="/" priority="1">
+ <xslt:variable name="result-nodes" select="exsl:node-set($书社:result)/node()[not(self::书社:apply-attributes-to-root)]|exsl:node-set($书社: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|exsl:node-set($书社: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="exsl:node-set($书社:result)//书社:apply-attributes-to-root"/>
+ <xslt:with-param name="destination-nodes" select="$result-nodes"/>
+ </xslt:call-template>
+ </xslt:when>
+ <xslt:otherwise>
+ <xslt:variable name="wrapped-result">
+ <xslt:call-template name="书社:wrap">
+ <xslt:with-param name="nodes" select="$result-nodes"/>
+ </xslt:call-template>
+ </xslt:variable>
+ <xslt:call-template name="书社:apply-attributes">
+ <xslt:with-param name="and-version" select="true()"/>
+ <xslt:with-param name="context-nodes" select="exsl:node-set($书社:result)//书社:apply-attributes-to-root"/>
+ <xslt:with-param name="destination-nodes" select="exsl:node-set($wrapped-result)/node()"/>
+ </xslt:call-template>
+ </xslt:otherwise>
+ </xslt:choose>
+ </xslt:variable>
+ <xslt:apply-templates select="exsl:node-set($root-with-attributes)/node()" mode="书社:application"/>