<xsl:template match="*" mode="epub.type" priority="-1"/>
<xsl:template match="chapter
- |section
|appendix
|epigraph
|warning
</xsl:if>
</xsl:template>
+<xsl:template match="section[parent::chapter]" mode="epub.type">
+ <xsl:if test="$epub.output.epub.types != 0">
+ <xsl:attribute name="epub:type">subchapter</xsl:attribute>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="section[not(parent::chapter)]" mode="epub.type">
+ <xsl:if test="$epub.output.epub.types != 0">
+ <xsl:attribute name="epub:type">division</xsl:attribute>
+ </xsl:if>
+</xsl:template>
+
<!-- EPUB3: to add attributes to root output element -->
<xsl:template name="root.attributes">
<!-- collect and output all namespace declarations -->