+                                                               <xslt:for-each select="exsl:node-set($attribute-names)/*">
+                                                                       <xslt:choose>
+                                                                               <xslt:when test="@namespace-uri='&xml;'"/>
+                                                                               <xslt:when test="$context[self::html:* or self::svg:*] and @namespace-uri='' and @local-name='lang'"/>
+                                                                               <xslt:when test="@namespace-uri='&书社;' and (@local-name='destination' or @local-name='disable-output-wrapping')"/>
+                                                                               <xslt:when test="preceding-sibling::*[@local-name=current()/@local-name and @namespace-uri=current()/@namespace-uri]"/>
+                                                                               <xslt:otherwise>
+                                                                                       <xslt:attribute>
+                                                                                               <attribute name="name">
+                                                                                                       <text>{@name}</text>
+                                                                                               </attribute>
+                                                                                               <attribute name="namespace">
+                                                                                                       <text>{@namespace-uri}</text>
+                                                                                               </attribute>
+                                                                                               <xslt:for-each select="$existing-attributes[local-name()=current()/@local-name and namespace-uri()=current()/@namespace-uri]">
+                                                                                                       <xslt:value-of select="."/>
+                                                                                                       <xslt:if test="position()!=last()">
+                                                                                                               <xslt:text>
+                                                                                                                       <text> </text>
+                                                                                                               </xslt:text>
+                                                                                                       </xslt:if>
+                                                                                               </xslt:for-each>
+                                                                                               <xslt:if test="$existing-attributes[local-name()=current()/@local-name and namespace-uri()=current()/@namespace-uri] and $additional-attributes[local-name()=current()/@local-name and namespace-uri()=current()/@namespace-uri]">
+                                                                                                       <xslt:text>
+                                                                                                               <text> </text>
+                                                                                                       </xslt:text>
+                                                                                               </xslt:if>
+                                                                                               <xslt:for-each select="$additional-attributes[local-name()=current()/@local-name and namespace-uri()=current()/@namespace-uri]">
+                                                                                                       <xslt:value-of select="."/>
+                                                                                                       <xslt:if test="position()!=last()">
+                                                                                                               <xslt:text>
+                                                                                                                       <text> </text>
+                                                                                                               </xslt:text>
+                                                                                                       </xslt:if>
+                                                                                               </xslt:for-each>
+                                                                                       </xslt:attribute>
+                                                                               </xslt:otherwise>
+                                                                       </xslt:choose>
+                                                               </xslt:for-each>
+                                                               <xslt:copy-of select="node()"/>
+                                                       </xslt:copy>
+                                               </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]/@*)[not(namespace-uri()='&书社;' and local-name()='archived-as')]"/>
+                                               <xslt:apply-templates select="$modalinput/node()" mode="书社:header"/>
+                                               <xslt:for-each 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:copy>
+                                                               <xslt:copy-of select="@*[not(namespace-uri()='&书社;' and local-name()='archived-as')]|node()"/>