<
xsl:stylesheet xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform" xmlns:dtb=
"http://www.daisy.org/z3986/2005/dtbook/" xmlns=
"http://www.daisy.org/z3986/2005/dtbook/" version=
"2.0" exclude-result-prefixes=
"dtb">
<
xsl:include href=
"recursive-copy.xsl"/>
<
xsl:include href=
"output.xsl"/>
<
xsl:template match=
"*[count(parent::*/text()[normalize-space()!=''])=0]">
<
xsl:if test=
"following-sibling::* or preceding-sibling::* or count(descendant::*) > 1">
<
xsl:text>
</
xsl:text>
<
xsl:for-each select=
"ancestor::*">
<
xsl:text> </
xsl:text>
</
xsl:for-each>
</
xsl:if>
<
xsl:copy>
<
xsl:copy-of select=
"@*"/>
<
xsl:apply-templates/>
<
xsl:if test=
"not(text()[normalize-space()!='']) and count(descendant::*) > 1">
<
xsl:text>
</
xsl:text>
<
xsl:for-each select=
"ancestor::*">
<
xsl:text> </
xsl:text>
</
xsl:for-each>
</
xsl:if>
</
xsl:copy>
</
xsl:template>
<
xsl:template match=
"text()[count(parent::*/text()[normalize-space()!=''])=0]"/>
</
xsl:stylesheet>