<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/library">
	<xsl:copy>
		<xsl:apply-templates select="book"/>
	</xsl:copy>
</xsl:template>

<xsl:template match="author">
	<xsl:variable name="name" select="normalize-space()"/>
	<xsl:copy-of select="/library/author[normalize-space(name)=$name]"/>
</xsl:template>

<xsl:template match="character">
	<xsl:variable name="name" select="normalize-space()"/>
	<xsl:copy-of select="/library/character[normalize-space(name)=$name]"/>
</xsl:template>

<xsl:template match="*|@*">
	<xsl:copy>
		<xsl:apply-templates/>
	</xsl:copy>
</xsl:template>

</xsl:stylesheet>