+ </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-fragment">
+ <xslt:copy-of select="$nodes"/>
+ <apply-templates select="exsl:node-set($unique-ids)" mode="书社:literally"/>
+ </xslt:variable>
+ <xslt:variable name="modalinput" select="exsl:node-set($modalinput-fragment)"/>
+ <xslt:variable name="metadata-fragment">
+ <xslt:copy-of select="$nodes[self::html:html]/html:head/node()|$nodes[self::html:head]/node()"/>
+ <xslt:apply-templates select="$modalinput/node()" mode="书社:metadata"/>
+ </xslt:variable>
+ <xslt:variable name="metadata" select="exsl:node-set($metadata-fragment)"/>
+ <xslt:element name="html" namespace="&xhtml;">
+ <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>
+ <xslt:element name="head" namespace="&xhtml;">
+ <xslt:copy-of select="$nodes[self::html:html]/html:head/@*|$nodes[self::html:head]/@*"/>
+ <xslt:element name="title" namespace="&xhtml;">
+ <xslt:for-each select="$metadata/html:title">
+ <xslt:value-of select="."/>
+ <xslt:if test="position()!=last()">
+ <xslt:text>
+ <text> </text>
+ </xslt:text>
+ </xslt:if>
+ </xslt:for-each>
+ </xslt:element>
+ <xslt:copy-of select="$metadata/node()[not(self::html:title or self::html:meta and @name='generator')]"/>
+ <xslt:element name="meta" namespace="&xhtml;">
+ <xslt:attribute name="name">
+ <xslt:text>
+ <text>generator</text>
+ </xslt:text>
+ </xslt:attribute>
+ <xslt:attribute name="content">
+ <xslt:for-each select="$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>
+ </xslt:element>
+ </xslt:element>
+ <xslt:element name="body" namespace="&xhtml;">
+ <xslt:copy-of select="$nodes[self::html:html]/html:body/@*|$nodes[self::html:body]/@*"/>
+ <xslt:apply-templates select="$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="$modalinput/node()" mode="书社:footer"/>
+ </xslt:element>
+ </xslt:element>
+ </xslt:template>
+ <xslt:template match="/">
+ <xslt:variable name="finalization-fragment">
+ <xslt:apply-templates select="$书社:result" mode="书社:finalize"/>
+ </xslt:variable>
+ <xslt:copy-of select="书社:document-with-attributes-applied(exsl:node-set($finalization-fragment))"/>