<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dtb="http://www.daisy.org/z3986/2005/dtbook/" xmlns:tmp="http://www.daisy.org/ns/pipeline/tmp" exclude-result-prefixes="dtb tmp" version="2.0"> <xsl:output indent="yes" method="xml"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="dtb:annotation"> <xsl:variable name="block-level-contents" select="tokenize('div,sidebar,caption,code-block,hd,list,note,p,blockquote,table,dl,dateline,epigraph,address,imggroup,poem,linegroup,samp', ',')"/> <xsl:choose> <xsl:when test="child::*/local-name() = $block-level-contents"> <xsl:element name="tmp:annotation-block"> <xsl:apply-templates/> </xsl:element> </xsl:when> <xsl:otherwise> <xsl:element name="tmp:annotation-phrase"> <xsl:apply-templates/> </xsl:element> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>