<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:d="org.daisy.pipeline.word_to_dtbook.impl.DaisyClass" xmlns="http://www.daisy.org/z3986/2005/dtbook/" version="2.0" exclude-result-prefixes="w pic wp dcterms xsi cp dc a r v dcmitype d xsl m o xs">
<xsl:param name="Cite_style" select="d:Citation($myObj)"/>
<xsl:template name="TableOfContents">
<xsl:param name="pagination" as="xs:string"/>
<xsl:for-each select="$documentXml//w:document/w:body/node()">
<xsl:if test="self::w:p">
<xsl:if test="w:pPr/w:pStyle[substring(@w:val,1,3)='TOC']">
<xsl:if test="w:hyperlink">
<xsl:variable name="set_list" as="xs:integer" select="d:Set_Toc($myObj)"/>
<xsl:if test="$set_list=1">
<xsl:value-of disable-output-escaping="yes" select="'<level1>'"/>
<xsl:if test="w:pPr/w:pStyle[@w:val='TOCHeading']">
<h1>
<xsl:value-of select="w:r/w:t"/>
</h1>
</xsl:if>
<xsl:value-of disable-output-escaping="yes" select="'<list type="pl">'"/>
</xsl:if>
<xsl:if test="w:hyperlink and not(w:pPr/w:pStyle[@w:val='TOCHeading'])">
<xsl:value-of disable-output-escaping="yes" select="'<li>'"/>
<xsl:for-each select="w:hyperlink/w:r/w:rPr/w:rStyle[@w:val='Hyperlink']">
<xsl:variable name="club" as="xs:string" select="../../w:t"/>
<xsl:value-of select="d:SetTOCMessage($myObj,$club)"/>
</xsl:for-each>
<lic>
<xsl:value-of select="d:GetTOCMessage($myObj)"/>
</lic>
<xsl:value-of select="d:NullMsg($myObj)"/>
<xsl:for-each select="w:hyperlink/w:r">
<xsl:if test="not(w:rPr/w:rStyle[@w:val='Hyperlink'])and w:t">
<lic>
<xsl:attribute name="class">pagenum</xsl:attribute>
<xsl:text> </xsl:text>
<xsl:value-of select="w:t"/>
</lic>
</xsl:if>
</xsl:for-each>
<xsl:value-of disable-output-escaping="yes" select="'</li>'"/>
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:for-each>
<xsl:if test="d:Set_Toc($myObj)>1">
<xsl:value-of disable-output-escaping="yes" select="'</list>'"/>
<xsl:value-of disable-output-escaping="yes" select="'</level1>'"/>
</xsl:if>
<xsl:sequence select="d:sink(d:Get_Toc($myObj))"/>
<xsl:for-each select="$documentXml//w:document/w:body/node()">
<xsl:if test="self::w:p">
<xsl:if test="w:pPr/w:pStyle[substring(@w:val,1,3)='TOC']">
<xsl:if test="not(w:hyperlink)">
<xsl:variable name="set_list" as="xs:integer" select="d:Set_Toc($myObj)"/>
<xsl:if test="$set_list=1">
<xsl:value-of disable-output-escaping="yes" select="'<level1>'"/>
<xsl:if test="w:pPr/w:pStyle[@w:val='TOCHeading']">
<h1>
<xsl:value-of select="w:r/w:t"/>
</h1>
</xsl:if>
<xsl:value-of disable-output-escaping="yes" select="'<list type="pl">'"/>
</xsl:if>
<xsl:for-each select=".">
<xsl:value-of disable-output-escaping="yes" select="'<li>'"/>
<xsl:for-each select="w:r">
<xsl:if test="w:t">
<xsl:variable name="setToc" as="xs:integer" select="d:Set_tabToc($myObj)"/>
<xsl:choose>
<xsl:when test="$setToc>=2">
<lic>
<xsl:attribute name="class">
<xsl:value-of select="'pagenum'"/>
</xsl:attribute>
<xsl:text> </xsl:text>
<xsl:value-of select="w:t"/>
</lic>
</xsl:when>
<xsl:otherwise>
<lic>
<xsl:value-of select="w:t"/>
</lic>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:for-each>
<xsl:sequence select="d:sink(d:Get_tabToc($myObj))"/>
<xsl:value-of disable-output-escaping="yes" select="'</li>'"/>
</xsl:for-each>
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:for-each>
<xsl:if test="d:Set_Toc($myObj)>1">
<xsl:value-of disable-output-escaping="yes" select="'</list>'"/>
<xsl:value-of disable-output-escaping="yes" select="'</level1>'"/>
</xsl:if>
<xsl:sequence select="d:sink(d:Get_Toc($myObj))"/>
<xsl:for-each select="$documentXml//w:body/w:sdt">
<xsl:if test="w:sdtPr/w:docPartObj/w:docPartGallery/@w:val='Table of Contents'">
<level1>
<xsl:attribute name="class">
<xsl:value-of select="'print_toc'"/>
</xsl:attribute>
<xsl:sequence select="d:sink(d:CheckTocOccur($myObj))"/>
<xsl:if test="$pagination='automatic'">
</xsl:if>
<h1>
<xsl:value-of select="w:sdtContent/w:p/w:r/w:t"/>
</h1>
<xsl:value-of disable-output-escaping="yes" select="'<list type="pl">'"/>
<xsl:if test="w:sdtContent/w:p/w:hyperlink">
<xsl:for-each select="w:sdtContent/w:p/w:hyperlink">
<xsl:value-of disable-output-escaping="yes" select="'<li>'"/>
<xsl:for-each select="w:r/w:rPr/w:rStyle[@w:val='Hyperlink']">
<xsl:variable name="club" as="xs:string" select="../../w:t"/>
<xsl:value-of select="d:SetTOCMessage($myObj,$club)"/>
</xsl:for-each>
<lic>
<xsl:value-of select="d:GetTOCMessage($myObj)"/>
</lic>
<xsl:value-of select="d:NullMsg($myObj)"/>
<xsl:for-each select="w:r">
<xsl:if test="not(w:rPr/w:rStyle[@w:val='Hyperlink']) and w:t">
<lic>
<xsl:attribute name="class">pagenum</xsl:attribute>
<xsl:text> </xsl:text>
<xsl:value-of select="w:t"/>
</lic>
</xsl:if>
</xsl:for-each>
<xsl:value-of disable-output-escaping="yes" select="'</li>'"/>
</xsl:for-each>
</xsl:if>
<xsl:if test="not(w:sdtContent/w:p/w:hyperlink)">
<xsl:for-each select="w:sdtContent/w:p">
<xsl:if test="not(w:pPr/w:pStyle[@w:val='TOCHeading'])">
<xsl:value-of disable-output-escaping="yes" select="'<li>'"/>
<xsl:for-each select="w:r/w:t">
<xsl:variable name="club" as="xs:string" select="."/>
<xsl:value-of select="d:SetTOCMessage($myObj,$club)"/>
</xsl:for-each>
<lic>
<xsl:value-of select="d:GetTOCMessage($myObj)"/>
</lic>
<xsl:value-of select="d:NullMsg($myObj)"/>
<xsl:value-of disable-output-escaping="yes" select="'</li>'"/>
</xsl:if>
</xsl:for-each>
</xsl:if>
<xsl:if test="(not(following-sibling::node()[1][w:r/w:rPr/w:rStyle[substring(@w:val,1,15)='PageNumberDAISY']]) and ($pagination='custom')) or (not($pagination='custom'))">
<xsl:value-of disable-output-escaping="yes" select="'</list>'"/>
</xsl:if>
</level1>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>