tdmncx.xsl 1.44 KB
Newer Older
cliclac's avatar
cliclac committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs"
    xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
    version="2.0">
    
    <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
    
    <xsl:template match="html">
        <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1" xml:lang="en-US">
            <head>
                <meta content="org-example-5059463624137734586" name="dtb:uid"/>
            </head>
            
            <navMap>
                <xsl:apply-templates/>
            </navMap>
        </ncx>
    </xsl:template>
    
    <xsl:template match="//section">
        <navPoint>
            <xsl:attribute name="class">h<xsl:value-of select="count(ancestor::section)+1"/></xsl:attribute>
            <xsl:attribute name="id">ch_<xsl:number level="multiple" count="section" format="1_1"/></xsl:attribute>
            <navLabel>
                <text>
                    <xsl:value-of select="header/h1"/>
                </text>
            </navLabel>
            <content>
                <xsl:attribute name="src">content.html#ch_<xsl:number level="multiple" count="section" format="1_1"/></xsl:attribute>
            </content>
            <xsl:apply-templates/>
            
        </navPoint>
    </xsl:template>
    
    <xsl:template match="text()"/>
    
</xsl:stylesheet>