Because this indiscriminately adds the attribute to the result of
parsing the root node, the checksum should be added for both X·M·L and
plaintext sources.
</xslt:for-each>
</xslt:template>
<xslt:template match="/">
- <xslt:apply-templates select="node()" mode="书社:parse"/>
+ <xslt:variable name="parsedroot">
+ <xslt:apply-templates select="node()" mode="书社:parse"/>
+ </xslt:variable>
+ <xslt:for-each select="exsl:node-set($parsedroot)/node()">
+ <xslt:choose>
+ <xslt:when test="self::*">
+ <xslt:copy>
+ <xslt:attribute name="书社:cksum">
+ <xslt:value-of select="$CKSUM"/>
+ </xslt:attribute>
+ <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 match="@*|node()" priority="-1">
<xslt:copy>