刚开始学XSLT, 试试
<xsl:stylesheet version="2.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform" xmlns:xs="
http://www.w3.org/2001/XMLSchema" xmlns:fn="
http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="Book">
<xsl:element name="Publication">
<xsl:attribute name="title" select="@title"/>
<xsl:attribute name="nbPages" select="sum(chapters/@nbPages)"/>
<xsl:apply-templates select="chapters[1]"/>
</xsl:element>
</xsl:template>
<xsl:template match="chapters">
<xsl:param name="str"/>
<xsl:choose>
<xsl:when test="not(following-sibling::*)">
<xsl:attribute name="authors" select="substring(concat($str,' and ',@author),6)"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="following-sibling::chapters[1]">
<xsl:with-param name="str" select="concat($str,' and ',@author)"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>