<
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:ep=
"http://schemas.openxmlformats.org/officeDocument/2006/extended-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:dcmitype=
"http://purl.org/dc/dcmitype/" xmlns:vt=
"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:d=
"org.daisy.pipeline.word_to_dtbook.impl.DaisyClass" xmlns=
"http://www.daisy.org/z3986/2005/dtbook/" xmlns:m=
"http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:mml=
"http://www.w3.org/1998/Math/MathML" version=
"2.0" exclude-result-prefixes=
"w pic wp dcterms xsi cp dc a r vt dcmitype xs d m mml">
<
xsl:output method=
"xml" encoding=
"UTF-8"/>
<
xsl:param name=
"InputFile" as=
"xs:string"/>
<
xsl:param name=
"OutputDir" as=
"xs:string"/>
<
xsl:param name=
"title" as=
"xs:string" select=
"''"/>
<
xsl:param name=
"creator" as=
"xs:string" select=
"''"/>
<
xsl:param name=
"publisher" as=
"xs:string" select=
"''"/>
<
xsl:param name=
"uid" as=
"xs:string" select=
"''"/>
<
xsl:param name=
"subject" as=
"xs:string" select=
"''"/>
<
xsl:param name=
"acceptRevisions" as=
"xs:boolean" select=
"true()"/>
<
xsl:param name=
"version" as=
"xs:string" select=
"'14'"/>
<
xsl:param name=
"pagination" as=
"xs:string" select=
"'custom'"/>
<
xsl:param name=
"MasterSub" as=
"xs:boolean" select=
"false()"/>
<
xsl:param name=
"ImageSizeOption" as=
"xs:string" select=
"'original'"/>
<
xsl:param name=
"DPI" as=
"xs:integer" select=
"96"/>
<
xsl:param name=
"CharacterStyles" as=
"xs:boolean" select=
"false()"/>
<
xsl:param name=
"FootnotesPosition" as=
"xs:string" select=
"'end'"/>
<
xsl:param name=
"FootnotesLevel" as=
"xs:integer" select=
"0"/>
<
xsl:param name=
"FootnotesNumbering" as=
"xs:string" select=
"'none'"/>
<
xsl:param name=
"FootnotesStartValue" as=
"xs:integer" select=
"1"/>
<
xsl:param name=
"FootnotesNumberingPrefix" as=
"xs:string?" select=
"''"/>
<
xsl:param name=
"FootnotesNumberingSuffix" as=
"xs:string?" select=
"''"/>
<
xsl:param name=
"Language" as=
"xs:string?" select=
"''"/>
<
xsl:param name=
"disableDateGeneration" as=
"xs:boolean" select=
"false()"/>
<
xsl:param name=
"extractShapes" as=
"xs:boolean" select=
"true()"/>
<
xsl:variable name=
"myObj" select=
"d:new($InputFile,$OutputDir,$extractShapes)"/>
<
xsl:variable name=
"documentXml" as=
"document-node(element(w:document))" select=
"document(concat('jar:',$InputFile,'!/word/document.xml'))"/>
<
xsl:variable name=
"docPropsAppXml" as=
"document-node(element(ep:Properties))" select=
"document(concat('jar:',$InputFile,'!/docProps/app.xml'))"/>
<
xsl:variable name=
"docPropsCoreXml" as=
"document-node(element(cp:coreProperties))" select=
"document(concat('jar:',$InputFile,'!/docProps/core.xml'))"/>
<
xsl:variable name=
"stylesXml" as=
"document-node(element(w:styles))" select=
"document(concat('jar:',$InputFile,'!/word/styles.xml'))"/>
<
xsl:variable name=
"numberingXml" as=
"document-node(element(w:numbering))?" select=
"document(concat('jar:',$InputFile,'!/word/numbering.xml'))"/>
<
xsl:variable name=
"footnotesXml" as=
"document-node(element(w:footnotes))?" select=
"document(concat('jar:',$InputFile,'!/word/footnotes.xml'))"/>
<
xsl:variable name=
"endnotesXml" as=
"document-node(element(w:endnotes))?" select=
"document(concat('jar:',$InputFile,'!/word/endnotes.xml'))"/>
<
xsl:variable name=
"documentLanguages">
<
xsl:variable name=
"runnerLanguages">
<
xsl:for-each select=
"$documentXml//w:body//w:r">
<
xsl:variable name=
"found">
<
xsl:call-template name=
"GetRunLanguage">
<
xsl:with-param name=
"runNode" select=
"."/>
</
xsl:call-template>
</
xsl:variable>
<
lang val=
"{$found}"/>
</
xsl:for-each>
</
xsl:variable>
<
xsl:variable name=
"uniqRunnerLanguages">
<
xsl:for-each select=
"$runnerLanguages/*:lang">
<
xsl:variable name=
"currentVal" select=
"@*:val"/>
<
xsl:if test=
"count(preceding-sibling::*:lang[@*:val=$currentVal])=0">
<
lang val=
"{$currentVal}"/>
</
xsl:if>
</
xsl:for-each>
</
xsl:variable>
<
xsl:variable name=
"paragraphLanguages">
<
xsl:for-each select=
"$documentXml//w:body//w:p">
<
xsl:variable name=
"found">
<
xsl:call-template name=
"GetParagraphLanguage">
<
xsl:with-param name=
"paragraphNode" select=
"."/>
</
xsl:call-template>
</
xsl:variable>
<
lang val=
"{$found}"/>
</
xsl:for-each>
<
xsl:for-each select=
"$uniqRunnerLanguages/*:lang">
<
lang val=
"{@*:val}"/>
</
xsl:for-each>
</
xsl:variable>
<
xsl:variable name=
"uniqLanguages">
<
xsl:for-each select=
"$paragraphLanguages/*:lang">
<
xsl:variable name=
"currentVal" select=
"@*:val"/>
<
xsl:if test=
"count(preceding-sibling::*:lang[@*:val=$currentVal])=0">
<
lang val=
"{$currentVal}" count=
"{count(following-sibling::*:lang[@*:val=$currentVal]) + 1}"/>
</
xsl:if>
</
xsl:for-each>
</
xsl:variable>
<
xsl:if test=
"$Language and string-length($Language) > 0">
<
lang val=
"{@*:val}"/>
</
xsl:if>
<
xsl:for-each select=
"$uniqLanguages/*:lang">
<
xsl:sort select=
"@*:count" data-type=
"number" order=
"descending"/>
<
xsl:if test=
"not($Language = @*:val)">
<
lang val=
"{@*:val}"/>
</
xsl:if>
</
xsl:for-each>
</
xsl:variable>
<
xsl:import href=
"Common.xsl"/>
<
xsl:import href=
"TOC.xsl"/>
<
xsl:import href=
"Common2.xsl"/>
<
xsl:import href=
"Common3.xsl"/>
<
xsl:import href=
"OOML2MML.xsl"/>
<
xsl:output method=
"xml" indent=
"no"/>
<
xsl:variable name=
"sOperators" as=
"xs:string" select=
"concat( '!"()+,-/⫾:;<', '=>?[\]{|}¡¬±', '·¿×÷ ', ' ‐‒–—‖†‡•․‥…', '‼⁀⁎⁏⁐ ⅀←↑', '→↓↔↕↖↗↘↙↚↛↜↝', '↞↟↠↡↢↣↤↥↦↧↨↩', '↪↫↬↭↮↯↰↱↲↳↶↷', '↺↻↼↽↾↿⇀⇁⇂⇃⇄⇅', '⇆⇇⇈⇉⇊⇋⇌⇍⇎⇏⇐⇑', '⇒⇓⇔⇕⇖⇗⇘⇙⇚⇛⇜⇝', '⇞⇟⇠⇡⇢⇣⇤⇥⇦⇧⇨⇩', '⇴⇵⇶⇷⇸⇹⇺⇻⇼⇽⇾⇿', '∀∁∂∃∄∆∇∈∉∊∋∌', '∍∏∐∑−∓∔∕∖∗∘∙', '√∛∜∝∣∤∥∦∧∨∩∪', '∫∬∭∮∯∰∱∲∳∴∵∶', '∷∸∹∺∻∼∽∾≀≁≂≃', '≄≅≆≇≈≉≊≋≌≍≎≏', '≐≑≒≓≔≕≖≗≘≙≚≛', '≜≝≞≟≠≡≢≣≤≥≦≧', '≨≩≪≫≬≭≮≯≰≱≲≳', '≴≵≶≷≸≹≺≻≼≽≾≿', '⊀⊁⊂⊃⊄⊅⊆⊇⊈⊉⊊⊋', '⊌⊍⊎⊏⊐⊑⊒⊓⊔⊕⊖⊗', '⊘⊙⊚⊛⊜⊝⊞⊟⊠⊡⊢⊣', '⊥⊦⊧⊨⊩⊪⊫⊬⊭⊮⊯⊰', '⊱⊲⊳⊴⊵⊶⊷⊸⊹⊺⊻⊼', '⊽⋀⋁⋂⋃⋄⋅⋆⋇⋈⋉⋊', '⋋⋌⋍⋎⋏⋐⋑⋒⋓⋔⋕⋖', '⋗⋘⋙⋚⋛⋜⋝⋞⋟⋠⋡⋢', '⋣⋤⋥⋦⋧⋨⋩⋪⋫⋬⋭⋮', '⋯⋰⋱⋲⋳⋴⋵⋶⋷⋸⋹⋺', '⋻⋼⋽⋾⋿⌅⌆⌈⌉⌊⌋⌜', '⌝⌞⌟⌢⌣〈〉⌽⌿⎰⎱▲', '△▴▵▶▷▸▹▼▽▾▿◀', '◁◂◃◄◅◊○◦◫◬◸◹', '◺◻◼◽◾◿★☆❲❳⟑⟒', '⟓⟔⟕⟖⟗⟘⟙⟚⟛⟜⟝⟞', '⟟⟠⟡⟢⟣⟤⟥⟦⟧⟨⟩⟪', '⟫⟰⟱⟲⟳⟴⟵⟶⟷⟸⟹⟺', '⟻⟼⟽⟾⟿⤀⤁⤂⤃⤄⤅⤆', '⤇⤈⤉⤊⤋⤌⤍⤎⤏⤐⤑⤒', '⤓⤔⤕⤖⤗⤘⤙⤚⤛⤜⤝⤞', '⤟⤠⤡⤢⤣⤤⤥⤦⤧⤨⤩⤪', '⤫⤬⤭⤮⤯⤰⤱⤲⤳⤴⤵⤶', '⤷⤸⤹⤺⤻⤼⤽⤾⤿⥀⥁⥂', '⥃⥄⥅⥆⥇⥈⥉⥊⥋⥌⥍⥎', '⥏⥐⥑⥒⥓⥔⥕⥖⥗⥘⥙⥚', '⥛⥜⥝⥞⥟⥠⥡⥢⥣⥤⥥⥦', '⥧⥨⥩⥪⥫⥬⥭⥮⥯⥰⥱⥲', '⥳⥴⥵⥶⥷⥸⥹⥺⥻⥼⥽⥾', '⥿⦀⦂⦃⦄⦅⦆⦇⦈⦉⦊⦋', '⦌⦍⦎⦏⦐⦑⦒⦓⦔⦕⦖⦗', '⦘⦙⦚⦶⦷⦸⦹⧀⧁⧄⧅⧆', '⧇⧈⧎⧏⧐⧑⧒⧓⧔⧕⧖⧗', '⧘⧙⧚⧛⧟⧡⧢⧣⧤⧥⧦⧫', '⧴⧵⧶⧷⧸⧹⧺⧻⧼⧽⧾⧿', '⨀⨁⨂⨃⨄⨅⨆⨇⨈⨉⨊⨋', '⨌⨍⨎⨏⨐⨑⨒⨓⨔⨕⨖⨗', '⨘⨙⨚⨛⨜⨝⨞⨟⨠⨡⨢⨣', '⨤⨥⨦⨧⨨⨩⨪⨫⨬⨭⨮⨯', '⨰⨱⨲⨳⨴⨵⨶⨷⨸⨹⨺⨻', '⨼⨽⨾⨿⩀⩁⩂⩃⩄⩅⩆⩇', '⩈⩉⩊⩋⩌⩍⩎⩏⩐⩑⩒⩓', '⩔⩕⩖⩗⩘⩙⩚⩛⩜⩝⩞⩟', '⩠⩡⩢⩣⩤⩥⩦⩧⩨⩩⩪⩫', '⩬⩭⩮⩯⩰⩱⩲⩳⩴⩵⩶⩷', '⩸⩹⩺⩻⩼⩽⩾⩿⪀⪁⪂⪃', '⪄⪅⪆⪇⪈⪉⪊⪋⪌⪍⪎⪏', '⪐⪑⪒⪓⪔⪕⪖⪗⪘⪙⪚⪛', '⪜⪝⪞⪟⪠⪡⪢⪣⪤⪥⪦⪧', '⪨⪩⪪⪫⪬⪭⪮⪯⪰⪱⪲⪳', '⪴⪵⪶⪷⪸⪹⪺⪻⪼⪽⪾⪿', '⫀⫁⫂⫃⫄⫅⫆⫇⫈⫉⫊⫋', '⫌⫍⫎⫏⫐⫑⫒⫓⫔⫕⫖⫗', '⫘⫙⫚⫛⫝̸⫝⫞⫟⫠⫢⫣⫤', '⫥⫦⫧⫨⫩⫪⫫⫬⫭⫮⫯⫰', '⫲⫳⫴⫵⫶⫷⫸⫹⫺⫻⫼⫽')"/>
<
xsl:variable name=
"sMinuses" as=
"xs:string">
<
xsl:call-template name=
"SRepeatChar">
<
xsl:with-param name=
"cchRequired" select=
"string-length($sOperators)"/>
<
xsl:with-param name=
"ch" select=
"'-'"/>
</
xsl:call-template>
</
xsl:variable>
<
xsl:variable name=
"sNumbers" as=
"xs:string" select=
"'0123456789'"/>
<
xsl:variable name=
"sZeros" as=
"xs:string">
<
xsl:call-template name=
"SRepeatChar">
<
xsl:with-param name=
"cchRequired" select=
"string-length($sNumbers)"/>
<
xsl:with-param name=
"ch" select=
"'0'"/>
</
xsl:call-template>
</
xsl:variable>
<
xsl:template name=
"main">
<
xsl:result-document encoding=
"utf-8" indent=
"yes">
<
xsl:text disable-output-escaping=
"yes"><!DOCTYPE dtbook PUBLIC '-//NISO//DTD dtbook 2005-3//EN' 'http://www.daisy.org/z3986/2005/dtbook-2005-3.dtd'</
xsl:text>
<
xsl:if test=
"count($documentXml//m:*) > 0">
<
xsl:text disable-output-escaping=
"yes">[
<!ENTITY % MATHML.prefixed "INCLUDE" >
<!ENTITY % MATHML.prefix "mml">
<!ENTITY % Schema.prefix "sch">
<!ENTITY % XLINK.prefix "xlp">
<!ENTITY % MATHML.Common.attrib
"xlink:href CDATA #IMPLIED
xlink:type CDATA #IMPLIED
class CDATA #IMPLIED
style CDATA #IMPLIED
id ID #IMPLIED
xref IDREF #IMPLIED
other CDATA #IMPLIED
xmlns:dtbook CDATA #FIXED
'http://www.daisy.org/z3986/2005/dtbook/'
dtbook:smilref CDATA #IMPLIED">
<!ENTITY % mathML2 PUBLIC '-//W3C//DTD MathML 2.0//EN' 'http://www.w3.org/Math/DTD/mathml2/mathml2.dtd'>
%mathML2;
<!ENTITY % externalFlow "| mml:math">
<!ENTITY % externalNamespaces "xmlns:mml CDATA #FIXED
'http://www.w3.org/1998/Math/MathML'" >
]</
xsl:text>
</
xsl:if>
<
xsl:text disable-output-escaping=
"yes"> >
</
xsl:text>
<
dtbook version=
"2005-3">
<
xsl:if test=
"count($documentXml//m:*) > 0">
<
xsl:namespace name=
"mml" select=
"'http://www.w3.org/1998/Math/MathML'"/>
</
xsl:if>
<
xsl:attribute name=
"xml:lang">
<
xsl:value-of select=
"$documentLanguages/*:lang[1]/@*:val"/>
</
xsl:attribute>
<
xsl:variable name=
"documentDate" as=
"xs:string" select=
"$docPropsCoreXml//cp:coreProperties/dcterms:modified"/>
<
xsl:variable name=
"documentSubject" as=
"xs:string" select=
"d:DocPropSubject($myObj)"/>
<
xsl:variable name=
"documentDescription" as=
"xs:string" select=
"d:DocPropDescription($myObj)"/>
<
head>
<
xsl:variable name=
"Auto" as=
"xs:string" select=
"concat('AUTO-UID-',d:GenerateId())"/>
<
xsl:choose>
<
xsl:when test=
"string-length($uid) = 0">
<
meta name=
"dtb:uid" content=
"{$Auto}"/>
</
xsl:when>
<
xsl:otherwise>
<
meta name=
"dtb:uid" content=
"{$uid}"/>
</
xsl:otherwise>
</
xsl:choose>
<
meta name=
"dtb:generator" content=
"DAISY Pipeline 2 word-to-dtbook 1.0.0"/>
<
xsl:choose>
<
xsl:when test=
"string-length($title) = 0">
<
meta name=
"dc:Title" content=
"{$docPropsCoreXml//cp:coreProperties/dc:title/text()}"/>
</
xsl:when>
<
xsl:otherwise>
<
meta name=
"dc:Title" content=
"{$title}"/>
</
xsl:otherwise>
</
xsl:choose>
<
xsl:choose>
<
xsl:when test=
"string-length($creator) = 0">
<
xsl:variable name=
"creatorFromPackage" select=
"$docPropsCoreXml//cp:coreProperties/dc:creator/text()"/>
<
xsl:if test=
"string-length($creatorFromPackage)!=0">
<
meta name=
"dc:Creator" content=
"{$creatorFromPackage}"/>
</
xsl:if>
</
xsl:when>
<
xsl:otherwise>
<
meta name=
"dc:Creator" content=
"{$creator}"/>
</
xsl:otherwise>
</
xsl:choose>
<
xsl:if test=
"string-length($documentDate)!=0 and not($disableDateGeneration)">
<
meta name=
"dc:Date" content=
"{substring-before($documentDate,'T')}"/>
</
xsl:if>
<
xsl:choose>
<
xsl:when test=
"string-length($publisher) = 0">
<
xsl:variable name=
"publisherFromPackage" select=
"$docPropsAppXml//ep:Properties/ep:Company/text()"/>
<
xsl:if test=
"string-length($publisherFromPackage)!=0">
<
meta name=
"dc:Publisher" content=
"{$publisherFromPackage}"/>
</
xsl:if>
</
xsl:when>
<
xsl:otherwise>
<
meta name=
"dc:Publisher" content=
"{$publisher}"/>
</
xsl:otherwise>
</
xsl:choose>
<
xsl:choose>
<
xsl:when test=
"string-length($subject)!=0">
<
meta name=
"dc:Subject" content=
"{$subject}"/>
</
xsl:when>
<
xsl:otherwise>
<
xsl:if test=
"string-length($documentSubject)!=0">
<
meta name=
"dc:Subject" content=
"{$documentSubject}"/>
</
xsl:if>
</
xsl:otherwise>
</
xsl:choose>
<
xsl:if test=
"string-length($documentDescription)!=0">
<
meta name=
"dc:Description" content=
"{$documentDescription}"/>
</
xsl:if>
<
xsl:choose>
<
xsl:when test=
"string-length($uid) = 0">
<
meta name=
"dc:Identifier" content=
"{$Auto}"/>
</
xsl:when>
<
xsl:otherwise>
<
meta name=
"dc:Identifier" content=
"{$uid}"/>
</
xsl:otherwise>
</
xsl:choose>
<
xsl:for-each select=
"$documentLanguages/*:lang">
<
xsl:sequence select=
"d:sink(d:AddLanguage($myObj,@val))"/>
<
meta name=
"dc:Language" content=
"{@val}"/>
</
xsl:for-each>
</
head>
<
book showin=
"blp">
<
xsl:if test=
"not($MasterSub)">
<
xsl:for-each select=
"$documentXml//w:document/w:body/node()">
<
xsl:if test=
"self::w:p">
<
xsl:for-each select=
"w:pPr/w:pStyle[substring(@w:val,1,11)='Frontmatter']">
<
xsl:if test=
"d:PushPageStyle($myObj,@w:val)"/>
</
xsl:for-each>
<
xsl:for-each select=
"w:pPr/w:pStyle[substring(@w:val,1,10)='Bodymatter']">
<
xsl:if test=
"d:PushPageStyle($myObj,@w:val)"/>
</
xsl:for-each>
<
xsl:for-each select=
"w:pPr/w:pStyle[substring(@w:val,1,10)='Rearmatter']">
<
xsl:if test=
"d:PushPageStyle($myObj,@w:val)"/>
</
xsl:for-each>
<
xsl:for-each select=
"w:r/w:rPr/w:rStyle[substring(@w:val,1,11)='Frontmatter']">
<
xsl:if test=
"d:PushPageStyle($myObj,@w:val)"/>
</
xsl:for-each>
<
xsl:for-each select=
"w:r/w:rPr/w:rStyle[substring(@w:val,1,10)='Bodymatter']">
<
xsl:if test=
"d:PushPageStyle($myObj,@w:val)"/>
</
xsl:for-each>
<
xsl:for-each select=
"w:r/w:rPr/w:rStyle[substring(@w:val,1,10)='Rearmatter']">
<
xsl:if test=
"d:PushPageStyle($myObj,@w:val)"/>
</
xsl:for-each>
<
xsl:sequence select=
"d:IncrementCheckingParagraph($myObj)"/>
</
xsl:if>
</
xsl:for-each>
<
xsl:if test=
"d:IsInvalidPageStylesSequence($myObj)='true'">
<
xsl:message terminate=
"yes">
<
xsl:value-of select=
"d:GetPageStylesErrors($myObj)"/>
</
xsl:message>
</
xsl:if>
</
xsl:if>
<
frontmatter>
<
doctitle>
<
xsl:choose>
<
xsl:when test=
"string-length($title) = 0">
<
xsl:value-of select=
"$docPropsCoreXml//cp:coreProperties/dc:title"/>
</
xsl:when>
<
xsl:otherwise>
<
xsl:value-of select=
"$title"/>
</
xsl:otherwise>
</
xsl:choose>
</
doctitle>
<
docauthor>
<
xsl:choose>
<
xsl:when test=
"string-length($creator) = 0">
<
xsl:value-of select=
"$docPropsCoreXml//cp:coreProperties/dc:creator"/>
</
xsl:when>
<
xsl:otherwise>
<
xsl:value-of select=
"$creator"/>
</
xsl:otherwise>
</
xsl:choose>
</
docauthor>
<
xsl:if test=
" count($documentXml//w:document/w:body/w:p[position() > 1]/w:pPr/w:pStyle[substring(@w:val,1,10)='Bodymatter'])=1 or count($documentXml//w:document/w:body/w:p/w:r[position() > 1]/w:rPr/w:rStyle[substring(@w:val,1,10)='Bodymatter'])=1 ">
<
xsl:call-template name=
"Matter">
<
xsl:with-param name=
"acceptRevisions" select=
"$acceptRevisions"/>
<
xsl:with-param name=
"version" select=
"$version"/>
<
xsl:with-param name=
"pagination" select=
"$pagination"/>
<
xsl:with-param name=
"masterSub" select=
"$MasterSub"/>
<
xsl:with-param name=
"sOperators" select=
"$sOperators"/>
<
xsl:with-param name=
"sMinuses" select=
"$sMinuses"/>
<
xsl:with-param name=
"sNumbers" select=
"$sNumbers"/>
<
xsl:with-param name=
"sZeros" select=
"$sZeros"/>
<
xsl:with-param name=
"imgOption" select=
"$ImageSizeOption"/>
<
xsl:with-param name=
"dpi" select=
"$DPI"/>
<
xsl:with-param name=
"charStyles" select=
"$CharacterStyles"/>
<
xsl:with-param name=
"matterType" select=
"'Frontmatter'"/>
</
xsl:call-template>
</
xsl:if>
</
frontmatter>
<
bodymatter id=
"bodymatter_0001">
<
xsl:call-template name=
"Matter">
<
xsl:with-param name=
"acceptRevisions" select=
"$acceptRevisions"/>
<
xsl:with-param name=
"version" select=
"$version"/>
<
xsl:with-param name=
"pagination" select=
"$pagination"/>
<
xsl:with-param name=
"masterSub" select=
"$MasterSub"/>
<
xsl:with-param name=
"sOperators" select=
"$sOperators"/>
<
xsl:with-param name=
"sMinuses" select=
"$sMinuses"/>
<
xsl:with-param name=
"sNumbers" select=
"$sNumbers"/>
<
xsl:with-param name=
"sZeros" select=
"$sZeros"/>
<
xsl:with-param name=
"imgOption" select=
"$ImageSizeOption"/>
<
xsl:with-param name=
"dpi" select=
"$DPI"/>
<
xsl:with-param name=
"charStyles" select=
"$CharacterStyles"/>
<
xsl:with-param name=
"matterType" select=
"'Bodymatter'"/>
</
xsl:call-template>
</
bodymatter>
<
xsl:if test=
"( count($documentXml//w:document/w:body/w:p/w:pPr/w:pStyle[substring(@w:val,1,10)='Rearmatter'])=1 or count($documentXml//w:document/w:body/w:p/w:r/w:rPr/w:rStyle[substring(@w:val,1,10)='Rearmatter'])=1 or count($documentXml//w:document/w:body/w:p/w:r/w:rPr/w:rStyle[@w:val='EndnoteReference']) > 0 or count($documentXml//w:document/w:body/w:p/w:r/w:endnoteReference) > 0 )">
<
rearmatter>
<
xsl:if test=
"count( $documentXml//w:document/w:body/w:p/w:r[ ./w:rPr/w:rStyle[@w:val='EndnoteReference'] or ./w:endnoteReference ] ) > 0">
<
level1>
<
xsl:for-each select=
"( $documentXml//w:document/w:body/w:p/w:r[ ./w:rPr/w:rStyle[@w:val='EndnoteReference'] or ./w:endnoteReference ] )">
<
xsl:variable name=
"endNoteId" as=
"xs:integer" select=
"./w:endnoteReference/@w:id"/>
<
xsl:if test=
"$endNoteId > 0">
<
note>
<
xsl:attribute name=
"id">
<
xsl:value-of select=
"concat('endnote-',$endNoteId)"/>
</
xsl:attribute>
<
xsl:attribute name=
"class">
<
xsl:value-of select=
"'Endnote'"/>
</
xsl:attribute>
<
xsl:for-each select=
"$endnotesXml//w:endnotes/w:endnote">
<
xsl:if test=
"@w:id=$endNoteId">
<
xsl:for-each select=
"./node()">
<
xsl:if test=
"self::w:p">
<
xsl:call-template name=
"ParagraphStyle">
<
xsl:with-param name=
"version" select=
"$version"/>
<
xsl:with-param name=
"flagNote" select=
"'endnote'"/>
<
xsl:with-param name=
"checkid" select=
"$endNoteId + 1"/>
<
xsl:with-param name=
"sOperators" select=
"$sOperators"/>
<
xsl:with-param name=
"sMinuses" select=
"$sMinuses"/>
<
xsl:with-param name=
"sNumbers" select=
"$sNumbers"/>
<
xsl:with-param name=
"sZeros" select=
"$sZeros"/>
<
xsl:with-param name=
"characterparaStyle" select=
"false()"/>
</
xsl:call-template>
</
xsl:if>
</
xsl:for-each>
<
xsl:sequence select=
"d:sink(d:InitializeNoteFlag($myObj))"/>
</
xsl:if>
</
xsl:for-each>
</
note>
</
xsl:if>
</
xsl:for-each>
</
level1>
</
xsl:if>
<
xsl:call-template name=
"Matter">
<
xsl:with-param name=
"acceptRevisions" select=
"$acceptRevisions"/>
<
xsl:with-param name=
"version" select=
"$version"/>
<
xsl:with-param name=
"pagination" select=
"$pagination"/>
<
xsl:with-param name=
"masterSub" select=
"$MasterSub"/>
<
xsl:with-param name=
"sOperators" select=
"$sOperators"/>
<
xsl:with-param name=
"sMinuses" select=
"$sMinuses"/>
<
xsl:with-param name=
"sNumbers" select=
"$sNumbers"/>
<
xsl:with-param name=
"sZeros" select=
"$sZeros"/>
<
xsl:with-param name=
"imgOption" select=
"$ImageSizeOption"/>
<
xsl:with-param name=
"dpi" select=
"$DPI"/>
<
xsl:with-param name=
"charStyles" select=
"$CharacterStyles"/>
<
xsl:with-param name=
"matterType" select=
"'Rearmatter'"/>
</
xsl:call-template>
</
rearmatter>
</
xsl:if>
</
book>
</
dtbook>
</
xsl:result-document>
<
xsl:sequence select=
"d:End($myObj)"/>
</
xsl:template>
</
xsl:stylesheet>