<
xsl:stylesheet xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform" xmlns:dtb=
"http://www.daisy.org/z3986/2005/dtbook/" xmlns:xs=
"http://www.w3.org/2001/XMLSchema" xmlns:math=
"http://www.w3.org/1998/Math/MathML" xmlns:my=
"http://my-functions" version=
"2.0" extension-element-prefixes=
"my" exclude-result-prefixes=
"dtb my">
<
xsl:include href=
"table-utils.xsl"/>
<
xsl:output method=
"text" encoding=
"utf-8" indent=
"no"/>
<
xsl:strip-space elements=
"*"/>
<
xsl:preserve-space elements=
"dtb:line dtb:address dtb:div dtb:title dtb:author dtb:note dtb:byline dtb:dateline dtb:a dtb:em dtb:strong dtb:dfn dtb:kbd dtb:code dtb:samp dtb:cite dtb:abbr dtb:acronym dtb:sub dtb:sup dtb:span dtb:bdo dtb:sent dtb:w dtb:q dtb:p dtb:doctitle dtb:docauthor dtb:covertitle dtb:h1 dtb:h2 dtb:h3 dtb:h4 dtb:h5 dtb:h6 dtb:bridgehead dtb:hd dtb:dt dtb:li dtb:lic "/>
<
xsl:param name=
"fontsize">17pt</
xsl:param>
<
xsl:param name=
"font">LMRoman10 Regular</
xsl:param>
<
xsl:param name=
"backupFont">Arial Unicode MS</
xsl:param>
<
xsl:param name=
"backupUnicodeRanges"/>
<
xsl:param name=
"defaultLanguage">english</
xsl:param>
<
xsl:param name=
"stocksize">a4paper</
xsl:param>
<
xsl:param name=
"alignment">justified</
xsl:param>
<
xsl:param name=
"pageStyle">plain</
xsl:param>
<
xsl:param name=
"line_spacing">singlespacing</
xsl:param>
<
xsl:param name=
"paperwidth">200mm</
xsl:param>
<
xsl:param name=
"paperheight">250mm</
xsl:param>
<
xsl:param name=
"left_margin">28mm</
xsl:param>
<
xsl:param name=
"right_margin">20mm</
xsl:param>
<
xsl:param name=
"top_margin">20mm</
xsl:param>
<
xsl:param name=
"bottom_margin">20mm</
xsl:param>
<
xsl:param name=
"replace_em_with_quote">false</
xsl:param>
<
xsl:param name=
"endnotes">none</
xsl:param>
<
xsl:param name=
"include_images">true</
xsl:param>
<
xsl:param name=
"version">unknown</
xsl:param>
<
xsl:variable name=
"number_of_volumes" select=
"count(//*['volume-split-point'=tokenize(@class, '\s+')])+1"/>
<
xsl:template match=
"/*">
<
c:data xmlns:c=
"http://www.w3.org/ns/xproc-step">
<
xsl:next-match/>
</
c:data>
</
xsl:template>
<
xsl:function name=
"my:max-line-width" as=
"xs:integer">
<
xsl:sequence select=
"if ($fontsize='17pt') then 40 else if ($fontsize='20pt') then 35 else if ($fontsize='25pt') then 30 else 40"/>
</
xsl:function>
<
xsl:function name=
"my:includegraphics-command" as=
"xs:string">
<
xsl:param name=
"src" as=
"xs:string"/>
<
xsl:param name=
"with_caption" as=
"xs:boolean"/>
<
xsl:variable name=
"magic-number" select=
"3"/>
<
xsl:variable name=
"scale-factor">
<
xsl:sequence select=
"if ($fontsize='14pt') then round-half-to-even(14 div 12, 1) else if ($fontsize='17pt') then round-half-to-even(17 div 12, 1) else if ($fontsize='20pt') then round-half-to-even(20 div 12, 1) else if ($fontsize='25pt') then round-half-to-even(25 div 12, 1) else 1"/>
</
xsl:variable>
<
xsl:variable name=
"height" select=
"if ($with_caption) then '\textheightMinusCaption' else '\textheight'"/>
<
xsl:sequence select=
"concat('\maxsizebox{\textwidth}{',$height,'}{\includegraphics[scale=',$scale-factor*$magic-number,']{',$src,'}}
')"/>
</
xsl:function>
<
xsl:function name=
"my:cleanCaptions" as=
"xs:string">
<
xsl:param name=
"context" as=
"node()"/>
<
xsl:value-of select=
"string($context)"/>
</
xsl:function>
<
xsl:function name=
"my:is-block-element" as=
"xs:boolean">
<
xsl:param name=
"node" as=
"node()"/>
<
xsl:apply-templates select=
"$node" mode=
"is-block-element"/>
</
xsl:function>
<
xsl:template match=
"node()" as=
"xs:boolean" mode=
"is-block-element" priority=
"10">
<
xsl:sequence select=
"false()"/>
</
xsl:template>
<
xsl:template match=
"dtb:*|math:*" as=
"xs:boolean" mode=
"is-block-element" priority=
"11">
<
xsl:sequence select=
"false()"/>
</
xsl:template>
<
xsl:template match=
"dtb:samp|dtb:cite" as=
"xs:boolean" mode=
"is-block-element" priority=
"12">
<
xsl:sequence select=
"if (parent::*[self::dtb:p|self::dtb:li|self::dtb:td|self::dtb:th]) then false() else true()"/>
</
xsl:template>
<
xsl:template match=
"dtb:h1|dtb:h2|dtb:h3|dtb:h4|dtb:h5|dtb:h6|dtb:p|dtb:list|dtb:li|dtb:author|dtb:byline|dtb:line|dtb:imggroup|dtb:blockquote" as=
"xs:boolean" mode=
"is-block-element" priority=
"12">
<
xsl:sequence select=
"true()"/>
</
xsl:template>
<
xsl:function name=
"my:has-preceding-non-empty-textnode-within-block" as=
"xs:boolean">
<
xsl:param name=
"context"/>
<
xsl:sequence select=
"some $t in ($context/preceding::text() intersect $context/ancestor-or-self::*[my:is-block-element(.)][1]//text()) satisfies normalize-space($t) != ''"/>
</
xsl:function>
<
xsl:function name=
"my:is-level-element" as=
"xs:boolean">
<
xsl:param name=
"node" as=
"node()"/>
<
xsl:apply-templates select=
"$node" mode=
"is-level-element"/>
</
xsl:function>
<
xsl:template match=
"node()" as=
"xs:boolean" mode=
"is-level-element" priority=
"10">
<
xsl:sequence select=
"false()"/>
</
xsl:template>
<
xsl:template match=
"dtb:level1|dtb:level2|dtb:level3|dtb:level4|dtb:level5|dtb:level6" as=
"xs:boolean" mode=
"is-level-element" priority=
"12">
<
xsl:sequence select=
"true()"/>
</
xsl:template>
<
xsl:function name=
"my:has-preceding-para-within-parent-level" as=
"xs:boolean">
<
xsl:param name=
"context"/>
<
xsl:sequence select=
"exists($context/preceding::dtb:p intersect $context/ancestor::*[my:is-level-element(.)][1]//dtb:p)"/>
</
xsl:function>
<
xsl:variable name=
"level_to_section_map">
<
entry key=
"level1">\chapter</
entry>
<
entry key=
"level2">\section</
entry>
<
entry key=
"level3">\subsection</
entry>
<
entry key=
"level4">\subsubsection</
entry>
<
entry key=
"level5">\paragraph</
entry>
<
entry key=
"level6">\subparagraph</
entry>
</
xsl:variable>
<
xsl:template match=
"*" mode=
"localizeWords">
<
xsl:choose>
<
xsl:when test=
"lang('de')">
<
xsl:text>\renewcommand*{\notesname}{Anmerkungen}
</
xsl:text>
</
xsl:when>
</
xsl:choose>
</
xsl:template>
<
xsl:function name=
"my:quoteSpecialChars" as=
"xs:string">
<
xsl:param name=
"text"/>
<
xsl:variable name=
"tmp1" select=
"replace($text, '\\', '\\textbackslash ')"/>
<
xsl:variable name=
"tmp2" select=
"replace($tmp1, '\s+', ' ')"/>
<
xsl:variable name=
"tmp3" select=
"replace($tmp2, '(\$|&|%|#|_|\{|\})', '\\$1')"/>
<
xsl:variable name=
"tmp4" select=
"replace($tmp3, '(~|\^)', '\\$1{}')"/>
<
xsl:variable name=
"tmp5" select=
"replace($tmp4, ' ([–—]\p{P})', ' $1')"/>
<
xsl:variable name=
"tmp6" select=
"replace($tmp5, ' ((\.{3}|…)\p{P})', ' $1')"/>
<
xsl:variable name=
"tmp7" select=
"replace(replace($tmp6, '\[', '\\lbrack{}'), '\]', '\\rbrack{}')"/>
<
xsl:variable name=
"tmp8" select=
"replace(replace($tmp7, '<<', '{<}<'), '>>', '{>}>')"/>
<
xsl:value-of select=
"$tmp8"/>
</
xsl:function>
<
xsl:template match=
"/">
<
xsl:variable name=
"pass1">
<
xsl:apply-templates mode=
"volume-split"/>
</
xsl:variable>
<
xsl:apply-templates select=
"$pass1/*"/>
</
xsl:template>
<
xsl:template match=
"dtb:dtbook">
<
xsl:text>% ***************************************
</
xsl:text>
<
xsl:value-of select=
"concat('% DAISY Pipeline 2 dtbook-to-latex v', $version, '
')"/>
<
xsl:text>% ***************************************
</
xsl:text>
<
xsl:text>\documentclass[</
xsl:text>
<
xsl:value-of select=
"concat($fontsize, ',', $stocksize, ',')"/>
<
xsl:text>extrafontsizes,twoside,showtrims]{memoir}
</
xsl:text>
<
xsl:text>\usepackage{calc}
</
xsl:text>
<
xsl:if test=
"//dtb:table">
<
xsl:text>\usepackage{tabulary}
</
xsl:text>
<
xsl:text>\usepackage{xcolor}
</
xsl:text>
<
xsl:text>\usepackage{colortbl}
</
xsl:text>
<
xsl:text>\arrayrulecolor{black!60}
</
xsl:text>
<
xsl:text>\setlength{\arrayrulewidth}{0.5mm}
</
xsl:text>
</
xsl:if>
<
xsl:text>\captionstyle{\raggedright}
</
xsl:text>
<
xsl:choose>
<
xsl:when test=
"($paperheight ne '') and ($paperwidth ne '')">
<
xsl:value-of select=
"concat('\settrimmedsize{',$paperheight,'}{',$paperwidth,'}{*}
')"/>
<
xsl:text>\setlength{\trimtop}{\stockheight - \paperheight}
</
xsl:text>
<
xsl:text>\setlength{\trimedge}{\stockwidth - \paperwidth}
</
xsl:text>
<
xsl:text>\settrims{0.5\trimtop}{\trimedge}
</
xsl:text>
</
xsl:when>
<
xsl:otherwise>
<
xsl:text>\settrimmedsize{\stockheight}{\stockwidth}{*}
</
xsl:text>
</
xsl:otherwise>
</
xsl:choose>
<
xsl:if test=
"($left_margin ne '') and ($right_margin ne '')">
<
xsl:value-of select=
"concat('\setlrmarginsandblock{',$left_margin,'}{',$right_margin,'}{*}
')"/>
</
xsl:if>
<
xsl:if test=
"($top_margin ne '') and ($bottom_margin ne '')">
<
xsl:value-of select=
"concat('\setulmarginsandblock{',$top_margin,'}{',$bottom_margin,' + 1.5\onelineskip}{*}
')"/>
</
xsl:if>
<
xsl:text>\setheadfoot{\onelineskip}{1.5\onelineskip}
</
xsl:text>
<
xsl:text>\setheaderspaces{*}{*}{0.4}
</
xsl:text>
<
xsl:text>\checkandfixthelayout
</
xsl:text>
<
xsl:text>\newcommand*{\trimLmarksLight}{%
</
xsl:text>
<
xsl:text> \let\tmarktl\Ltrimpictl
</
xsl:text>
<
xsl:text> \let\tmarktr\Ltrimpictr
</
xsl:text>
<
xsl:text> \let\tmarkbl\Ltrimpicbl
</
xsl:text>
<
xsl:text> \let\tmarkbr\Ltrimpicbr
</
xsl:text>
<
xsl:text> \let\tmarktm\relax
</
xsl:text>
<
xsl:text> \let\tmarkml\relax
</
xsl:text>
<
xsl:text> \let\tmarkmr\relax
</
xsl:text>
<
xsl:text> \let\tmarkbm\relax}
</
xsl:text>
<
xsl:text>\trimLmarksLight
</
xsl:text>
<
xsl:text>\usepackage{graphicx}
</
xsl:text>
<
xsl:text>\usepackage{adjustbox}
</
xsl:text>
<
xsl:call-template name=
"findLanguage"/>
<
xsl:text>\def\languageshorthands#1{}
</
xsl:text>
<
xsl:text>\setlength{\parskip}{1.5ex}
</
xsl:text>
<
xsl:text>\setlength{\parindent}{0ex}
</
xsl:text>
<
xsl:text>\usepackage{fontspec,xunicode,xltxtra}
</
xsl:text>
<
xsl:text>\defaultfontfeatures{Mapping=tex-text}
</
xsl:text>
<
xsl:text>\setmainfont{</
xsl:text><
xsl:value-of select=
"$font"/><
xsl:text>}
</
xsl:text>
<
xsl:if test=
"string-length($backupFont) > 0 and string-length($backupUnicodeRanges) > 0">
<
xsl:variable name=
"all-unicode-ranges" select=
"doc('unicode-blocks.xml')/unicodeBlocks/block"/>
<
xsl:variable name=
"included-unicode-ranges" as=
"xs:string*" select=
"distinct-values( for $cp in distinct-values(string-to-codepoints(string(/*))) return $all-unicode-ranges[$cp >= number(@start) and $cp <= number(@end)]/@name)"/>
<
xsl:variable name=
"backup-unicode-ranges" as=
"xs:string*" select=
"tokenize($backupUnicodeRanges, ',')[.=$included-unicode-ranges]"/>
<
xsl:if test=
"$backup-unicode-ranges[1]">
<
xsl:text>
</
xsl:text>
<
xsl:text>%%Use a secondary font for some Unicode ranges
</
xsl:text>
<
xsl:text>%%Warning: the package ucharclasses must be installed
</
xsl:text>
<
xsl:text>\usepackage{ucharclasses}
</
xsl:text>
<
xsl:text>\newfontfamily\lpfont{</
xsl:text><
xsl:value-of select=
"$font"/><
xsl:text>}
</
xsl:text>
<
xsl:text>\newfontfamily\unicodefont{</
xsl:text><
xsl:value-of select=
"$backupFont"/><
xsl:text>}
</
xsl:text>
<
xsl:text>\setDefaultTransitions{\lpfont}{}
</
xsl:text>
<
xsl:for-each select=
"$backup-unicode-ranges">
<
xsl:text>\setTransitionTo{</
xsl:text><
xsl:value-of select=
"."/><
xsl:text>}{\unicodefont}
</
xsl:text>
</
xsl:for-each>
<
xsl:text>
</
xsl:text>
</
xsl:if>
</
xsl:if>
<
xsl:if test=
"//dtb:samp[@xml:space='preserve']">
<
xsl:text>\usepackage{alltt}
</
xsl:text>
</
xsl:if>
<
xsl:if test=
"//dtb:sidebar|//dtb:prodnote">
<
xsl:text>\usepackage{tcolorbox}
</
xsl:text>
<
xsl:text>\tcbuselibrary{breakable}
</
xsl:text>
<
xsl:text>\tcbset{colframe=black!60,colback=white,arc=0mm,float,parbox=false,enlarge top by=5mm}
</
xsl:text>
</
xsl:if>
<
xsl:if test=
"//dtb:linenum|//dtb:span[@class='linenum']">
<
xsl:text>\sideparmargin{left}
</
xsl:text>
</
xsl:if>
<
xsl:text>\usepackage{enumitem}
</
xsl:text>
<
xsl:text>\usepackage[hyphens]{url}
</
xsl:text>
<
xsl:text>\urlstyle{same}
</
xsl:text>
<
xsl:text>\usepackage{hyperref}
</
xsl:text>
<
xsl:text>\hypersetup{
</
xsl:text>
<
xsl:text>pdfinfo={
</
xsl:text>
<
xsl:value-of select=
"concat(' Title={', my:quoteSpecialChars(//dtb:meta[@name='dc:title' or @name='dc:Title']/@content), '},
')"/>
<
xsl:value-of select=
"concat(' Author={', my:quoteSpecialChars(//dtb:meta[@name='dc:creator' or @name='dc:Creator']/@content), '},
')"/>
<
xsl:value-of select=
"concat(' Subject={', my:quoteSpecialChars(//dtb:meta[@name='dc:subject' or @name='dc:Subject']/@content), '},
')"/>
<
xsl:value-of select=
"concat(' Lang={', my:quoteSpecialChars(//dtb:meta[@name='dc:language' or @name='dc:Language']/@content), '},
')"/>
<
xsl:value-of select=
"concat(' Producer={', my:quoteSpecialChars(//dtb:meta[@name='dc:publisher' or @name='dc:Publisher']/@content), '},
')"/>
<
xsl:value-of select=
"concat(' Source={', my:quoteSpecialChars(//dtb:meta[@name='dc:source' or @name='dc:Source']/@content), '},
')"/>
<
xsl:value-of select=
"concat(' Identifier={', my:quoteSpecialChars(//dtb:meta[@name='dc:identifier' or @name='dc:Identifier']/@content), '},
')"/>
<
xsl:value-of select=
"concat(' Fontsize={', my:quoteSpecialChars($fontsize), '},
')"/>
<
xsl:value-of select=
"concat(' Font={', my:quoteSpecialChars($font), '},
')"/>
<
xsl:value-of select=
"concat(' Stocksize={', my:quoteSpecialChars($stocksize), '},
')"/>
<
xsl:value-of select=
"concat(' Alignment={', my:quoteSpecialChars($alignment), '},
')"/>
<
xsl:value-of select=
"concat(' PageStyle={', my:quoteSpecialChars($pageStyle), '},
')"/>
<
xsl:value-of select=
"concat(' LineSpacing={', my:quoteSpecialChars($line_spacing), '},
')"/>
<
xsl:value-of select=
"concat(' ReplaceEmWithQuote={', my:quoteSpecialChars($replace_em_with_quote), '},
')"/>
<
xsl:value-of select=
"concat(' EndNotes={', my:quoteSpecialChars($endnotes), '}
')"/>
<
xsl:text>}
</
xsl:text>
<
xsl:text>}
</
xsl:text>
<
xsl:text>\usepackage{float}
</
xsl:text>
<
xsl:text>\usepackage{alphalph}
</
xsl:text>
<
xsl:text>\sloppy
</
xsl:text>
<
xsl:text>\setlength{\topskip}{1.6\topskip}
</
xsl:text>
<
xsl:text>\checkandfixthelayout
</
xsl:text>
<
xsl:text>\sloppybottom
</
xsl:text>
<
xsl:text>\clubpenalty=10000
</
xsl:text>
<
xsl:text>\widowpenalty=10000
</
xsl:text>
<
xsl:text>\raggedbottom
</
xsl:text>
<
xsl:text>\makechapterstyle{largePrint}{%
</
xsl:text>
<
xsl:text> \renewcommand*{\chapterheadstart}{} %% no space before chapter
</
xsl:text>
<
xsl:text> \renewcommand*{\printchaptername}{} %% do not print "Chapter"
</
xsl:text>
<
xsl:text> \renewcommand*{\chaptitlefont}{\normalfont\LARGE\bfseries\raggedright} %% set the font for the title
</
xsl:text>
<
xsl:text> \renewcommand*{\printchapternum}{} %% do not print chapter number
</
xsl:text>
<
xsl:text> \renewcommand*{\afterchapternum}{} %% no space after the number (since it isn't printed)
</
xsl:text>
<
xsl:text>}
</
xsl:text>
<
xsl:text>\makechapterstyle{largePrintScientific}{%
</
xsl:text>
<
xsl:text> \renewcommand*{\chaptitlefont}{\normalfont\LARGE\bfseries\raggedright} %% set the font for the title
</
xsl:text>
<
xsl:text>}
</
xsl:text>
<
xsl:choose>
<
xsl:when test=
"$pageStyle='scientific'">
<
xsl:text>\chapterstyle{largePrintScientific}
</
xsl:text>
</
xsl:when>
<
xsl:otherwise>
<
xsl:text>\chapterstyle{largePrint}
</
xsl:text>
</
xsl:otherwise>
</
xsl:choose>
<
xsl:text>\setsecheadstyle{\Large\bfseries\raggedright}
</
xsl:text>
<
xsl:text>\setsubsecheadstyle{\large\bfseries\raggedright}
</
xsl:text>
<
xsl:text>\setsubsubsecheadstyle{\bfseries\raggedright}
</
xsl:text>
<
xsl:text>\newlength{\textheightMinusCaption}
</
xsl:text>
<
xsl:text>\setlength{\textheightMinusCaption}{\textheight - \baselineskip}
</
xsl:text>
<
xsl:if test=
"$pageStyle=('plain', 'compact', 'spacious')">
<
xsl:text>\setsecnumdepth{book}
</
xsl:text>
</
xsl:if>
<
xsl:if test=
"$pageStyle!='scientific'">
<
xsl:text>\renewcommand{\cftchapterleader}{, }
</
xsl:text>
<
xsl:text>\renewcommand{\cftchapterafterpnum}{\cftparfillskip}
</
xsl:text>
<
xsl:text>\renewcommand{\cftsectionleader}{, }
</
xsl:text>
<
xsl:text>\renewcommand{\cftsectionafterpnum}{\cftparfillskip}
</
xsl:text>
<
xsl:text>\renewcommand{\cftsubsectionleader}{, }
</
xsl:text>
<
xsl:text>\renewcommand{\cftsubsectionafterpnum}{\cftparfillskip}
</
xsl:text>
<
xsl:text>\renewcommand{\cftsubsubsectionleader}{, }
</
xsl:text>
<
xsl:text>\renewcommand{\cftsubsubsectionafterpnum}{\cftparfillskip}
</
xsl:text>
<
xsl:text>\makeevenfoot{plain}{\thepage}{}{}
</
xsl:text>
<
xsl:text>\makeoddfoot{plain}{}{}{\thepage}
</
xsl:text>
</
xsl:if>
<
xsl:if test=
"$alignment='left'">
<
xsl:text>\setrmarg{3.55em plus 1fil}
</
xsl:text>
</
xsl:if>
<
xsl:call-template name=
"setmaxtocdepth"/>
<
xsl:choose>
<
xsl:when test=
"$endnotes = 'none'">
<
xsl:text>\renewcommand{\foottextfont}{\normalsize}
</
xsl:text>
<
xsl:text>\footmarkstyle{\textsuperscript{#1} }
</
xsl:text>
<
xsl:text>\setlength{\footmarkwidth}{0ex}
</
xsl:text>
<
xsl:text>\setlength{\footmarksep}{\footmarkwidth}
</
xsl:text>
<
xsl:text>\setlength{\footnotesep}{\onelineskip}
</
xsl:text>
<
xsl:text>\renewcommand{\footnoterule}{%
</
xsl:text>
<
xsl:text>\kern-3pt%
</
xsl:text>
<
xsl:text>\hrule height 1.5pt
</
xsl:text>
<
xsl:text>\kern 2.6pt}
</
xsl:text>
</
xsl:when>
<
xsl:otherwise>
<
xsl:text>\makepagenote
</
xsl:text>
<
xsl:text>\continuousnotenums
</
xsl:text>
<
xsl:if test=
"$endnotes = 'chapter'">
<
xsl:text>\renewcommand{\notedivision}{\section{\notesname}}
</
xsl:text>
<
xsl:text>\renewcommand{\pagenotesubhead}[3]{}
</
xsl:text>
</
xsl:if>
<
xsl:if test=
"$endnotes='document' and $pageStyle=('plain', 'compact', 'spacious', 'withPageNums')">
<
xsl:text>\renewcommand{\pagenotesubhead}[3]{\section*{#3}}
</
xsl:text>
</
xsl:if>
</
xsl:otherwise>
</
xsl:choose>
<
xsl:text>
</
xsl:text>
<
xsl:text>\makeatletter
</
xsl:text>
<
xsl:text>\newcommand{\AlphUpper}[1]{\@AlphUpper{#1}} % Define the \AlphAlph wrapper for enumitem
</
xsl:text>
<
xsl:text>\newcommand{\AlphLower}[1]{\@AlphLower{#1}} % Define the \alphalph wrapper for enumitem
</
xsl:text>
<
xsl:text>\newcommand{\@AlphUpper}[1]{\AlphAlph{\value{#1}}} % Internal representation
</
xsl:text>
<
xsl:text>\newcommand{\@AlphLower}[1]{\alphalph{\value{#1}}} % Internal representation
</
xsl:text>
<
xsl:text>\AddEnumerateCounter{\AlphUpper}{\@AlphUpper}{A} % Register this new format
</
xsl:text>
<
xsl:text>\AddEnumerateCounter{\AlphLower}{\@AlphLower}{a} % Register this new format
</
xsl:text>
<
xsl:text>\makeatother
</
xsl:text>
<
xsl:text>\makeatletter
</
xsl:text>
<
xsl:text>\renewcommand*{\@pbreak}[1]{\par
</
xsl:text>
<
xsl:text>\penalty -100
</
xsl:text>
<
xsl:text>%% \vskip #1\onelineskip \@plus 2\onelineskip
</
xsl:text>
<
xsl:text>%% \penalty -20
</
xsl:text>
<
xsl:text>%% \vskip \z@ \@plus -2\onelineskip
</
xsl:text>
<
xsl:text>\vskip #1\onelineskip
</
xsl:text>
<
xsl:text>\@afterindentfalse
</
xsl:text>
<
xsl:text>\@afterheading}
</
xsl:text>
<
xsl:text>\makeatletter
</
xsl:text>
<
xsl:if test=
"$line_spacing = 'onehalfspacing'">
<
xsl:text>\OnehalfSpacing
</
xsl:text>
</
xsl:if>
<
xsl:if test=
"$line_spacing = 'doublespacing'">
<
xsl:text>\DoubleSpacing
</
xsl:text>
</
xsl:if>
<
xsl:text>\setlength{\cftparskip}{0.25\onelineskip}
</
xsl:text>
<
xsl:text>\setlength{\vindent}{0em}
</
xsl:text>
<
xsl:if test=
"//dtb:poem/dtb:title|//dtb:poem/dtb:hd">
<
xsl:text>\renewcommand*{\PoemTitlefont}{\normalfont\large}
</
xsl:text>
</
xsl:if>
<
xsl:if test=
"//dtb:dl">
<
xsl:text>\newenvironment{longdescription}
</
xsl:text>
<
xsl:text> {\begin{description}[style=unboxed]}
</
xsl:text>
<
xsl:text> {\end{description}}
</
xsl:text>
</
xsl:if>
<
xsl:apply-templates select=
"." mode=
"localizeWords"/>
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template name=
"iso639toBabel">
<
xsl:param name=
"iso639Code"/>
<
xsl:variable name=
"babelLang">
<
xsl:choose>
<
xsl:when test=
"matches($iso639Code, 'sv(-.+)?')">swedish</
xsl:when>
<
xsl:when test=
"matches($iso639Code, 'en-[Uu][Ss]')">USenglish</
xsl:when>
<
xsl:when test=
"matches($iso639Code, 'en-[Uu][Kk]')">UKenglish</
xsl:when>
<
xsl:when test=
"matches($iso639Code, 'en(-.+)?')">english</
xsl:when>
<
xsl:when test=
"matches($iso639Code, 'de-1901')">german</
xsl:when>
<
xsl:when test=
"matches($iso639Code, 'de(-.+)?')">ngerman</
xsl:when>
<
xsl:otherwise>
<
xsl:message>
***** <
xsl:value-of select=
"$iso639Code"/> not supported. Defaulting to '<
xsl:value-of select=
"$defaultLanguage"/>' ******
</
xsl:message>
<
xsl:value-of select=
"$defaultLanguage"/></
xsl:otherwise>
</
xsl:choose>
</
xsl:variable>
<
xsl:value-of select=
"$babelLang"/>
</
xsl:template>
<
xsl:template name=
"findLanguage">
<
xsl:variable name=
"iso639Code">
<
xsl:choose>
<
xsl:when test=
"//dtb:meta[@name='dc:Language']">
<
xsl:value-of select=
"//dtb:meta[@name='dc:Language']/@content"/>
</
xsl:when>
<
xsl:when test=
"//dtb:meta[@name='dc:language']">
<
xsl:value-of select=
"//dtb:meta[@name='dc:language']/@content"/>
</
xsl:when>
<
xsl:when test=
"/dtb:dtbook/@xml:lang">
<
xsl:value-of select=
"/dtb:dtbook/@xml:lang"/>
</
xsl:when>
</
xsl:choose>
</
xsl:variable>
<
xsl:text>\usepackage[</
xsl:text>
<
xsl:call-template name=
"iso639toBabel">
<
xsl:with-param name=
"iso639Code">
<
xsl:value-of select=
"$iso639Code"/>
</
xsl:with-param>
</
xsl:call-template>
<
xsl:text>]{babel}
</
xsl:text>
</
xsl:template>
<
xsl:template name=
"setmaxtocdepth">
<
xsl:variable name=
"max_toc_depth" select=
"max(for $node in //dtb:frontmatter/dtb:level1/dtb:list//dtb:lic return count($node/ancestor::dtb:list))"/>
<
xsl:if test=
"$max_toc_depth > 0">
<
xsl:text>\maxtocdepth{</
xsl:text>
<
xsl:value-of select=
"substring($level_to_section_map/entry[@key=concat('level',$max_toc_depth)],2)"/>
<
xsl:text>}
</
xsl:text>
</
xsl:if>
</
xsl:template>
<
xsl:template name=
"set_frontmatter_pagestyle">
<
xsl:if test=
"$pageStyle=('plain', 'compact', 'spacious')">
<
xsl:text>\pagestyle{empty}
</
xsl:text>
<
xsl:text>\aliaspagestyle{chapter}{empty}
</
xsl:text>
</
xsl:if>
<
xsl:if test=
"$pageStyle='withPageNums'">
<
xsl:text>\pagestyle{plain}
</
xsl:text>
</
xsl:if>
<
xsl:text>\openright
</
xsl:text>
</
xsl:template>
<
xsl:template name=
"restore_pagestyle">
<
xsl:value-of select=
"if ($pageStyle=('plain', 'compact', 'spacious', 'withPageNums')) then '\pagestyle{plain}
' else '\pagestyle{Ruled}
'"/>
<
xsl:text>\aliaspagestyle{chapter}{plain}
</
xsl:text>
<
xsl:if test=
"$pageStyle='compact'">
<
xsl:text>\openany
</
xsl:text>
</
xsl:if>
</
xsl:template>
<
xsl:template name=
"current_volume_string">
<
xsl:param name=
"current_volume_number"/>
<
xsl:value-of select=
"concat('Volume ', $current_volume_number, ' of ', $number_of_volumes, '\\[0.5cm]
')"/>
</
xsl:template>
<
xsl:template name=
"total_volumes_string">
<
xsl:variable name=
"volumes-string" select=
"if ($number_of_volumes = 1) then 'volume' else 'volumes'"/>
<
xsl:value-of select=
"concat('Large print book in \numtoname{', $number_of_volumes, '} ', $volumes-string, '\\[0.5cm]
')"/>
</
xsl:template>
<
xsl:template name=
"publisher">
<
xsl:for-each select=
"//dtb:meta[@name='dc:publisher' or @name='dc:Publisher']">
<
xsl:text>{\large </
xsl:text>
<
xsl:value-of select=
"my:quoteSpecialChars(string(@content))"/>
<
xsl:text>}\\[0.5cm]
</
xsl:text>
</
xsl:for-each>
</
xsl:template>
<
xsl:template name=
"imprint">
</
xsl:template>
<
xsl:template name=
"author">
<
xsl:param name=
"font_size" select=
"'\large'"/>
<
xsl:value-of select=
"concat('{', $font_size, ' ')"/>
<
xsl:variable name=
"author">
<
xsl:for-each select=
"//dtb:meta[@name='dc:creator' or @name='dc:Creator']">
<
xsl:value-of select=
"my:quoteSpecialChars(string(@content))"/>
<
xsl:if test=
"not(position() = last())"><
xsl:text>, </
xsl:text></
xsl:if>
</
xsl:for-each>
</
xsl:variable>
<
xsl:sequence select=
"if (normalize-space($author) != '') then $author else '\ '"/>
<
xsl:text>}\\[1.5cm]
</
xsl:text>
</
xsl:template>
<
xsl:template name=
"title">
<
xsl:param name=
"font_size" select=
"'\huge'"/>
<
xsl:text>\begin{Spacing}{1.75}
</
xsl:text>
<
xsl:for-each select=
"//dtb:meta[@name='dc:title' or @name='dc:Title']">
<
xsl:value-of select=
"concat('{', $font_size, ' ')"/>
<
xsl:value-of select=
"my:quoteSpecialChars(string(@content))"/>
<
xsl:text>}\\[0.5cm]
</
xsl:text>
</
xsl:for-each>
<
xsl:text>\end{Spacing}
</
xsl:text>
</
xsl:template>
<
xsl:template name=
"cover">
<
xsl:param name=
"current_volume_number" select=
"1"/>
<
xsl:call-template name=
"author"/>
<
xsl:call-template name=
"title"/>
<
xsl:if test=
"$number_of_volumes > 1">
<
xsl:call-template name=
"current_volume_string">
<
xsl:with-param name=
"current_volume_number" select=
"$current_volume_number"/>
</
xsl:call-template>
</
xsl:if>
<
xsl:text>\vfill
</
xsl:text>
<
xsl:call-template name=
"total_volumes_string"/>
<
xsl:call-template name=
"publisher"/>
<
xsl:call-template name=
"imprint"/>
</
xsl:template>
<
xsl:template name=
"volumecover">
<
xsl:text>\cleartorecto
</
xsl:text>
<
xsl:text>\savepagenumber
</
xsl:text>
<
xsl:call-template name=
"set_frontmatter_pagestyle"/>
<
xsl:call-template name=
"cover">
<
xsl:with-param name=
"current_volume_number" select=
"count(preceding::dtb:div[@class='volume-split-point'])+2"/>
</
xsl:call-template>
<
xsl:text>\cleartorecto
</
xsl:text>
<
xsl:if test=
"dtb:level1/dtb:list[descendant::dtb:lic]">
<
xsl:text>\tableofcontents*
</
xsl:text>
</
xsl:if>
<
xsl:call-template name=
"restore_pagestyle"/>
<
xsl:text>\restorepagenumber
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:head">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:meta|dtb:link"/>
<
xsl:template match=
"dtb:book">
<
xsl:text>\begin{document}
</
xsl:text>
<
xsl:if test=
"$alignment='left'">
<
xsl:text>\raggedright
</
xsl:text>
</
xsl:if>
<
xsl:apply-templates/>
<
xsl:if test=
"//(dtb:noteref|dtb:annoref) and $endnotes = 'document'">
<
xsl:text>\printpagenotes
</
xsl:text>
</
xsl:if>
<
xsl:text>\end{document}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:frontmatter">
<
xsl:call-template name=
"set_frontmatter_pagestyle"/>
<
xsl:text>\frontmatter
</
xsl:text>
<
xsl:apply-templates select=
"//dtb:meta" mode=
"titlePage"/>
<
xsl:call-template name=
"cover"/>
<
xsl:text>\cleartorecto
</
xsl:text>
<
xsl:if test=
"dtb:level1/dtb:list[descendant::dtb:lic]">
<
xsl:text>\tableofcontents*
</
xsl:text>
</
xsl:if>
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:frontmatter/dtb:level1/dtb:list[descendant::dtb:lic]" priority=
"1">
<
xsl:message>skipping lic in frontmatter!</
xsl:message>
</
xsl:template>
<
xsl:template match=
"dtb:meta[@name='dc:title' or @name='dc:Title']" mode=
"titlePage">
<
xsl:text>\title{</
xsl:text>
<
xsl:value-of select=
"my:quoteSpecialChars(string(@content))"/>
<
xsl:text>}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:meta[@name='dc:creator' or @name='dc:Creator']" mode=
"titlePage">
<
xsl:text>\author{</
xsl:text>
<
xsl:value-of select=
"my:quoteSpecialChars(string(@content))"/>
<
xsl:text>}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:meta[@name='dc:date' or @name='dc:Date']" mode=
"titlePage">
<
xsl:text>\date{</
xsl:text>
<
xsl:value-of select=
"my:quoteSpecialChars(string(@content))"/>
<
xsl:text>}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:level1">
<
xsl:if test=
"empty(dtb:h1)">
<
xsl:text>\chapter*{\ }
</
xsl:text>
<
xsl:text>\plainbreak{3}
</
xsl:text>
</
xsl:if>
<
xsl:apply-templates/>
<
xsl:if test=
".//(dtb:noteref|dtb:annoref) and $endnotes = 'chapter'">
<
xsl:text>\printpagenotes*
</
xsl:text>
</
xsl:if>
<
xsl:if test=
"following::*[1][self::dtb:p]">
<
xsl:text>\plainbreak{1}
</
xsl:text>
</
xsl:if>
</
xsl:template>
<
xsl:template name=
"maybe-insert-clearpage">
<
xsl:if test=
"$pageStyle=('spacious') and ancestor::dtb:bodymatter and my:has-preceding-para-within-parent-level(.)">
<
xsl:text>\clearpage
</
xsl:text>
</
xsl:if>
</
xsl:template>
<
xsl:template match=
"dtb:level2">
<
xsl:call-template name=
"maybe-insert-clearpage"/>
<
xsl:if test=
"empty(dtb:h2)">
<
xsl:text>\section*{\ }
</
xsl:text>
<
xsl:text>\plainbreak{3}
</
xsl:text>
</
xsl:if>
<
xsl:apply-templates/>
<
xsl:if test=
"following::*[1][self::dtb:p]">
<
xsl:text>\plainbreak{1}
</
xsl:text>
</
xsl:if>
</
xsl:template>
<
xsl:template match=
"dtb:level3">
<
xsl:if test=
"empty(dtb:h3)">
<
xsl:text>\subsection*{\ }
</
xsl:text>
<
xsl:text>\plainbreak{2}
</
xsl:text>
</
xsl:if>
<
xsl:apply-templates/>
<
xsl:if test=
"following::*[1][self::dtb:p]">
<
xsl:text>\plainbreak{1}
</
xsl:text>
</
xsl:if>
</
xsl:template>
<
xsl:template match=
"dtb:level4">
<
xsl:if test=
"empty(dtb:h4)">
<
xsl:text>\subsubsection*{\ }
</
xsl:text>
<
xsl:text>\plainbreak{1}
</
xsl:text>
</
xsl:if>
<
xsl:apply-templates/>
<
xsl:if test=
"following::*[1][self::dtb:p]">
<
xsl:text>\plainbreak{1}
</
xsl:text>
</
xsl:if>
</
xsl:template>
<
xsl:template match=
"dtb:level5">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:level6">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:level">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:doctitle">
</
xsl:template>
<
xsl:template match=
"dtb:docauthor">
</
xsl:template>
<
xsl:template match=
"dtb:covertitle">
</
xsl:template>
<
xsl:template match=
"dtb:p">
<
xsl:apply-templates/>
<
xsl:text>
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:pagenum">
<
xsl:if test=
"$pageStyle=('withPageNums', 'scientific')">
<
xsl:text>\marginpar{</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>}
</
xsl:text>
</
xsl:if>
</
xsl:template>
<
xsl:template match=
"dtb:address">
<
xsl:apply-templates/>
<
xsl:text>
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:address/dtb:line">
<
xsl:apply-templates/>
<
xsl:if test=
"following-sibling::*"><
xsl:text>\\</
xsl:text></
xsl:if>
<
xsl:text>
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:h1|dtb:h2|dtb:h3|dtb:h4|dtb:h5|dtb:h6">
<
xsl:variable name=
"level" select=
"local-name(ancestor::dtb:*[matches(local-name(),'^level[1-6]$')][1])"/>
<
xsl:value-of select=
"$level_to_section_map/entry[@key=$level]"/>
<
xsl:choose>
<
xsl:when test=
"ancestor::dtb:frontmatter">
<
xsl:text>*</
xsl:text>
</
xsl:when>
<
xsl:otherwise>
<
xsl:text>[</
xsl:text>
<
xsl:value-of select=
"normalize-space(my:quoteSpecialChars(string()))"/>
<
xsl:text>]</
xsl:text>
</
xsl:otherwise>
</
xsl:choose>
<
xsl:text>{</
xsl:text>
<
xsl:variable name=
"headline-content">
<
xsl:apply-templates/>
</
xsl:variable>
<
xsl:value-of select=
"normalize-space($headline-content)"/>
<
xsl:text>}
</
xsl:text>
<
xsl:apply-templates select=
"my:first-pagenum-anchor-before-headline(.)" mode=
"inside-headline"/>
</
xsl:template>
<
xsl:template match=
"dtb:bridgehead">
<
xsl:variable name=
"level" select=
"concat('level',number(substring-after(local-name(ancestor::dtb:*[matches(local-name(),'^level[1-6]$')][1]),'level'))+1)"/>
<
xsl:value-of select=
"$level_to_section_map/entry[@key=$level]"/>
<
xsl:text>*{</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:list[not(@type)]">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:lic">
<
xsl:apply-templates/>
<
xsl:if test=
"not(preceding-sibling::dtb:lic) and (following-sibling::dtb:lic or normalize-space(following-sibling::text())!='')">
<
xsl:text>\dotfill </
xsl:text>
</
xsl:if>
</
xsl:template>
<
xsl:template match=
"dtb:h1/dtb:br|dtb:h2/dtb:br|dtb:h3/dtb:br|dtb:h4/dtb:br|dtb:h5/dtb:br|dtb:h6/dtb:br|dtb:bridgehead/dtb:br">
<
xsl:text>\newline </
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:br">
<
xsl:text>\\*
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:bodymatter">
<
xsl:text>\mainmatter
</
xsl:text>
<
xsl:call-template name=
"restore_pagestyle"/>
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:noteref|dtb:annoref">
<
xsl:variable name=
"refText">
<
xsl:apply-templates select=
"//(dtb:note|dtb:annotation)[@id=translate(current()/@idref,'#','')]" mode=
"footnotes"/>
</
xsl:variable>
<
xsl:if test=
"self::dtb:annoref">
<
xsl:apply-templates/>
</
xsl:if>
<
xsl:choose>
<
xsl:when test=
"$endnotes = 'none'">
<
xsl:text>\footnotemark</
xsl:text>
<
xsl:text>\footnotetext{</
xsl:text>
<
xsl:if test=
"$alignment='left'"><
xsl:text>\raggedright </
xsl:text></
xsl:if>
<
xsl:value-of select=
"string($refText)"/>
<
xsl:text>}</
xsl:text>
</
xsl:when>
<
xsl:otherwise>
<
xsl:text>\pagenote{</
xsl:text>
<
xsl:value-of select=
"string($refText)"/>
<
xsl:text>}</
xsl:text>
</
xsl:otherwise>
</
xsl:choose>
</
xsl:template>
<
xsl:template match=
"dtb:img">
<
xsl:choose>
<
xsl:when test=
"$include_images='false'">
</
xsl:when>
<
xsl:otherwise>
<
xsl:variable name=
"captions" select=
"//dtb:caption[@id=tokenize(translate(current()/@imgref,'#',''), '\s+')]|following-sibling::*[1][self::dtb:caption]"/>
<
xsl:text>\begin{figure}[htbp!]
</
xsl:text>
<
xsl:value-of select=
"my:includegraphics-command(@src, exists($captions))"/>
<
xsl:apply-templates select=
"$captions" mode=
"referenced-caption"/>
<
xsl:text>\end{figure}
</
xsl:text>
</
xsl:otherwise>
</
xsl:choose>
</
xsl:template>
<
xsl:template match=
"dtb:h1/dtb:img|dtb:h2/dtb:img|dtb:h3/dtb:img|dtb:h4/dtb:img|dtb:h5/dtb:img|dtb:h6/dtb:img">
<
xsl:choose>
<
xsl:when test=
"$include_images='false'">
</
xsl:when>
<
xsl:otherwise>
<
xsl:value-of select=
"my:includegraphics-command(@src,false())"/>
</
xsl:otherwise>
</
xsl:choose>
</
xsl:template>
<
xsl:template match=
"dtb:table//dtb:img|dtb:sidebar//dtb:img" priority=
"10">
<
xsl:choose>
<
xsl:when test=
"$include_images='false'">
</
xsl:when>
<
xsl:otherwise>
<
xsl:variable name=
"captions" select=
"//dtb:caption[@id=tokenize(translate(current()/@imgref,'#',''), '\s+')]|following-sibling::*[1][self::dtb:caption]"/>
<
xsl:value-of select=
"my:includegraphics-command(@src, exists($captions))"/>
<
xsl:apply-templates select=
"$captions" mode=
"referenced-caption">
</
xsl:apply-templates>
</
xsl:otherwise>
</
xsl:choose>
</
xsl:template>
<
xsl:template match=
"dtb:caption">
</
xsl:template>
<
xsl:template match=
"dtb:caption" mode=
"referenced-caption">
<
xsl:variable name=
"caption" select=
"my:cleanCaptions(.)"/>
<
xsl:value-of select=
"concat('\legend{',$caption,'}
')"/>
<
xsl:value-of select=
"concat('\addcontentsline{lof}{figure}{',$caption,'}
')"/>
</
xsl:template>
<
xsl:template match=
"dtb:imggroup//dtb:prodnote" priority=
"100">
<
xsl:choose>
<
xsl:when test=
"exists(//dtb:img[@id=tokenize(translate(current()/@imgref,'#',''),'\s+')]|preceding-sibling::*[1][self::dtb:img])">
</
xsl:when>
<
xsl:otherwise>
<
xsl:text>\begin{tcolorbox}[colback=black!10,floatplacement=h!]</
xsl:text>
<
xsl:text>
\raggedright
</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>\end{tcolorbox}
</
xsl:text>
</
xsl:otherwise>
</
xsl:choose>
</
xsl:template>
<
xsl:template match=
"dtb:div">
<
xsl:text>\plainbreak{1.5}
</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>\plainbreak{1.5}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:div[@class='volume-split-point']">
<
xsl:call-template name=
"volumecover"/>
</
xsl:template>
<
xsl:template match=
"@*|node()" mode=
"volume-split">
<
xsl:if test=
"contains(@class, 'volume-split-point')">
<
xsl:if test=
"'volume-split-point'=tokenize(@class, '\s+')">
<
xsl:element name=
"div" namespace=
"http://www.daisy.org/z3986/2005/dtbook/">
<
xsl:attribute name=
"class" select=
"'volume-split-point'"/>
<
xsl:element name=
"p" namespace=
"http://www.daisy.org/z3986/2005/dtbook/"/>
</
xsl:element>
</
xsl:if>
</
xsl:if>
<
xsl:copy>
<
xsl:apply-templates select=
"@*|node()" mode=
"volume-split"/>
</
xsl:copy>
</
xsl:template>
<
xsl:template match=
"@class[contains(., 'volume-split-point')]" mode=
"volume-split">
<
xsl:attribute name=
"class" select=
"string-join(tokenize(., '\s+')[not(.='volume-split-point')], ' ')"/>
</
xsl:template>
<
xsl:template match=
"dtb:imggroup">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:author">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:author[parent::dtb:level|parent::dtb:level1|parent::dtb:level2|parent::dtb:level3|parent::dtb:level4|parent::dtb:level5|parent::dtb:level6|parent::dtb:div|parent::dtb:blockquote]">
<
xsl:apply-templates/>
<
xsl:text>
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:blockquote">
<
xsl:text>\begin{quote}
</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>\end{quote}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:byline">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:byline[parent::dtb:level|parent::dtb:level1|parent::dtb:level2|parent::dtb:level3|parent::dtb:level4|parent::dtb:level5|parent::dtb:level6|parent::dtb:div|parent::dtb:blockquote]">
<
xsl:apply-templates/>
<
xsl:text>
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:dateline">
<
xsl:apply-templates/>
<
xsl:text>
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:epigraph">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:note|dtb:annotation">
</
xsl:template>
<
xsl:template match=
"dtb:note|dtb:annotation" mode=
"footnotes">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:note/dtb:p|dtb:annotation/dtb:p">
<
xsl:apply-templates/>
<
xsl:if test=
"position() != last()"><
xsl:text>
</
xsl:text></
xsl:if>
</
xsl:template>
<
xsl:template match=
"dtb:sidebar">
<
xsl:text>\begin{tcolorbox}[breakable,floatplacement=htp!]
</
xsl:text>
<
xsl:text>\raggedright
</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>\end{tcolorbox}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:sidebar[@class='no-float']">
<
xsl:text>\begin{tcolorbox}[breakable,nofloat]
</
xsl:text>
<
xsl:text>\raggedright
</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>\end{tcolorbox}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:sidebar//dtb:sidebar">
<
xsl:text>\begin{tcolorbox}[nofloat]
</
xsl:text>
<
xsl:text>\raggedright
</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>\end{tcolorbox}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:sidebar/dtb:hd|dtb:linegroup/dtb:hd">
<
xsl:text>\textbf{</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:hd">
<
xsl:variable name=
"level">
<
xsl:value-of select=
"count(ancestor::dtb:level)"/>
</
xsl:variable>
<
xsl:value-of select=
"$level_to_section_map/entry[@key=concat('level',$level)]"/>
<
xsl:text>[</
xsl:text>
<
xsl:value-of select=
"text()"/>
<
xsl:text>]{</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:list/dtb:hd" mode=
"insert-heading">
<
xsl:text>\paragraph{</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:list/dtb:hd">
</
xsl:template>
<
xsl:template match=
"dtb:list[@type='ol']">
<
xsl:apply-templates select=
"dtb:hd" mode=
"insert-heading"/>
<
xsl:text>\begin{enumerate}</
xsl:text>
<
xsl:text>[</
xsl:text>
<
xsl:choose>
<
xsl:when test=
"@start"><
xsl:text>start=</
xsl:text><
xsl:value-of select=
"@start"/></
xsl:when>
<
xsl:otherwise><
xsl:text>start=1</
xsl:text></
xsl:otherwise>
</
xsl:choose>
<
xsl:if test=
"not(parent::dtb:li)">
<
xsl:text>,leftmargin=*</
xsl:text>
</
xsl:if>
<
xsl:choose>
<
xsl:when test=
"index-of(('1'), string(@enum))"><
xsl:text>,label=\arabic*.</
xsl:text></
xsl:when>
<
xsl:when test=
"index-of(('a'), string(@enum))"><
xsl:text>,label=\AlphLower*.</
xsl:text></
xsl:when>
<
xsl:when test=
"index-of(('A'), string(@enum))"><
xsl:text>,label=\AlphUpper*.</
xsl:text></
xsl:when>
<
xsl:when test=
"index-of(('i'), string(@enum))"><
xsl:text>,label=\roman*.</
xsl:text></
xsl:when>
<
xsl:when test=
"index-of(('I'), string(@enum))"><
xsl:text>,label=\Roman*.</
xsl:text></
xsl:when>
</
xsl:choose>
<
xsl:text>]
</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>\end{enumerate}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:list[@type='ul']">
<
xsl:apply-templates select=
"dtb:hd" mode=
"insert-heading"/>
<
xsl:text>\begin{itemize}[leftmargin=*]
</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>\end{itemize}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:list//dtb:list[@type='ul']" priority=
"10">
<
xsl:apply-templates select=
"dtb:hd" mode=
"insert-heading"/>
<
xsl:text>\begin{itemize}
</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>\end{itemize}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:list[@type='pl']">
<
xsl:apply-templates select=
"dtb:hd" mode=
"insert-heading"/>
<
xsl:text>\begin{trivlist}
</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>\end{trivlist}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:list//dtb:list[@type='pl']" priority=
"10">
<
xsl:apply-templates select=
"dtb:hd" mode=
"insert-heading"/>
<
xsl:text>\begin{enumerate}[label=,leftmargin=*,labelsep=*]
</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>\end{enumerate}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:li">
<
xsl:variable name=
"itemContent">
<
xsl:apply-templates/>
</
xsl:variable>
<
xsl:if test=
"not(./dtb:list) or ./text()[1][normalize-space() != '']">
<
xsl:text>\item </
xsl:text>
</
xsl:if>
<
xsl:value-of select=
"replace($itemContent,'^(\s*)(\[.*\])','$1{$2}')"/>
<
xsl:text>
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:dl">
<
xsl:text>\begin{longdescription}
</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>\end{longdescription}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:dt">
<
xsl:text>\item[</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>] </
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:dd">
<
xsl:apply-templates/>
<
xsl:text>
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:table">
<
xsl:variable name=
"normalized-table">
<
xsl:apply-templates mode=
"normalize-table" select=
"."/>
</
xsl:variable>
<
xsl:text>\begin{table}[H]
</
xsl:text>
<
xsl:text>\begin{tabulary}{\textwidth}{|</
xsl:text>
<
xsl:variable name=
"numcols">
<
xsl:value-of select=
"max(for $row in $normalized-table//dtb:tr return count($row/(dtb:td|dtb:th)))"/>
</
xsl:variable>
<
xsl:value-of select=
"string-join((for $col in 1 to $numcols return 'L'),'|')"/>
<
xsl:text>|} \hline
</
xsl:text>
<
xsl:apply-templates select=
"$normalized-table/dtb:table/dtb:thead, $normalized-table/dtb:table/dtb:tbody, $normalized-table/dtb:table/dtb:tfoot, $normalized-table/dtb:table/dtb:tr"/>
<
xsl:text>\end{tabulary}
</
xsl:text>
<
xsl:apply-templates select=
"dtb:caption"/>
<
xsl:text>\end{table}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:table" mode=
"normalize-table">
<
xsl:variable name=
"dtb:tr" as=
"element()*">
<
xsl:call-template name=
"dtb:insert-covered-table-cells">
<
xsl:with-param name=
"table_cells" select=
"dtb:tr/(dtb:td|dtb:th)"/>
<
xsl:with-param name=
"insert_if_colspan" select=
"false()" tunnel=
"yes"/>
</
xsl:call-template>
</
xsl:variable>
<
xsl:copy>
<
xsl:apply-templates mode=
"#current" select=
"(dtb:thead, $dtb:tr, dtb:tbody, dtb:tfoot)"/>
</
xsl:copy>
</
xsl:template>
<
xsl:template match=
"dtb:thead|dtb:tbody|dtb:tfoot" mode=
"normalize-table">
<
xsl:variable name=
"dtb:tr" as=
"element()*">
<
xsl:call-template name=
"dtb:insert-covered-table-cells">
<
xsl:with-param name=
"table_cells" select=
"dtb:tr/(dtb:td|dtb:th)"/>
<
xsl:with-param name=
"insert_if_colspan" select=
"false()" tunnel=
"yes"/>
</
xsl:call-template>
</
xsl:variable>
<
xsl:copy>
<
xsl:apply-templates mode=
"#current" select=
"$dtb:tr"/>
</
xsl:copy>
</
xsl:template>
<
xsl:template match=
"dtb:tr" mode=
"normalize-table">
<
xsl:sequence select=
"."/>
</
xsl:template>
<
xsl:template match=
"dtb:table/dtb:caption">
<
xsl:variable name=
"caption" select=
"my:cleanCaptions(.)"/>
<
xsl:value-of select=
"concat('\legend{',$caption,'}
')"/>
<
xsl:value-of select=
"concat('\addcontentsline{lot}{table}{',$caption,'}
')"/>
</
xsl:template>
<
xsl:template match=
"dtb:tbody">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:thead">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:tfoot">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:tr">
<
xsl:apply-templates/>
<
xsl:text>\\ </
xsl:text>
<
xsl:if test=
"not(following-sibling::dtb:tr[1]//(dtb:td|dtb:th)[@covered-table-cell='yes'])">
<
xsl:text>\hline</
xsl:text>
</
xsl:if>
<
xsl:text>
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:th">
<
xsl:if test=
"preceding-sibling::dtb:th">
<
xsl:text> & </
xsl:text>
</
xsl:if>
<
xsl:text>\textbf{</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>}</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:td">
<
xsl:if test=
"preceding-sibling::dtb:td">
<
xsl:text> & </
xsl:text>
</
xsl:if>
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:td[@colspan > 1]">
<
xsl:if test=
"preceding-sibling::dtb:td">
<
xsl:text> & </
xsl:text>
</
xsl:if>
<
xsl:text>\multicolumn{</
xsl:text><
xsl:value-of select=
"@colspan"/><
xsl:text>}{l|}{</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>}</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:th[@colspan > 1]">
<
xsl:if test=
"preceding-sibling::dtb:th">
<
xsl:text> & </
xsl:text>
</
xsl:if>
<
xsl:text>\multicolumn{</
xsl:text><
xsl:value-of select=
"@colspan"/><
xsl:text>}{l|}{\textbf{</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>}}</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:colgroup|dtb:col">
</
xsl:template>
<
xsl:template match=
"dtb:poem">
<
xsl:text>\begin{verse}
</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>\end{verse}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:poem/dtb:line|dtb:poem/dtb:author|dtb:poem/dtb:byline">
<
xsl:apply-templates/>
<
xsl:if test=
"following-sibling::*"><
xsl:text>\\</
xsl:text></
xsl:if>
<
xsl:text>
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:poem/dtb:title|dtb:poem/dtb:hd">
<
xsl:text>\PoemTitle*[]{</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:cite/dtb:title">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:cite">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:q">
<
xsl:text>\textsl{</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>}</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:samp|dtb:code|dtb:kbd">
<
xsl:text>\texttt{</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>}</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:samp[@xml:space='preserve']|dtb:code[@xml:space='preserve']">
<
xsl:text>\begin{alltt}</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>\end{alltt}</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:samp[@xml:space='preserve']//text()|dtb:code[@xml:space='preserve']//text()">
<
xsl:value-of select=
"replace(replace(., '\\', '\\textbackslash '), '(\{|\})', '\\$1')"/>
</
xsl:template>
<
xsl:template match=
"dtb:linegroup">
<
xsl:apply-templates select=
"*"/>
<
xsl:text>
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:linegroup/dtb:line">
<
xsl:apply-templates/>
<
xsl:if test=
"following-sibling::*"><
xsl:text>\\</
xsl:text></
xsl:if>
<
xsl:text>
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:line[normalize-space()='']" priority=
"1"/>
<
xsl:template match=
"dtb:line">
<
xsl:apply-templates/>
<
xsl:text>\\
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:linenum">
<
xsl:variable name=
"num">
<
xsl:apply-templates/>
</
xsl:variable>
<
xsl:value-of select=
"concat('\sidepar[',$num,']{',$num,'}')"/>
</
xsl:template>
<
xsl:template match=
"dtb:line//text()[(preceding-sibling::*|preceding-sibling::text())[1]/self::dtb:linenum]">
<
xsl:value-of select=
"my:quoteSpecialChars(replace(string(current()), '^\s+(.*)$', '$1'))"/>
</
xsl:template>
<
xsl:template match=
"dtb:prodnote">
<
xsl:text>\begin{tcolorbox}[colback=black!10,floatplacement=h!]</
xsl:text>
<
xsl:text>
\raggedright
</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>\end{tcolorbox}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:p/dtb:prodnote">
<
xsl:text>\begin{tcolorbox}[colback=black!10,nofloat,after={}]</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>\end{tcolorbox}
</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:rearmatter">
<
xsl:text>\backmatter
</
xsl:text>
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:a">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:a[@external='true']">
<
xsl:text>\url{</
xsl:text><
xsl:value-of select=
"my:quoteSpecialChars(replace(normalize-space(replace(string(), '(\{|\})', '')), '\\$', ''))"/><
xsl:text>}</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:a[@class='pageref' and starts-with(@href, '#')]">
<
xsl:value-of select=
"concat('\pageref{',substring(@href,2),'}')"/>
</
xsl:template>
<
xsl:template match=
"dtb:a[@id != '']">
<
xsl:value-of select=
"concat('\label{',@id,'}
')"/>
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:function name=
"my:is-pagenum-anchor" as=
"xs:boolean">
<
xsl:param name=
"anchor" as=
"element()"/>
<
xsl:sequence select=
"exists($anchor/preceding-sibling::*[1][self::dtb:pagenum])"/>
</
xsl:function>
<
xsl:function name=
"my:first-pagenum-anchor-before-headline" as=
"element()?">
<
xsl:param name=
"headline" as=
"element()"/>
<
xsl:sequence select=
"$headline/preceding-sibling::*[1][self::dtb:a and my:is-pagenum-anchor(.)]"/>
</
xsl:function>
<
xsl:function name=
"my:is-first-pagenum-anchor-before-headline" as=
"xs:boolean">
<
xsl:param name=
"anchor" as=
"element()"/>
<
xsl:sequence select=
"exists($anchor[my:is-pagenum-anchor(.)]/following-sibling::*[1][matches(name(),'h[1-6]')])"/>
</
xsl:function>
<
xsl:template match=
"dtb:a[@id != '']" mode=
"inside-headline">
<
xsl:value-of select=
"concat('\label{',@id,'}
')"/>
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:a[@id != '' and my:is-first-pagenum-anchor-before-headline(.)]" priority=
"10">
</
xsl:template>
<
xsl:template match=
"dtb:em">
<
xsl:choose>
<
xsl:when test=
"$replace_em_with_quote = 'true'">
<
xsl:text>'</
xsl:text>
</
xsl:when>
<
xsl:otherwise>
<
xsl:text>\emph{</
xsl:text>
</
xsl:otherwise>
</
xsl:choose>
<
xsl:apply-templates/>
<
xsl:choose>
<
xsl:when test=
"$replace_em_with_quote = 'true'">
<
xsl:text>'</
xsl:text>
</
xsl:when>
<
xsl:otherwise>
<
xsl:text>}</
xsl:text>
</
xsl:otherwise>
</
xsl:choose>
</
xsl:template>
<
xsl:template match=
"dtb:strong">
<
xsl:text>\textbf{</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>}</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:abbr">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:acronym">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:bdo">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:dfn">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:sent">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:w">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:sup">
<
xsl:text>\textsuperscript{</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>}</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:sub">
<
xsl:text>\textsubscript{</
xsl:text>
<
xsl:apply-templates/>
<
xsl:text>}</
xsl:text>
</
xsl:template>
<
xsl:template match=
"dtb:span">
<
xsl:apply-templates/>
</
xsl:template>
<
xsl:template match=
"dtb:abbr//text()">
<
xsl:value-of select=
"my:quoteSpecialChars(replace(normalize-space(string(current())), ' ', ' '))"/>
</
xsl:template>
<
xsl:function name=
"my:add-hyphenation-points" as=
"xs:string">
<
xsl:param name=
"word" as=
"xs:string"/>
<
xsl:variable name=
"margin" select=
"3"/>
<
xsl:choose>
<
xsl:when test=
"string-length($word) > $margin*2">
<
xsl:sequence select=
"string-join((substring($word,1,$margin), replace(substring($word,$margin+1,string-length($word)-(2*$margin+1)), '\w', '$0\\-'), substring($word,string-length($word)-$margin)),'')"/>
</
xsl:when>
<
xsl:otherwise>
<
xsl:sequence select=
"$word"/>
</
xsl:otherwise>
</
xsl:choose>
</
xsl:function>
<
xsl:function name=
"my:string-replace" as=
"xs:string">
<
xsl:param name=
"input" as=
"xs:string"/>
<
xsl:param name=
"substring" as=
"xs:string"/>
<
xsl:param name=
"replacement" as=
"xs:string"/>
<
xsl:variable name=
"before" select=
"substring-before($input,$substring)"/>
<
xsl:variable name=
"after" select=
"substring-after($input,$substring)"/>
<
xsl:choose>
<
xsl:when test=
"$input">
<
xsl:sequence select=
"string-join(($before,$replacement,$after),'')"/>
</
xsl:when>
<
xsl:otherwise>
<
xsl:sequence select=
"string-join(($before,$replacement,my:string-replace($after,$substring,$replacement)),'')"/>
</
xsl:otherwise>
</
xsl:choose>
</
xsl:function>
<
xsl:function name=
"my:hyphenate-long-words" as=
"xs:string">
<
xsl:param name=
"wordSequence" as=
"xs:string*"/>
<
xsl:param name=
"text" as=
"xs:string"/>
<
xsl:variable name=
"word" select=
"$wordSequence[1]"/>
<
xsl:variable name=
"rest" select=
"$wordSequence[position() gt 1]"/>
<
xsl:choose>
<
xsl:when test=
"empty($wordSequence)">
<
xsl:sequence select=
"$text"/>
</
xsl:when>
<
xsl:otherwise>
<
xsl:sequence select=
"my:hyphenate-long-words($rest, my:string-replace($text, $word, my:add-hyphenation-points($word)))"/>
</
xsl:otherwise>
</
xsl:choose>
</
xsl:function>
<
xsl:function name=
"my:hyphenate-dashed-words" as=
"xs:string">
<
xsl:param name=
"wordSequence" as=
"xs:string*"/>
<
xsl:param name=
"text" as=
"xs:string"/>
<
xsl:variable name=
"word" select=
"$wordSequence[1]"/>
<
xsl:variable name=
"rest" select=
"$wordSequence[position() gt 1]"/>
<
xsl:choose>
<
xsl:when test=
"empty($wordSequence)">
<
xsl:sequence select=
"$text"/>
</
xsl:when>
<
xsl:otherwise>
<
xsl:sequence select=
"my:hyphenate-dashed-words($rest, my:string-replace($text, $word, replace($word,'(\w)-(\w)','$1-\\hspace{0pt}$2')))"/>
</
xsl:otherwise>
</
xsl:choose>
</
xsl:function>
<
xsl:template match=
"text()">
<
xsl:variable name=
"sanitized" select=
"my:quoteSpecialChars(current())"/>
<
xsl:variable name=
"long-words" select=
"tokenize($sanitized,'\W+')[string-length(.) > my:max-line-width()]"/>
<
xsl:variable name=
"long-dashed-words" select=
"tokenize($sanitized,'(\p{Pc}|\p{Ps}|\p{Pe}|\p{Pi}|\p{Pf}|\p{Po}|\p{Z}|\p{C})+')[string-length(.) > 20][contains(.,'-')]"/>
<
xsl:variable name=
"tmp" select=
"my:hyphenate-long-words($long-words, $sanitized)"/>
<
xsl:value-of select=
"my:hyphenate-dashed-words($long-dashed-words, $tmp)"/>
</
xsl:template>
<
xsl:template match=
"text()" mode=
"textOnly">
<
xsl:value-of select=
"my:quoteSpecialChars(string(current()))"/>
</
xsl:template>
<
xsl:template match=
"dtb:*">
<
xsl:message>
*****<
xsl:value-of select=
"name(..)"/>/{<
xsl:value-of select=
"namespace-uri()"/>}<
xsl:value-of select=
"name()"/>******
</
xsl:message>
</
xsl:template>
</
xsl:stylesheet>