commons.xsl 102 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244
  1. <?xml version='1.0'?>
  2. <!--
  3. Copyright ? 2004-2006 by Idiom Technologies, Inc. All rights reserved.
  4. IDIOM is a registered trademark of Idiom Technologies, Inc. and WORLDSERVER
  5. and WORLDSTART are trademarks of Idiom Technologies, Inc. All other
  6. trademarks are the property of their respective owners.
  7. IDIOM TECHNOLOGIES, INC. IS DELIVERING THE SOFTWARE "AS IS," WITH
  8. ABSOLUTELY NO WARRANTIES WHATSOEVER, WHETHER EXPRESS OR IMPLIED, AND IDIOM
  9. TECHNOLOGIES, INC. DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
  10. BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11. PURPOSE AND WARRANTY OF NON-INFRINGEMENT. IDIOM TECHNOLOGIES, INC. SHALL NOT
  12. BE LIABLE FOR INDIRECT, INCIDENTAL, SPECIAL, COVER, PUNITIVE, EXEMPLARY,
  13. RELIANCE, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO LOSS OF
  14. ANTICIPATED PROFIT), ARISING FROM ANY CAUSE UNDER OR RELATED TO OR ARISING
  15. OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE, EVEN IF IDIOM
  16. TECHNOLOGIES, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  17. Idiom Technologies, Inc. and its licensors shall not be liable for any
  18. damages suffered by any person as a result of using and/or modifying the
  19. Software or its derivatives. In no event shall Idiom Technologies, Inc.'s
  20. liability for any damages hereunder exceed the amounts received by Idiom
  21. Technologies, Inc. as a result of this transaction.
  22. These terms and conditions supersede the terms and conditions in any
  23. licensing agreement to the extent that such terms and conditions conflict
  24. with those set forth herein.
  25. This file is part of the DITA Open Toolkit project.
  26. See the accompanying license.txt file for applicable licenses.
  27. -->
  28. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  29. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  30. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  31. xmlns:opentopic="http://www.idiominc.com/opentopic"
  32. xmlns:opentopic-index="http://www.idiominc.com/opentopic/index"
  33. xmlns:opentopic-func="http://www.idiominc.com/opentopic/exsl/function"
  34. xmlns:dita2xslfo="http://dita-ot.sourceforge.net/ns/200910/dita2xslfo"
  35. xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
  36. xmlns:ot-placeholder="http://suite-sol.com/namespaces/ot-placeholder"
  37. exclude-result-prefixes="dita-ot ot-placeholder opentopic opentopic-index opentopic-func dita2xslfo xs"
  38. version="2.0">
  39. <xsl:key name="id" match="*[@id]" use="@id"/>
  40. <xsl:key name="map-id"
  41. match="opentopic:map//*[@id][empty(ancestor::*[contains(@class, ' map/reltable ')])]"
  42. use="@id"/>
  43. <xsl:key name="topic-id"
  44. match="*[@id][contains(@class, ' topic/topic ')] |
  45. ot-placeholder:*[@id]"
  46. use="@id"/>
  47. <xsl:key name="class" match="*[@class]" use="tokenize(@class, ' ')"/>
  48. <xsl:key name="fnById" match="*[contains(@class, ' topic/fn ')]" use="@id"/>
  49. <!--
  50. A key with all elements that need to be numbered.
  51. To get the number of an element using this key, you can use the << node
  52. comparison operator in XPath 2 to get all elements in the key that appear
  53. before the current element in the tree. For example, to get the number of
  54. topic/fig elements before the current element, you would do something like:
  55. <xsl:value-of select="count(key('enumerableByClass', 'topic/fig')[. &lt;&lt; current()])"/>
  56. This is much faster than using the preceding:: axis and somewhat faster than
  57. using the <xsl:number> element.
  58. -->
  59. <xsl:key name="enumerableByClass"
  60. match="*[contains(@class, ' topic/fig ')][*[contains(@class, ' topic/title ')]] |
  61. *[contains(@class, ' topic/table ')][*[contains(@class, ' topic/title ')]] |
  62. *[contains(@class,' topic/fn ') and empty(@callout)]"
  63. use="tokenize(@class, ' ')"/>
  64. <!-- Deprecated since 2.3 -->
  65. <xsl:variable name="msgprefix" select="'PDFX'"/>
  66. <xsl:variable name="id.toc" select="'ID_TOC_00-0F-EA-40-0D-4D'"/>
  67. <xsl:variable name="id.index" select="'ID_INDEX_00-0F-EA-40-0D-4D'"/>
  68. <xsl:variable name="id.lot" select="'ID_LOT_00-0F-EA-40-0D-4D'"/>
  69. <xsl:variable name="id.lof" select="'ID_LOF_00-0F-EA-40-0D-4D'"/>
  70. <xsl:variable name="id.glossary" select="'ID_GLOSSARY_00-0F-EA-40-0D-4D'"/>
  71. <xsl:variable name="root" select="/" as="document-node()"/>
  72. <!-- In order to not process any data under opentopic:map -->
  73. <xsl:template match="opentopic:map"/>
  74. <!-- get the max chars for shortdesc-->
  75. <xsl:variable name="maxCharsInShortDesc" as="xs:integer">
  76. <xsl:call-template name="getMaxCharsForShortdescKeep"/>
  77. </xsl:variable>
  78. <xsl:template match="*[@conref]" priority="99">
  79. <fo:block xsl:use-attribute-sets="__unresolved__conref">
  80. <xsl:apply-templates select="." mode="insertReferenceTitle">
  81. <xsl:with-param name="href" select="@conref"/>
  82. <xsl:with-param name="titlePrefix" select="'Content-Reference'"/>
  83. </xsl:apply-templates>
  84. </fo:block>
  85. </xsl:template>
  86. <xsl:template name="startPageNumbering" as="attribute()*">
  87. <!--BS: uncomment if you need reset page numbering at first chapter-->
  88. <!--
  89. <xsl:variable name="id" select="ancestor-or-self::*[contains(@class, ' topic/topic ')][1]/@id"/>
  90. <xsl:variable name="mapTopic" select="key('map-id', $id)"/>
  91. <xsl:if test="not(($mapTopic/preceding::*[contains(@class, ' bookmap/chapter ') or contains(@class, ' bookmap/part ')])
  92. or ($mapTopic/ancestor::*[contains(@class, ' bookmap/chapter ') or contains(@class, ' bookmap/part ')]))">
  93. <xsl:attribute name="initial-page-number">1</xsl:attribute>
  94. </xsl:if>
  95. -->
  96. </xsl:template>
  97. <xsl:template match="*" mode="processTopic">
  98. <fo:block xsl:use-attribute-sets="topic">
  99. <xsl:apply-templates select="." mode="commonTopicProcessing"/>
  100. </fo:block>
  101. </xsl:template>
  102. <xsl:template match="*" mode="commonTopicProcessing">
  103. <xsl:if test="empty(ancestor::*[contains(@class, ' topic/topic ')])">
  104. <fo:marker marker-class-name="current-topic-number">
  105. <xsl:variable name="topicref" select="key('map-id', ancestor-or-self::*[contains(@class, ' topic/topic ')][1]/@id)"/>
  106. <xsl:for-each select="$topicref">
  107. <xsl:apply-templates select="." mode="topicTitleNumber"/>
  108. </xsl:for-each>
  109. </fo:marker>
  110. </xsl:if>
  111. <xsl:apply-templates select="*[contains(@class, ' topic/title ')]"/>
  112. <xsl:apply-templates select="*[contains(@class, ' topic/prolog ')]"/>
  113. <xsl:apply-templates select="*[not(contains(@class, ' topic/title ')) and
  114. not(contains(@class, ' topic/prolog ')) and
  115. not(contains(@class, ' topic/topic '))]"/>
  116. <!--xsl:apply-templates select="." mode="buildRelationships"/-->
  117. <xsl:apply-templates select="*[contains(@class,' topic/topic ')]"/>
  118. <xsl:apply-templates select="." mode="topicEpilog"/>
  119. </xsl:template>
  120. <!-- Hook that allows common end-of-topic processing (after nested topics). -->
  121. <xsl:template match="*" mode="topicEpilog">
  122. </xsl:template>
  123. <xsl:template match="*[contains(@class, ' topic/topic ')]">
  124. <xsl:variable name="topicType" as="xs:string">
  125. <xsl:call-template name="determineTopicType"/>
  126. </xsl:variable>
  127. <xsl:choose>
  128. <xsl:when test="$topicType = 'topicChapter'">
  129. <xsl:call-template name="processTopicChapter"/>
  130. </xsl:when>
  131. <xsl:when test="$topicType = 'topicAppendix'">
  132. <xsl:call-template name="processTopicAppendix"/>
  133. </xsl:when>
  134. <xsl:when test="$topicType = 'topicAppendices'">
  135. <xsl:call-template name="processTopicAppendices"/>
  136. </xsl:when>
  137. <xsl:when test="$topicType = 'topicPart'">
  138. <xsl:call-template name="processTopicPart"/>
  139. </xsl:when>
  140. <xsl:when test="$topicType = 'topicPreface'">
  141. <xsl:call-template name="processTopicPreface"/>
  142. </xsl:when>
  143. <xsl:when test="$topicType = 'topicNotices'">
  144. <xsl:if test="$retain-bookmap-order">
  145. <xsl:call-template name="processTopicNotices"/>
  146. </xsl:if>
  147. </xsl:when>
  148. <xsl:when test="$topicType = 'topicTocList'">
  149. <xsl:call-template name="processTocList"/>
  150. </xsl:when>
  151. <xsl:when test="$topicType = 'topicIndexList'">
  152. <xsl:call-template name="processIndexList"/>
  153. </xsl:when>
  154. <xsl:when test="$topicType = 'topicFrontMatter'">
  155. <xsl:call-template name="processFrontMatterTopic"/>
  156. </xsl:when>
  157. <xsl:when test="$topicType = 'topicSimple'">
  158. <xsl:call-template name="processTopicSimple"/>
  159. </xsl:when>
  160. <xsl:otherwise>
  161. <xsl:apply-templates select="." mode="processUnknowTopic">
  162. <xsl:with-param name="topicType" select="$topicType"/>
  163. </xsl:apply-templates>
  164. </xsl:otherwise>
  165. </xsl:choose>
  166. </xsl:template>
  167. <xsl:template match="*" mode="processUnknowTopic"
  168. name="processTopicSimple">
  169. <xsl:param name="topicType"/>
  170. <xsl:variable name="page-sequence-reference" select="if ($mapType = 'bookmap') then 'body-sequence' else 'ditamap-body-sequence'"/>
  171. <xsl:choose>
  172. <xsl:when test="empty(ancestor::*[contains(@class,' topic/topic ')]) and empty(ancestor::ot-placeholder:glossarylist)">
  173. <fo:page-sequence master-reference="{$page-sequence-reference}" xsl:use-attribute-sets="page-sequence.body">
  174. <xsl:call-template name="startPageNumbering"/>
  175. <xsl:call-template name="insertBodyStaticContents"/>
  176. <fo:flow flow-name="xsl-region-body">
  177. <xsl:apply-templates select="." mode="processTopic"/>
  178. </fo:flow>
  179. </fo:page-sequence>
  180. </xsl:when>
  181. <xsl:otherwise>
  182. <xsl:apply-templates select="." mode="processTopic"/>
  183. </xsl:otherwise>
  184. </xsl:choose>
  185. </xsl:template>
  186. <xsl:template match="*" mode="insertTopicHeaderMarker">
  187. <xsl:param name="marker-class-name" as="xs:string">current-header</xsl:param>
  188. <fo:marker marker-class-name="{$marker-class-name}">
  189. <xsl:apply-templates select="." mode="insertTopicHeaderMarkerContents"/>
  190. </fo:marker>
  191. </xsl:template>
  192. <xsl:template match="*[contains(@class, ' topic/topic ')]" mode="insertTopicHeaderMarkerContents">
  193. <xsl:apply-templates select="*[contains(@class,' topic/title ')]" mode="getTitle"/>
  194. </xsl:template>
  195. <xsl:template match="*[contains(@class, ' topic/title ')]" mode="insertTopicHeaderMarkerContents">
  196. <xsl:apply-templates select="." mode="getTitle"/>
  197. </xsl:template>
  198. <!-- Bookmap Chapter processing -->
  199. <xsl:template name="processTopicChapter">
  200. <fo:page-sequence master-reference="body-sequence" xsl:use-attribute-sets="page-sequence.body">
  201. <xsl:call-template name="startPageNumbering"/>
  202. <xsl:call-template name="insertBodyStaticContents"/>
  203. <fo:flow flow-name="xsl-region-body">
  204. <fo:block xsl:use-attribute-sets="topic">
  205. <xsl:call-template name="commonattributes"/>
  206. <xsl:variable name="level" as="xs:integer">
  207. <xsl:apply-templates select="." mode="get-topic-level"/>
  208. </xsl:variable>
  209. <xsl:if test="$level eq 1">
  210. <fo:marker marker-class-name="current-topic-number">
  211. <xsl:variable name="topicref" select="key('map-id', ancestor-or-self::*[contains(@class, ' topic/topic ')][1]/@id)"/>
  212. <xsl:for-each select="$topicref">
  213. <xsl:apply-templates select="." mode="topicTitleNumber"/>
  214. </xsl:for-each>
  215. </fo:marker>
  216. <xsl:apply-templates select="." mode="insertTopicHeaderMarker"/>
  217. </xsl:if>
  218. <xsl:apply-templates select="*[contains(@class,' topic/prolog ')]"/>
  219. <xsl:call-template name="insertChapterFirstpageStaticContent">
  220. <xsl:with-param name="type" select="'chapter'"/>
  221. </xsl:call-template>
  222. <fo:block xsl:use-attribute-sets="topic.title">
  223. <xsl:call-template name="pullPrologIndexTerms"/>
  224. <xsl:for-each select="*[contains(@class,' topic/title ')]">
  225. <xsl:apply-templates select="." mode="getTitle"/>
  226. </xsl:for-each>
  227. </fo:block>
  228. <xsl:choose>
  229. <xsl:when test="$chapterLayout='BASIC'">
  230. <xsl:apply-templates select="*[not(contains(@class, ' topic/topic ') or contains(@class, ' topic/title ') or
  231. contains(@class, ' topic/prolog '))]"/>
  232. <!--xsl:apply-templates select="." mode="buildRelationships"/-->
  233. </xsl:when>
  234. <xsl:otherwise>
  235. <xsl:apply-templates select="." mode="createMiniToc"/>
  236. </xsl:otherwise>
  237. </xsl:choose>
  238. <xsl:apply-templates select="*[contains(@class,' topic/topic ')]"/>
  239. <xsl:call-template name="pullPrologIndexTerms.end-range"/>
  240. </fo:block>
  241. </fo:flow>
  242. </fo:page-sequence>
  243. </xsl:template>
  244. <!-- Bookmap Appendix processing -->
  245. <xsl:template name="processTopicAppendix">
  246. <fo:page-sequence master-reference="body-sequence" xsl:use-attribute-sets="page-sequence.appendix">
  247. <xsl:call-template name="startPageNumbering"/>
  248. <xsl:call-template name="insertBodyStaticContents"/>
  249. <fo:flow flow-name="xsl-region-body">
  250. <fo:block xsl:use-attribute-sets="topic">
  251. <xsl:call-template name="commonattributes"/>
  252. <xsl:variable name="level" as="xs:integer">
  253. <xsl:apply-templates select="." mode="get-topic-level"/>
  254. </xsl:variable>
  255. <xsl:if test="$level eq 1">
  256. <fo:marker marker-class-name="current-topic-number">
  257. <xsl:variable name="topicref" select="key('map-id', ancestor-or-self::*[contains(@class, ' topic/topic ')][1]/@id)"/>
  258. <xsl:for-each select="$topicref">
  259. <xsl:apply-templates select="." mode="topicTitleNumber"/>
  260. </xsl:for-each>
  261. </fo:marker>
  262. <xsl:apply-templates select="." mode="insertTopicHeaderMarker"/>
  263. </xsl:if>
  264. <xsl:apply-templates select="*[contains(@class,' topic/prolog ')]"/>
  265. <xsl:call-template name="insertChapterFirstpageStaticContent">
  266. <xsl:with-param name="type" select="'appendix'"/>
  267. </xsl:call-template>
  268. <fo:block xsl:use-attribute-sets="topic.title">
  269. <xsl:call-template name="pullPrologIndexTerms"/>
  270. <xsl:for-each select="*[contains(@class,' topic/title ')]">
  271. <xsl:apply-templates select="." mode="getTitle"/>
  272. </xsl:for-each>
  273. </fo:block>
  274. <xsl:choose>
  275. <xsl:when test="$appendixLayout='BASIC'">
  276. <xsl:apply-templates select="*[not(contains(@class, ' topic/topic ') or contains(@class, ' topic/title ') or
  277. contains(@class, ' topic/prolog '))]"/>
  278. <!--xsl:apply-templates select="." mode="buildRelationships"/-->
  279. </xsl:when>
  280. <xsl:otherwise>
  281. <xsl:apply-templates select="." mode="createMiniToc"/>
  282. </xsl:otherwise>
  283. </xsl:choose>
  284. <xsl:apply-templates select="*[contains(@class,' topic/topic ')]"/>
  285. <xsl:call-template name="pullPrologIndexTerms.end-range"/>
  286. </fo:block>
  287. </fo:flow>
  288. </fo:page-sequence>
  289. </xsl:template>
  290. <!-- Bookmap appendices processing -->
  291. <xsl:template name="processTopicAppendices">
  292. <fo:page-sequence master-reference="body-sequence" xsl:use-attribute-sets="page-sequence.appendix">
  293. <xsl:call-template name="startPageNumbering"/>
  294. <xsl:call-template name="insertBodyStaticContents"/>
  295. <fo:flow flow-name="xsl-region-body">
  296. <fo:block xsl:use-attribute-sets="topic">
  297. <xsl:call-template name="commonattributes"/>
  298. <xsl:if test="empty(ancestor::*[contains(@class, ' topic/topic ')])">
  299. <fo:marker marker-class-name="current-topic-number">
  300. <xsl:variable name="topicref" select="key('map-id', ancestor-or-self::*[contains(@class, ' topic/topic ')][1]/@id)"/>
  301. <xsl:for-each select="$topicref">
  302. <xsl:apply-templates select="." mode="topicTitleNumber"/>
  303. </xsl:for-each>
  304. </fo:marker>
  305. <xsl:apply-templates select="." mode="insertTopicHeaderMarker"/>
  306. </xsl:if>
  307. <xsl:apply-templates select="*[contains(@class,' topic/prolog ')]"/>
  308. <xsl:call-template name="insertChapterFirstpageStaticContent">
  309. <xsl:with-param name="type" select="'appendices'"/>
  310. </xsl:call-template>
  311. <fo:block xsl:use-attribute-sets="topic.title">
  312. <xsl:call-template name="pullPrologIndexTerms"/>
  313. <xsl:for-each select="*[contains(@class,' topic/title ')]">
  314. <xsl:apply-templates select="." mode="getTitle"/>
  315. </xsl:for-each>
  316. </fo:block>
  317. <xsl:choose>
  318. <xsl:when test="$appendicesLayout='BASIC'">
  319. <xsl:apply-templates select="*[not(contains(@class, ' topic/topic ') or contains(@class, ' topic/title ') or
  320. contains(@class, ' topic/prolog '))]"/>
  321. <!--xsl:apply-templates select="." mode="buildRelationships"/-->
  322. </xsl:when>
  323. <xsl:otherwise>
  324. <xsl:apply-templates select="." mode="createMiniToc"/>
  325. </xsl:otherwise>
  326. </xsl:choose>
  327. <xsl:for-each select="*[contains(@class,' topic/topic ')]">
  328. <xsl:variable name="topicType" as="xs:string">
  329. <xsl:call-template name="determineTopicType"/>
  330. </xsl:variable>
  331. <xsl:if test="$topicType = 'topicSimple'">
  332. <xsl:apply-templates select="."/>
  333. </xsl:if>
  334. </xsl:for-each>
  335. <xsl:call-template name="pullPrologIndexTerms.end-range"/>
  336. </fo:block>
  337. </fo:flow>
  338. </fo:page-sequence>
  339. <xsl:for-each select="*[contains(@class,' topic/topic ')]">
  340. <xsl:variable name="topicType" as="xs:string">
  341. <xsl:call-template name="determineTopicType"/>
  342. </xsl:variable>
  343. <xsl:if test="not($topicType = 'topicSimple')">
  344. <xsl:apply-templates select="."/>
  345. </xsl:if>
  346. </xsl:for-each>
  347. </xsl:template>
  348. <!-- Bookmap Part processing -->
  349. <xsl:template name="processTopicPart">
  350. <fo:page-sequence master-reference="body-sequence" xsl:use-attribute-sets="page-sequence.part">
  351. <xsl:call-template name="startPageNumbering"/>
  352. <xsl:call-template name="insertBodyStaticContents"/>
  353. <fo:flow flow-name="xsl-region-body">
  354. <fo:block xsl:use-attribute-sets="topic">
  355. <xsl:call-template name="commonattributes"/>
  356. <xsl:if test="empty(ancestor::*[contains(@class, ' topic/topic ')])">
  357. <fo:marker marker-class-name="current-topic-number">
  358. <xsl:variable name="topicref" select="key('map-id', ancestor-or-self::*[contains(@class, ' topic/topic ')][1]/@id)"/>
  359. <xsl:for-each select="$topicref">
  360. <xsl:apply-templates select="." mode="topicTitleNumber"/>
  361. </xsl:for-each>
  362. </fo:marker>
  363. <xsl:apply-templates select="." mode="insertTopicHeaderMarker"/>
  364. </xsl:if>
  365. <xsl:apply-templates select="*[contains(@class,' topic/prolog ')]"/>
  366. <xsl:call-template name="insertChapterFirstpageStaticContent">
  367. <xsl:with-param name="type" select="'part'"/>
  368. </xsl:call-template>
  369. <fo:block xsl:use-attribute-sets="topic.title">
  370. <xsl:call-template name="pullPrologIndexTerms"/>
  371. <xsl:for-each select="*[contains(@class,' topic/title ')]">
  372. <xsl:apply-templates select="." mode="getTitle"/>
  373. </xsl:for-each>
  374. </fo:block>
  375. <xsl:choose>
  376. <xsl:when test="$partLayout='BASIC'">
  377. <xsl:apply-templates select="*[not(contains(@class, ' topic/topic ') or contains(@class, ' topic/title ') or
  378. contains(@class, ' topic/prolog '))]"/>
  379. <!--xsl:apply-templates select="." mode="buildRelationships"/-->
  380. </xsl:when>
  381. <xsl:otherwise>
  382. <xsl:apply-templates select="." mode="createMiniToc"/>
  383. </xsl:otherwise>
  384. </xsl:choose>
  385. <xsl:for-each select="*[contains(@class,' topic/topic ')]">
  386. <xsl:variable name="topicType" as="xs:string">
  387. <xsl:call-template name="determineTopicType"/>
  388. </xsl:variable>
  389. <xsl:if test="$topicType = 'topicSimple'">
  390. <xsl:apply-templates select="."/>
  391. </xsl:if>
  392. </xsl:for-each>
  393. <xsl:call-template name="pullPrologIndexTerms.end-range"/>
  394. </fo:block>
  395. </fo:flow>
  396. </fo:page-sequence>
  397. <xsl:for-each select="*[contains(@class,' topic/topic ')]">
  398. <xsl:variable name="topicType" as="xs:string">
  399. <xsl:call-template name="determineTopicType"/>
  400. </xsl:variable>
  401. <xsl:if test="not($topicType = 'topicSimple')">
  402. <xsl:apply-templates select="."/>
  403. </xsl:if>
  404. </xsl:for-each>
  405. </xsl:template>
  406. <xsl:template name="processTopicNotices">
  407. <xsl:variable name="atts" as="element()">
  408. <xsl:choose>
  409. <xsl:when test="key('map-id', ancestor-or-self::*[contains(@class, ' topic/topic ')][1]/@id)/ancestor::*[contains(@class,' bookmap/backmatter ')]">
  410. <dummy xsl:use-attribute-sets="page-sequence.backmatter.notice"/>
  411. </xsl:when>
  412. <xsl:otherwise>
  413. <dummy xsl:use-attribute-sets="page-sequence.notice"/>
  414. </xsl:otherwise>
  415. </xsl:choose>
  416. </xsl:variable>
  417. <fo:page-sequence master-reference="body-sequence">
  418. <xsl:copy-of select="$atts/@*"/>
  419. <xsl:call-template name="startPageNumbering"/>
  420. <xsl:call-template name="insertPrefaceStaticContents"/>
  421. <fo:flow flow-name="xsl-region-body">
  422. <fo:block xsl:use-attribute-sets="topic">
  423. <xsl:call-template name="commonattributes"/>
  424. <xsl:if test="empty(ancestor::*[contains(@class, ' topic/topic ')])">
  425. <fo:marker marker-class-name="current-topic-number">
  426. <xsl:variable name="topicref" select="key('map-id', ancestor-or-self::*[contains(@class, ' topic/topic ')][1]/@id)"/>
  427. <xsl:for-each select="$topicref">
  428. <xsl:apply-templates select="." mode="topicTitleNumber"/>
  429. </xsl:for-each>
  430. </fo:marker>
  431. <xsl:apply-templates select="." mode="insertTopicHeaderMarker"/>
  432. </xsl:if>
  433. <xsl:apply-templates select="*[contains(@class,' topic/prolog ')]"/>
  434. <xsl:call-template name="insertChapterFirstpageStaticContent">
  435. <xsl:with-param name="type" select="'notices'"/>
  436. </xsl:call-template>
  437. <fo:block xsl:use-attribute-sets="topic.title">
  438. <xsl:call-template name="pullPrologIndexTerms"/>
  439. <xsl:for-each select="*[contains(@class,' topic/title ')]">
  440. <xsl:apply-templates select="." mode="getTitle"/>
  441. </xsl:for-each>
  442. </fo:block>
  443. <xsl:choose>
  444. <xsl:when test="$noticesLayout='BASIC'">
  445. <xsl:apply-templates select="*[not(contains(@class, ' topic/topic ') or contains(@class, ' topic/title ') or
  446. contains(@class, ' topic/prolog '))]"/>
  447. <!--xsl:apply-templates select="." mode="buildRelationships"/-->
  448. </xsl:when>
  449. <xsl:otherwise>
  450. <xsl:apply-templates select="." mode="createMiniToc"/>
  451. </xsl:otherwise>
  452. </xsl:choose>
  453. <xsl:apply-templates select="*[contains(@class,' topic/topic ')]"/>
  454. <xsl:call-template name="pullPrologIndexTerms.end-range"/>
  455. </fo:block>
  456. </fo:flow>
  457. </fo:page-sequence>
  458. </xsl:template>
  459. <xsl:template name="processFrontMatterTopic">
  460. <fo:page-sequence master-reference="body-sequence" xsl:use-attribute-sets="page-sequence.frontmatter">
  461. <!-- Ideally would use existing template "insertFrontMatterStaticContents". Using "insertBodyStaticContents"
  462. for compatibility with 2.3 and earlier; front matter version drops headers, page numbers. -->
  463. <xsl:call-template name="insertBodyStaticContents"/>
  464. <fo:flow flow-name="xsl-region-body">
  465. <fo:block xsl:use-attribute-sets="topic">
  466. <xsl:call-template name="commonattributes"/>
  467. <xsl:if test="not(ancestor::*[contains(@class, ' topic/topic ')])">
  468. <fo:marker marker-class-name="current-topic-number">
  469. <xsl:number format="1"/>
  470. </fo:marker>
  471. <xsl:apply-templates select="." mode="insertTopicHeaderMarker"/>
  472. </xsl:if>
  473. <xsl:apply-templates select="*[contains(@class,' topic/prolog ')]"/>
  474. <fo:block xsl:use-attribute-sets="topic.title">
  475. <xsl:attribute name="id">
  476. <xsl:call-template name="generate-toc-id"/>
  477. </xsl:attribute>
  478. <xsl:call-template name="pullPrologIndexTerms"/>
  479. <xsl:for-each select="child::*[contains(@class,' topic/title ')]">
  480. <xsl:apply-templates select="." mode="getTitle"/>
  481. </xsl:for-each>
  482. </fo:block>
  483. <xsl:apply-templates select="*[not(contains(@class,' topic/title '))]"/>
  484. </fo:block>
  485. </fo:flow>
  486. </fo:page-sequence>
  487. </xsl:template>
  488. <xsl:template name="insertChapterFirstpageStaticContent">
  489. <xsl:param name="type" as="xs:string"/>
  490. <fo:block>
  491. <xsl:attribute name="id">
  492. <xsl:call-template name="generate-toc-id"/>
  493. </xsl:attribute>
  494. <xsl:choose>
  495. <xsl:when test="$type = 'chapter'">
  496. <fo:block xsl:use-attribute-sets="__chapter__frontmatter__name__container">
  497. <xsl:call-template name="getVariable">
  498. <xsl:with-param name="id" select="'Chapter with number'"/>
  499. <xsl:with-param name="params">
  500. <number>
  501. <fo:block xsl:use-attribute-sets="__chapter__frontmatter__number__container">
  502. <xsl:apply-templates select="key('map-id', @id)[1]" mode="topicTitleNumber"/>
  503. </fo:block>
  504. </number>
  505. </xsl:with-param>
  506. </xsl:call-template>
  507. </fo:block>
  508. </xsl:when>
  509. <xsl:when test="$type = 'appendix'">
  510. <fo:block xsl:use-attribute-sets="__chapter__frontmatter__name__container">
  511. <xsl:call-template name="getVariable">
  512. <xsl:with-param name="id" select="'Appendix with number'"/>
  513. <xsl:with-param name="params">
  514. <number>
  515. <fo:block xsl:use-attribute-sets="__chapter__frontmatter__number__container">
  516. <xsl:apply-templates select="key('map-id', @id)[1]" mode="topicTitleNumber"/>
  517. </fo:block>
  518. </number>
  519. </xsl:with-param>
  520. </xsl:call-template>
  521. </fo:block>
  522. </xsl:when>
  523. <xsl:when test="$type = 'appendices'">
  524. <fo:block xsl:use-attribute-sets="__chapter__frontmatter__name__container">
  525. <xsl:call-template name="getVariable">
  526. <xsl:with-param name="id" select="'Appendix with number'"/>
  527. <xsl:with-param name="params">
  528. <number>
  529. <fo:block xsl:use-attribute-sets="__chapter__frontmatter__number__container">
  530. <xsl:text>&#xA0;</xsl:text>
  531. </fo:block>
  532. </number>
  533. </xsl:with-param>
  534. </xsl:call-template>
  535. </fo:block>
  536. </xsl:when>
  537. <xsl:when test="$type = 'part'">
  538. <fo:block xsl:use-attribute-sets="__chapter__frontmatter__name__container">
  539. <xsl:call-template name="getVariable">
  540. <xsl:with-param name="id" select="'Part with number'"/>
  541. <xsl:with-param name="params">
  542. <number>
  543. <fo:block xsl:use-attribute-sets="__chapter__frontmatter__number__container">
  544. <xsl:apply-templates select="key('map-id', @id)[1]" mode="topicTitleNumber"/>
  545. </fo:block>
  546. </number>
  547. </xsl:with-param>
  548. </xsl:call-template>
  549. </fo:block>
  550. </xsl:when>
  551. <xsl:when test="$type = 'preface'">
  552. <fo:block xsl:use-attribute-sets="__chapter__frontmatter__name__container">
  553. <xsl:call-template name="getVariable">
  554. <xsl:with-param name="id" select="'Preface title'"/>
  555. </xsl:call-template>
  556. </fo:block>
  557. </xsl:when>
  558. <xsl:when test="$type = 'notices'">
  559. <fo:block xsl:use-attribute-sets="__chapter__frontmatter__name__container">
  560. <xsl:call-template name="getVariable">
  561. <xsl:with-param name="id" select="'Notices title'"/>
  562. </xsl:call-template>
  563. </fo:block>
  564. </xsl:when>
  565. </xsl:choose>
  566. </fo:block>
  567. </xsl:template>
  568. <xsl:template match="*[contains(@class, ' bookmap/chapter ')] |
  569. opentopic:map/*[contains(@class, ' map/topicref ')]" mode="topicTitleNumber" priority="-1">
  570. <xsl:variable name="chapters">
  571. <xsl:document>
  572. <xsl:for-each select="$map/descendant::*[contains(@class, ' bookmap/chapter ')]">
  573. <xsl:sequence select="."/>
  574. </xsl:for-each>
  575. </xsl:document>>
  576. </xsl:variable>
  577. <xsl:for-each select="$chapters/*[current()/@id = @id]">
  578. <xsl:number format="1" count="*[contains(@class, ' bookmap/chapter ')]"/>
  579. </xsl:for-each>
  580. </xsl:template>
  581. <xsl:template match="*[contains(@class, ' bookmap/appendix ')]" mode="topicTitleNumber">
  582. <xsl:number format="A" count="*[contains(@class, ' bookmap/appendix ')]"/>
  583. </xsl:template>
  584. <xsl:template match="*[contains(@class, ' bookmap/part ')]" mode="topicTitleNumber">
  585. <xsl:number format="I" count="*[contains(@class, ' bookmap/part ')]"/>
  586. </xsl:template>
  587. <xsl:template match="*" mode="topicTitleNumber" priority="-10">
  588. <!--xsl:message>No topicTitleNumber mode template for <xsl:value-of select="name()"/></xsl:message-->
  589. </xsl:template>
  590. <xsl:template match="*" mode="createMiniToc">
  591. <fo:table xsl:use-attribute-sets="__toc__mini__table">
  592. <fo:table-column xsl:use-attribute-sets="__toc__mini__table__column_1"/>
  593. <fo:table-column xsl:use-attribute-sets="__toc__mini__table__column_2"/>
  594. <fo:table-body xsl:use-attribute-sets="__toc__mini__table__body">
  595. <fo:table-row>
  596. <fo:table-cell>
  597. <fo:block xsl:use-attribute-sets="__toc__mini">
  598. <xsl:if test="*[contains(@class, ' topic/topic ')]">
  599. <fo:block xsl:use-attribute-sets="__toc__mini__header">
  600. <xsl:call-template name="getVariable">
  601. <xsl:with-param name="id" select="'Mini Toc'"/>
  602. </xsl:call-template>
  603. </fo:block>
  604. <fo:list-block xsl:use-attribute-sets="__toc__mini__list">
  605. <xsl:apply-templates select="*[contains(@class, ' topic/topic ')]" mode="in-this-chapter-list"/>
  606. </fo:list-block>
  607. </xsl:if>
  608. </fo:block>
  609. </fo:table-cell>
  610. <fo:table-cell xsl:use-attribute-sets="__toc__mini__summary">
  611. <!--Really, it would be better to just apply-templates, but the attribute sets for shortdesc, body
  612. and abstract might indent the text. Here, the topic body is in a table cell, and should
  613. not be indented, so each element is handled specially.-->
  614. <fo:block>
  615. <xsl:apply-templates select="*[contains(@class,' topic/titlealts ')]"/>
  616. <xsl:if test="*[contains(@class,' topic/shortdesc ')
  617. or contains(@class, ' topic/abstract ')]/node()">
  618. <fo:block xsl:use-attribute-sets="p">
  619. <xsl:apply-templates select="*[contains(@class,' topic/shortdesc ')
  620. or contains(@class, ' topic/abstract ')]/node()"/>
  621. </fo:block>
  622. </xsl:if>
  623. <xsl:apply-templates select="*[contains(@class,' topic/body ')]/*"/>
  624. <xsl:if test="*[contains(@class,' topic/related-links ')]//
  625. *[contains(@class,' topic/link ')][not(@role) or @role!='child']">
  626. <xsl:apply-templates select="*[contains(@class,' topic/related-links ')]"/>
  627. </xsl:if>
  628. </fo:block>
  629. </fo:table-cell>
  630. </fo:table-row>
  631. </fo:table-body>
  632. </fo:table>
  633. </xsl:template>
  634. <xsl:template match="*[contains(@class, ' topic/topic ')]" mode="in-this-chapter-list">
  635. <fo:list-item xsl:use-attribute-sets="ul.li">
  636. <fo:list-item-label xsl:use-attribute-sets="ul.li__label">
  637. <fo:block xsl:use-attribute-sets="ul.li__label__content">
  638. <xsl:call-template name="getVariable">
  639. <xsl:with-param name="id" select="'Unordered List bullet'"/>
  640. </xsl:call-template>
  641. </fo:block>
  642. </fo:list-item-label>
  643. <fo:list-item-body xsl:use-attribute-sets="ul.li__body">
  644. <fo:block xsl:use-attribute-sets="ul.li__content">
  645. <fo:basic-link internal-destination="{@id}" xsl:use-attribute-sets="xref">
  646. <xsl:value-of select="*[contains(@class, ' topic/title ')]"/>
  647. </fo:basic-link>
  648. </fo:block>
  649. </fo:list-item-body>
  650. </fo:list-item>
  651. </xsl:template>
  652. <!-- h[n] -->
  653. <xsl:template match="*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/title ')]">
  654. <xsl:variable name="topicType" as="xs:string">
  655. <xsl:call-template name="determineTopicType"/>
  656. </xsl:variable>
  657. <xsl:choose>
  658. <!-- Disable chapter title processing when mini TOC is created -->
  659. <xsl:when test="(topicType = 'topicChapter') or (topicType = 'topicAppendix')" />
  660. <!-- Normal processing -->
  661. <xsl:otherwise>
  662. <xsl:apply-templates select="." mode="processTopicTitle"/>
  663. </xsl:otherwise>
  664. </xsl:choose>
  665. </xsl:template>
  666. <xsl:template match="*" mode="processTopicTitle">
  667. <xsl:variable name="level" as="xs:integer">
  668. <xsl:apply-templates select="." mode="get-topic-level"/>
  669. </xsl:variable>
  670. <xsl:variable name="attrSet1">
  671. <xsl:apply-templates select="." mode="createTopicAttrsName">
  672. <xsl:with-param name="theCounter" select="$level"/>
  673. </xsl:apply-templates>
  674. </xsl:variable>
  675. <xsl:variable name="attrSet2" select="concat($attrSet1, '__content')"/>
  676. <fo:block>
  677. <xsl:call-template name="commonattributes"/>
  678. <xsl:call-template name="processAttrSetReflection">
  679. <xsl:with-param name="attrSet" select="$attrSet1"/>
  680. <xsl:with-param name="path" select="'../../cfg/fo/attrs/commons-attr.xsl'"/>
  681. </xsl:call-template>
  682. <fo:block>
  683. <xsl:call-template name="processAttrSetReflection">
  684. <xsl:with-param name="attrSet" select="$attrSet2"/>
  685. <xsl:with-param name="path" select="'../../cfg/fo/attrs/commons-attr.xsl'"/>
  686. </xsl:call-template>
  687. <xsl:if test="$level = 1">
  688. <xsl:apply-templates select="." mode="insertTopicHeaderMarker"/>
  689. </xsl:if>
  690. <xsl:if test="$level = 2">
  691. <xsl:apply-templates select="." mode="insertTopicHeaderMarker">
  692. <xsl:with-param name="marker-class-name" as="xs:string">current-h2</xsl:with-param>
  693. </xsl:apply-templates>
  694. </xsl:if>
  695. <fo:wrapper id="{parent::node()/@id}"/>
  696. <fo:wrapper>
  697. <xsl:attribute name="id">
  698. <xsl:call-template name="generate-toc-id">
  699. <xsl:with-param name="element" select=".."/>
  700. </xsl:call-template>
  701. </xsl:attribute>
  702. </fo:wrapper>
  703. <xsl:call-template name="pullPrologIndexTerms"/>
  704. <xsl:apply-templates select="." mode="getTitle"/>
  705. </fo:block>
  706. </fo:block>
  707. </xsl:template>
  708. <xsl:template match="*" mode="get-topic-level" as="xs:integer">
  709. <xsl:variable name="topicref" select="key('map-id', ancestor-or-self::*[contains(@class,' topic/topic ')][1]/@id)"/>
  710. <xsl:sequence select="count(ancestor-or-self::*[contains(@class,' topic/topic ')]) -
  711. count($topicref/ancestor-or-self::*[(contains(@class,' bookmap/part ') and
  712. ((exists(@navtitle) or
  713. *[contains(@class,' map/topicmeta ')]/*[contains(@class,' topic/navtitle ')]) or
  714. (exists(@href) and
  715. (empty(@format) or @format eq 'dita') and
  716. (empty(@scope) or @scope eq 'local')))) or
  717. (contains(@class,' bookmap/appendices ') and
  718. exists(@href) and
  719. (empty(@format) or @format eq 'dita') and
  720. (empty(@scope) or @scope eq 'local'))])"/>
  721. </xsl:template>
  722. <xsl:template match="*" mode="createTopicAttrsName">
  723. <xsl:param name="theCounter" as="xs:integer"/>
  724. <xsl:param name="theName" select="''" as="xs:string"/>
  725. <xsl:choose>
  726. <xsl:when test="$theCounter > 0">
  727. <xsl:apply-templates select="." mode="createTopicAttrsName">
  728. <xsl:with-param name="theCounter" select="$theCounter - 1"/>
  729. <xsl:with-param name="theName" select="concat($theName, 'topic.')"/>
  730. </xsl:apply-templates>
  731. </xsl:when>
  732. <xsl:otherwise>
  733. <xsl:value-of select="concat($theName, 'title')"/>
  734. </xsl:otherwise>
  735. </xsl:choose>
  736. </xsl:template>
  737. <xsl:template match="*[contains(@class,' topic/section ')]/*[contains(@class,' topic/title ')]">
  738. <fo:block xsl:use-attribute-sets="section.title">
  739. <xsl:call-template name="commonattributes"/>
  740. <xsl:apply-templates select="." mode="getTitle"/>
  741. </fo:block>
  742. </xsl:template>
  743. <xsl:template match="*[contains(@class,' topic/example ')]/*[contains(@class,' topic/title ')]">
  744. <fo:block xsl:use-attribute-sets="example.title">
  745. <xsl:call-template name="commonattributes"/>
  746. <xsl:apply-templates/>
  747. </fo:block>
  748. </xsl:template>
  749. <xsl:template match="*[contains(@class,' topic/fig ')]/*[contains(@class,' topic/title ')]">
  750. <fo:block xsl:use-attribute-sets="fig.title">
  751. <xsl:call-template name="commonattributes"/>
  752. <xsl:call-template name="getVariable">
  753. <xsl:with-param name="id" select="'Figure.title'"/>
  754. <xsl:with-param name="params">
  755. <number>
  756. <xsl:apply-templates select="." mode="fig.title-number"/>
  757. </number>
  758. <title>
  759. <xsl:apply-templates/>
  760. </title>
  761. </xsl:with-param>
  762. </xsl:call-template>
  763. </fo:block>
  764. </xsl:template>
  765. <xsl:template match="*[contains(@class,' topic/fig ')]/*[contains(@class,' topic/title ')]" mode="fig.title-number">
  766. <xsl:value-of select="count(key('enumerableByClass', 'topic/fig')[. &lt;&lt; current()])"/>
  767. </xsl:template>
  768. <xsl:template match="*[contains(@class, ' topic/tm ')]">
  769. <fo:inline xsl:use-attribute-sets="tm">
  770. <xsl:apply-templates/>
  771. <xsl:choose>
  772. <xsl:when test="@tmtype='service'">
  773. <fo:inline xsl:use-attribute-sets="tm__content__service">SM</fo:inline>
  774. </xsl:when>
  775. <xsl:when test="@tmtype='tm'">
  776. <fo:inline xsl:use-attribute-sets="tm__content">&#8482;</fo:inline>
  777. </xsl:when>
  778. <xsl:when test="@tmtype='reg'">
  779. <fo:inline xsl:use-attribute-sets="tm__content">&#174;</fo:inline>
  780. </xsl:when>
  781. <xsl:otherwise>
  782. <fo:inline xsl:use-attribute-sets="tm__content"><xsl:text>Error in tm type.</xsl:text></fo:inline>
  783. </xsl:otherwise>
  784. </xsl:choose>
  785. </fo:inline>
  786. </xsl:template>
  787. <xsl:template match="*[contains(@class,' topic/term ')]" name="topic.term">
  788. <xsl:param name="keys" select="@keyref" as="attribute()?"/>
  789. <xsl:param name="contents" as="node()*">
  790. <xsl:variable name="target" select="key('id', substring(@href, 2))"/>
  791. <xsl:choose>
  792. <xsl:when test="not(normalize-space(.)) and $keys and $target/self::*[contains(@class,' topic/topic ')]">
  793. <xsl:apply-templates select="$target/*[contains(@class, ' topic/title ')]/node()"/>
  794. </xsl:when>
  795. <xsl:otherwise>
  796. <xsl:apply-templates/>
  797. </xsl:otherwise>
  798. </xsl:choose>
  799. </xsl:param>
  800. <xsl:variable name="topicref" select="key('map-id', substring(@href, 2))"/>
  801. <xsl:choose>
  802. <xsl:when test="$keys and @href and not($topicref/ancestor-or-self::*[@linking][1]/@linking = ('none', 'sourceonly'))">
  803. <fo:basic-link xsl:use-attribute-sets="xref term">
  804. <xsl:call-template name="commonattributes"/>
  805. <xsl:call-template name="buildBasicLinkDestination"/>
  806. <xsl:copy-of select="$contents"/>
  807. </fo:basic-link>
  808. </xsl:when>
  809. <xsl:otherwise>
  810. <fo:inline xsl:use-attribute-sets="term">
  811. <xsl:call-template name="commonattributes"/>
  812. <xsl:copy-of select="$contents"/>
  813. </fo:inline>
  814. </xsl:otherwise>
  815. </xsl:choose>
  816. </xsl:template>
  817. <xsl:template match="*[contains(@class, ' topic/author ')]">
  818. <!--
  819. <fo:block xsl:use-attribute-sets="author">
  820. <xsl:apply-templates/>
  821. </fo:block>
  822. -->
  823. </xsl:template>
  824. <xsl:template match="*[contains(@class, ' topic/source ')]">
  825. <!--
  826. <fo:block xsl:use-attribute-sets="source">
  827. <xsl:apply-templates/>
  828. </fo:block>
  829. -->
  830. </xsl:template>
  831. <xsl:template match="*[contains(@class, ' topic/publisher ')]">
  832. <!--
  833. <fo:block xsl:use-attribute-sets="publisher">
  834. <xsl:apply-templates/>
  835. </fo:block>
  836. -->
  837. </xsl:template>
  838. <xsl:template match="*[contains(@class, ' topic/copyright ')]">
  839. <!--
  840. <fo:block xsl:use-attribute-sets="copyright">
  841. <xsl:apply-templates/>
  842. </fo:block>
  843. -->
  844. </xsl:template>
  845. <xsl:template match="*[contains(@class, ' topic/copyryear ')]">
  846. <!--
  847. <fo:block xsl:use-attribute-sets="copyryear">
  848. <xsl:apply-templates/>
  849. </fo:block>
  850. -->
  851. </xsl:template>
  852. <xsl:template match="*[contains(@class, ' topic/copyrholder ')]">
  853. <!--
  854. <fo:block xsl:use-attribute-sets="copyrholder">
  855. <xsl:apply-templates/>
  856. </fo:block>
  857. -->
  858. </xsl:template>
  859. <xsl:template match="*[contains(@class, ' topic/critdates ')]">
  860. <!--
  861. <fo:block xsl:use-attribute-sets="critdates">
  862. <xsl:apply-templates/>
  863. </fo:block>
  864. -->
  865. </xsl:template>
  866. <xsl:template match="*[contains(@class, ' topic/created ')]">
  867. <!--
  868. <fo:block xsl:use-attribute-sets="created">
  869. <xsl:apply-templates/>
  870. </fo:block>
  871. -->
  872. </xsl:template>
  873. <xsl:template match="*[contains(@class, ' topic/revised ')]">
  874. <!--
  875. <fo:block xsl:use-attribute-sets="revised">
  876. <xsl:apply-templates/>
  877. </fo:block>
  878. -->
  879. </xsl:template>
  880. <xsl:template match="*[contains(@class, ' topic/permissions ')]">
  881. <!--
  882. <fo:block xsl:use-attribute-sets="permissions">
  883. <xsl:apply-templates/>
  884. </fo:block>
  885. -->
  886. </xsl:template>
  887. <xsl:template match="*[contains(@class, ' topic/category ')]">
  888. <!--
  889. <fo:block xsl:use-attribute-sets="category">
  890. <xsl:apply-templates/>
  891. </fo:block>
  892. -->
  893. </xsl:template>
  894. <xsl:template match="*[contains(@class, ' topic/audience ')]">
  895. <!--
  896. <fo:block xsl:use-attribute-sets="audience">
  897. <xsl:apply-templates/>
  898. </fo:block>
  899. -->
  900. </xsl:template>
  901. <xsl:template match="*[contains(@class, ' topic/keywords ')]">
  902. <!--
  903. <fo:block xsl:use-attribute-sets="keywords">
  904. <xsl:apply-templates/>
  905. </fo:block>
  906. -->
  907. </xsl:template>
  908. <xsl:template match="*[contains(@class, ' topic/prodinfo ')]">
  909. <!--
  910. <fo:block xsl:use-attribute-sets="prodinfo">
  911. <xsl:apply-templates/>
  912. </fo:block>
  913. -->
  914. </xsl:template>
  915. <xsl:template match="*[contains(@class, ' topic/prodname ')]">
  916. <!--
  917. <fo:block xsl:use-attribute-sets="prodname">
  918. <xsl:apply-templates/>
  919. </fo:block>
  920. -->
  921. </xsl:template>
  922. <xsl:template match="*[contains(@class, ' topic/vrmlist ')]">
  923. <!--
  924. <fo:block xsl:use-attribute-sets="vrmlist">
  925. <xsl:apply-templates/>
  926. </fo:block>
  927. -->
  928. </xsl:template>
  929. <xsl:template match="*[contains(@class, ' topic/vrm ')]">
  930. <!--
  931. <fo:block xsl:use-attribute-sets="vrm">
  932. <xsl:apply-templates/>
  933. </fo:block>
  934. -->
  935. </xsl:template>
  936. <xsl:template match="*[contains(@class, ' topic/brand ')]">
  937. <!--
  938. <fo:block xsl:use-attribute-sets="brand">
  939. <xsl:apply-templates/>
  940. </fo:block>
  941. -->
  942. </xsl:template>
  943. <xsl:template match="*[contains(@class, ' topic/series ')]">
  944. <!--
  945. <fo:block xsl:use-attribute-sets="series">
  946. <xsl:apply-templates/>
  947. </fo:block>
  948. -->
  949. </xsl:template>
  950. <xsl:template match="*[contains(@class, ' topic/platform ')]">
  951. <!--
  952. <fo:block xsl:use-attribute-sets="platform">
  953. <xsl:apply-templates/>
  954. </fo:block>
  955. -->
  956. </xsl:template>
  957. <xsl:template match="*[contains(@class, ' topic/prognum ')]">
  958. <!--
  959. <fo:block xsl:use-attribute-sets="prognum">
  960. <xsl:apply-templates/>
  961. </fo:block>
  962. -->
  963. </xsl:template>
  964. <xsl:template match="*[contains(@class, ' topic/featnum ')]">
  965. <!--
  966. <fo:block xsl:use-attribute-sets="featnum">
  967. <xsl:apply-templates/>
  968. </fo:block>
  969. -->
  970. </xsl:template>
  971. <xsl:template match="*[contains(@class, ' topic/component ')]">
  972. <!--
  973. <fo:block xsl:use-attribute-sets="component">
  974. <xsl:apply-templates/>
  975. </fo:block>
  976. -->
  977. </xsl:template>
  978. <xsl:template match="*[contains(@class, ' topic/othermeta ')]">
  979. <!--
  980. <fo:block xsl:use-attribute-sets="othermeta">
  981. <xsl:apply-templates/>
  982. </fo:block>
  983. -->
  984. </xsl:template>
  985. <xsl:template match="*[contains(@class, ' topic/resourceid ')]">
  986. <!--
  987. <fo:block xsl:use-attribute-sets="resourceid">
  988. <xsl:apply-templates/>
  989. </fo:block>
  990. -->
  991. </xsl:template>
  992. <xsl:template match="*[contains(@class, ' concept/concept ')]" mode="processTopic"
  993. name="processConcept">
  994. <fo:block xsl:use-attribute-sets="concept">
  995. <xsl:apply-templates select="." mode="commonTopicProcessing"/>
  996. </fo:block>
  997. </xsl:template>
  998. <!-- Deprecated, retained for backwards compatibility -->
  999. <xsl:template match="*" mode="processConcept">
  1000. <xsl:call-template name="processConcept"/>
  1001. </xsl:template>
  1002. <xsl:template match="*[contains(@class, ' concept/conbody ')]" priority="1">
  1003. <xsl:variable name="level" as="xs:integer">
  1004. <xsl:apply-templates select="." mode="get-topic-level"/>
  1005. </xsl:variable>
  1006. <xsl:choose>
  1007. <xsl:when test="not(node())"/>
  1008. <xsl:when test="$level = 1">
  1009. <fo:block xsl:use-attribute-sets="body__toplevel conbody">
  1010. <xsl:call-template name="commonattributes"/>
  1011. <xsl:apply-templates/>
  1012. </fo:block>
  1013. </xsl:when>
  1014. <xsl:when test="$level = 2">
  1015. <fo:block xsl:use-attribute-sets="body__secondLevel conbody">
  1016. <xsl:call-template name="commonattributes"/>
  1017. <xsl:apply-templates/>
  1018. </fo:block>
  1019. </xsl:when>
  1020. <xsl:otherwise>
  1021. <fo:block xsl:use-attribute-sets="conbody">
  1022. <xsl:call-template name="commonattributes"/>
  1023. <xsl:apply-templates/>
  1024. </fo:block>
  1025. </xsl:otherwise>
  1026. </xsl:choose>
  1027. </xsl:template>
  1028. <!-- Gets navigation title of current topic, used for bookmarks/TOC -->
  1029. <xsl:template name="getNavTitle">
  1030. <xsl:variable name="topicref" select="key('map-id', @id)[1]"/>
  1031. <xsl:choose>
  1032. <xsl:when test="$topicref/@locktitle='yes' and
  1033. $topicref/*[contains(@class, ' map/topicmeta ')]/*[contains(@class, ' topic/navtitle ')]">
  1034. <xsl:apply-templates select="$topicref/*[contains(@class, ' map/topicmeta ')]/*[contains(@class, ' topic/navtitle ')]/node()"/>
  1035. </xsl:when>
  1036. <xsl:when test="$topicref/@locktitle='yes' and
  1037. $topicref/@navtitle">
  1038. <xsl:value-of select="$topicref/@navtitle"/>
  1039. </xsl:when>
  1040. <xsl:otherwise>
  1041. <xsl:apply-templates select="*[contains(@class,' topic/title ')]" mode="getTitle"/>
  1042. </xsl:otherwise>
  1043. </xsl:choose>
  1044. </xsl:template>
  1045. <xsl:template match="*" mode="getTitle">
  1046. <xsl:choose>
  1047. <!-- add keycol here once implemented-->
  1048. <xsl:when test="@spectitle">
  1049. <xsl:value-of select="@spectitle"/>
  1050. </xsl:when>
  1051. <xsl:otherwise>
  1052. <xsl:apply-templates/>
  1053. </xsl:otherwise>
  1054. </xsl:choose>
  1055. </xsl:template>
  1056. <xsl:template match="*[contains(@class,' topic/titlealts ')]">
  1057. <xsl:if test="$DRAFT='yes'">
  1058. <xsl:if test="*">
  1059. <fo:block xsl:use-attribute-sets="titlealts">
  1060. <xsl:call-template name="commonattributes"/>
  1061. <xsl:apply-templates/>
  1062. </fo:block>
  1063. </xsl:if>
  1064. </xsl:if>
  1065. </xsl:template>
  1066. <xsl:template match="*[contains(@class,' topic/navtitle ')]">
  1067. <fo:block xsl:use-attribute-sets="navtitle">
  1068. <xsl:call-template name="commonattributes"/>
  1069. <fo:inline xsl:use-attribute-sets="navtitle__label">
  1070. <xsl:call-template name="getVariable">
  1071. <xsl:with-param name="id" select="'Navigation title'"/>
  1072. </xsl:call-template>
  1073. <xsl:text>: </xsl:text>
  1074. </fo:inline>
  1075. <xsl:apply-templates/>
  1076. </fo:block>
  1077. </xsl:template>
  1078. <!-- Map uses map/searchtitle, topic uses topic/searchtitle. This will likely be changed
  1079. to a single value in DITA 2.0, but for now, recognize both. -->
  1080. <xsl:template match="*[contains(@class,' topic/titlealts ')]/*[contains(@class,' topic/searchtitle ')] |
  1081. *[contains(@class,' topic/titlealts ')]/*[contains(@class,' map/searchtitle ')]">
  1082. <fo:block xsl:use-attribute-sets="searchtitle">
  1083. <xsl:call-template name="commonattributes"/>
  1084. <fo:inline xsl:use-attribute-sets="searchtitle__label">
  1085. <xsl:call-template name="getVariable">
  1086. <xsl:with-param name="id" select="'Search title'"/>
  1087. </xsl:call-template>
  1088. <xsl:text>: </xsl:text>
  1089. </fo:inline>
  1090. <xsl:apply-templates/>
  1091. </fo:block>
  1092. </xsl:template>
  1093. <xsl:template match="*[contains(@class,' topic/abstract ')]">
  1094. <fo:block xsl:use-attribute-sets="abstract">
  1095. <xsl:call-template name="commonattributes"/>
  1096. <xsl:apply-templates/>
  1097. </fo:block>
  1098. </xsl:template>
  1099. <!-- For SF Bug 2879171: modify so that shortdesc is inline when inside
  1100. abstract with only other text or inline markup. -->
  1101. <xsl:template match="*[contains(@class,' topic/shortdesc ')]">
  1102. <xsl:variable name="format-as-block" as="xs:boolean">
  1103. <xsl:choose>
  1104. <xsl:when test="not(parent::*[contains(@class,' topic/abstract ')])">
  1105. <xsl:sequence select="true()"/>
  1106. </xsl:when>
  1107. <xsl:when test="preceding-sibling::*[contains(@class,' topic/p ') or contains(@class,' topic/dl ') or
  1108. contains(@class,' topic/fig ') or contains(@class,' topic/lines ') or
  1109. contains(@class,' topic/lq ') or contains(@class,' topic/note ') or
  1110. contains(@class,' topic/ol ') or contains(@class,' topic/pre ') or
  1111. contains(@class,' topic/simpletable ') or contains(@class,' topic/sl ') or
  1112. contains(@class,' topic/table ') or contains(@class,' topic/ul ')]">
  1113. <xsl:sequence select="true()"/>
  1114. </xsl:when>
  1115. <xsl:when test="following-sibling::*[contains(@class,' topic/p ') or contains(@class,' topic/dl ') or
  1116. contains(@class,' topic/fig ') or contains(@class,' topic/lines ') or
  1117. contains(@class,' topic/lq ') or contains(@class,' topic/note ') or
  1118. contains(@class,' topic/ol ') or contains(@class,' topic/pre ') or
  1119. contains(@class,' topic/simpletable ') or contains(@class,' topic/sl ') or
  1120. contains(@class,' topic/table ') or contains(@class,' topic/ul ')]">
  1121. <xsl:sequence select="true()"/>
  1122. </xsl:when>
  1123. <xsl:otherwise>
  1124. <xsl:sequence select="false()"/>
  1125. </xsl:otherwise>
  1126. </xsl:choose>
  1127. </xsl:variable>
  1128. <xsl:choose>
  1129. <xsl:when test="$format-as-block">
  1130. <xsl:apply-templates select="." mode="format-shortdesc-as-block"/>
  1131. </xsl:when>
  1132. <xsl:otherwise>
  1133. <xsl:apply-templates select="." mode="format-shortdesc-as-inline"/>
  1134. </xsl:otherwise>
  1135. </xsl:choose>
  1136. </xsl:template>
  1137. <xsl:template match="*" mode="format-shortdesc-as-block">
  1138. <!--fo:block xsl:use-attribute-sets="shortdesc" id="{@id}">
  1139. <xsl:apply-templates/>
  1140. </fo:block-->
  1141. <!--compare the length of shortdesc with the got max chars-->
  1142. <fo:block xsl:use-attribute-sets="topic__shortdesc">
  1143. <xsl:call-template name="commonattributes"/>
  1144. <!-- If the shortdesc is sufficiently short, add keep-with-next. -->
  1145. <xsl:if test="string-length(.) lt $maxCharsInShortDesc">
  1146. <!-- Low-strength keep to avoid conflict with keeps on titles. -->
  1147. <xsl:attribute name="keep-with-next.within-page">5</xsl:attribute>
  1148. </xsl:if>
  1149. <xsl:apply-templates/>
  1150. </fo:block>
  1151. </xsl:template>
  1152. <xsl:template match="*" mode="format-shortdesc-as-inline">
  1153. <fo:inline xsl:use-attribute-sets="shortdesc">
  1154. <xsl:call-template name="commonattributes"/>
  1155. <xsl:if test="preceding-sibling::* | preceding-sibling::text()">
  1156. <xsl:text> </xsl:text>
  1157. </xsl:if>
  1158. <xsl:apply-templates/>
  1159. </fo:inline>
  1160. </xsl:template>
  1161. <xsl:template match="*[contains(@class,' map/shortdesc ')]">
  1162. <xsl:apply-templates select="." mode="format-shortdesc-as-block"/>
  1163. </xsl:template>
  1164. <xsl:template match="*[contains(@class, ' topic/topic ')]/*[contains(@class,' topic/shortdesc ')]" priority="1">
  1165. <xsl:variable name="topicType" as="xs:string">
  1166. <xsl:call-template name="determineTopicType"/>
  1167. </xsl:variable>
  1168. <xsl:choose>
  1169. <!-- Disable chapter summary processing when mini TOC is created -->
  1170. <xsl:when test="$topicType = ('topicChapter', 'topicAppendix') and
  1171. $chapterLayout != 'BASIC'"/>
  1172. <!-- Normal processing -->
  1173. <xsl:otherwise>
  1174. <xsl:apply-templates select="." mode="format-shortdesc-as-block"/>
  1175. </xsl:otherwise>
  1176. </xsl:choose>
  1177. </xsl:template>
  1178. <xsl:template name="getMaxCharsForShortdescKeep" as="xs:integer">
  1179. <!-- These values specify the length of a short description that will
  1180. render with keep-with-next set, which should be (approximately) the
  1181. character count in three lines of rendered shortdesc text. If you customize the
  1182. default font, page margins, or shortdesc attribute sets, you may need
  1183. to change these values. -->
  1184. <xsl:choose>
  1185. <xsl:when test="$locale = 'en_US' or $locale = 'fr_FR'">
  1186. <xsl:sequence select="360"/>
  1187. </xsl:when>
  1188. <xsl:when test="$locale = 'ja_JP'">
  1189. <xsl:sequence select="141"/>
  1190. </xsl:when>
  1191. <xsl:when test="$locale = 'zh_CN'">
  1192. <xsl:sequence select="141"/>
  1193. </xsl:when>
  1194. <!-- Other languages require a template override to generate
  1195. keep-with-next
  1196. on shortdesc. Data was not available at the time this code released.
  1197. -->
  1198. <xsl:otherwise>
  1199. <xsl:sequence select="0"/>
  1200. </xsl:otherwise>
  1201. </xsl:choose>
  1202. </xsl:template>
  1203. <!-- this is the fallthrough body for nested topics -->
  1204. <xsl:template match="*[contains(@class,' topic/body ')]">
  1205. <xsl:variable name="level" as="xs:integer">
  1206. <xsl:apply-templates select="." mode="get-topic-level"/>
  1207. </xsl:variable>
  1208. <xsl:choose>
  1209. <xsl:when test="not(node())"/>
  1210. <xsl:when test="$level = 1">
  1211. <fo:block xsl:use-attribute-sets="body__toplevel">
  1212. <xsl:apply-templates/>
  1213. </fo:block>
  1214. </xsl:when>
  1215. <xsl:when test="$level = 2">
  1216. <fo:block xsl:use-attribute-sets="body__secondLevel">
  1217. <xsl:apply-templates/>
  1218. </fo:block>
  1219. </xsl:when>
  1220. <xsl:otherwise>
  1221. <fo:block xsl:use-attribute-sets="body">
  1222. <xsl:apply-templates/>
  1223. </fo:block>
  1224. </xsl:otherwise>
  1225. </xsl:choose>
  1226. </xsl:template>
  1227. <xsl:template match="*[contains(@class,' topic/bodydiv ')]">
  1228. <fo:block>
  1229. <xsl:call-template name="commonattributes"/>
  1230. <xsl:apply-templates/>
  1231. </fo:block>
  1232. </xsl:template>
  1233. <xsl:template match="*[contains(@class,' topic/section ')]
  1234. [@spectitle != '' and not(*[contains(@class, ' topic/title ')])]"
  1235. mode="dita2xslfo:section-heading"
  1236. priority="10">
  1237. <fo:block xsl:use-attribute-sets="section.title">
  1238. <xsl:call-template name="commonattributes"/>
  1239. <xsl:variable name="spectitleValue" as="xs:string" select="string(@spectitle)"/>
  1240. <xsl:variable name="resolvedVariable">
  1241. <xsl:call-template name="getVariable">
  1242. <xsl:with-param name="id" select="$spectitleValue"/>
  1243. </xsl:call-template>
  1244. </xsl:variable>
  1245. <xsl:sequence select="if (not(normalize-space($resolvedVariable)))
  1246. then $spectitleValue
  1247. else $resolvedVariable" />
  1248. </fo:block>
  1249. </xsl:template>
  1250. <xsl:template match="*[contains(@class,' topic/section ')]" mode="dita2xslfo:section-heading">
  1251. <!-- Specialized section elements may override this rule to add
  1252. default headings for a section. By default, titles are processed
  1253. where they exist within the section, so overrides may need to
  1254. check for the existence of a title first. -->
  1255. </xsl:template>
  1256. <xsl:template match="*[contains(@class,' topic/section ')]">
  1257. <fo:block xsl:use-attribute-sets="section">
  1258. <xsl:call-template name="commonattributes"/>
  1259. <xsl:apply-templates select="." mode="dita2xslfo:section-heading"/>
  1260. <xsl:apply-templates/>
  1261. </fo:block>
  1262. </xsl:template>
  1263. <xsl:template match="*[contains(@class,' topic/sectiondiv ')]">
  1264. <fo:block>
  1265. <xsl:call-template name="commonattributes"/>
  1266. <xsl:apply-templates/>
  1267. </fo:block>
  1268. </xsl:template>
  1269. <xsl:template match="*[contains(@class,' topic/example ')]">
  1270. <fo:block xsl:use-attribute-sets="example">
  1271. <xsl:call-template name="commonattributes"/>
  1272. <xsl:apply-templates/>
  1273. </fo:block>
  1274. </xsl:template>
  1275. <xsl:template match="*[contains(@class,' topic/desc ')]">
  1276. <fo:inline xsl:use-attribute-sets="desc">
  1277. <xsl:call-template name="commonattributes"/>
  1278. <xsl:apply-templates/>
  1279. </fo:inline>
  1280. </xsl:template>
  1281. <xsl:template match="*[contains(@class,' topic/prolog ')]"/>
  1282. <!--
  1283. <fo:block xsl:use-attribute-sets="prolog">
  1284. <xsl:apply-templates/>
  1285. </fo:block>
  1286. -->
  1287. <!--xsl:copy-of select="node()"/-->
  1288. <!--xsl:apply-templates select="descendant::opentopic-index:index.entry[not(parent::opentopic-index:index.entry)]"/-->
  1289. <!--/xsl:template-->
  1290. <xsl:template name="pullPrologIndexTerms">
  1291. <!-- index terms and ranges from topic -->
  1292. <xsl:apply-templates select="ancestor-or-self::*[contains(@class, ' topic/topic ')][1]/*[contains(@class, ' topic/prolog ')]
  1293. //opentopic-index:index.entry[not(parent::opentopic-index:index.entry) and not(@end-range = 'true')]"/>
  1294. <!-- index ranges from map -->
  1295. <xsl:variable name="topicref" select="key('map-id', @id)"/>
  1296. <xsl:apply-templates select="$topicref/
  1297. *[contains(@class, ' map/topicmeta ')]/
  1298. *[contains(@class, ' topic/keywords ')]/
  1299. descendant::opentopic-index:index.entry[@start-range = 'true']"/>
  1300. </xsl:template>
  1301. <xsl:template name="pullPrologIndexTerms.end-range">
  1302. <!-- index ranges from topic -->
  1303. <xsl:apply-templates select="ancestor-or-self::*[contains(@class, ' topic/topic ')][1]/
  1304. *[contains(@class, ' topic/prolog ')]/
  1305. descendant::opentopic-index:index.entry[not(parent::opentopic-index:index.entry) and
  1306. @end-range = 'true']"/>
  1307. <!-- index ranges from map -->
  1308. <xsl:variable name="topicref" select="key('map-id', @id)"/>
  1309. <xsl:apply-templates select="$topicref/
  1310. *[contains(@class, ' map/topicmeta ')]/
  1311. *[contains(@class, ' topic/keywords ')]/
  1312. descendant::opentopic-index:index.entry[@end-range = 'true']"/>
  1313. </xsl:template>
  1314. <xsl:template match="*[contains(@class, ' topic/metadata ')]">
  1315. <!--
  1316. <fo:block xsl:use-attribute-sets="metadata">
  1317. <xsl:apply-templates/>
  1318. </fo:block>
  1319. -->
  1320. <xsl:apply-templates select="descendant::opentopic-index:index.entry[not(parent::opentopic-index:index.entry)]"/>
  1321. </xsl:template>
  1322. <xsl:template match="*[contains(@class, ' topic/div ')]">
  1323. <fo:block xsl:use-attribute-sets="div">
  1324. <xsl:call-template name="commonattributes"/>
  1325. <xsl:apply-templates/>
  1326. </fo:block>
  1327. </xsl:template>
  1328. <xsl:template match="*[contains(@class, ' topic/p ')]">
  1329. <fo:block xsl:use-attribute-sets="p">
  1330. <xsl:call-template name="commonattributes"/>
  1331. <xsl:apply-templates/>
  1332. </fo:block>
  1333. </xsl:template>
  1334. <xsl:template match="*" mode="placeNoteContent">
  1335. <fo:block xsl:use-attribute-sets="note">
  1336. <xsl:call-template name="commonattributes"/>
  1337. <fo:inline xsl:use-attribute-sets="note__label">
  1338. <xsl:choose>
  1339. <xsl:when test="@type='note' or not(@type)">
  1340. <fo:inline xsl:use-attribute-sets="note__label__note">
  1341. <xsl:call-template name="getVariable">
  1342. <xsl:with-param name="id" select="'Note'"/>
  1343. </xsl:call-template>
  1344. </fo:inline>
  1345. </xsl:when>
  1346. <xsl:when test="@type='notice'">
  1347. <fo:inline xsl:use-attribute-sets="note__label__notice">
  1348. <xsl:call-template name="getVariable">
  1349. <xsl:with-param name="id" select="'Notice'"/>
  1350. </xsl:call-template>
  1351. </fo:inline>
  1352. </xsl:when>
  1353. <xsl:when test="@type='tip'">
  1354. <fo:inline xsl:use-attribute-sets="note__label__tip">
  1355. <xsl:call-template name="getVariable">
  1356. <xsl:with-param name="id" select="'Tip'"/>
  1357. </xsl:call-template>
  1358. </fo:inline>
  1359. </xsl:when>
  1360. <xsl:when test="@type='fastpath'">
  1361. <fo:inline xsl:use-attribute-sets="note__label__fastpath">
  1362. <xsl:call-template name="getVariable">
  1363. <xsl:with-param name="id" select="'Fastpath'"/>
  1364. </xsl:call-template>
  1365. </fo:inline>
  1366. </xsl:when>
  1367. <xsl:when test="@type='restriction'">
  1368. <fo:inline xsl:use-attribute-sets="note__label__restriction">
  1369. <xsl:call-template name="getVariable">
  1370. <xsl:with-param name="id" select="'Restriction'"/>
  1371. </xsl:call-template>
  1372. </fo:inline>
  1373. </xsl:when>
  1374. <xsl:when test="@type='important'">
  1375. <fo:inline xsl:use-attribute-sets="note__label__important">
  1376. <xsl:call-template name="getVariable">
  1377. <xsl:with-param name="id" select="'Important'"/>
  1378. </xsl:call-template>
  1379. </fo:inline>
  1380. </xsl:when>
  1381. <xsl:when test="@type='remember'">
  1382. <fo:inline xsl:use-attribute-sets="note__label__remember">
  1383. <xsl:call-template name="getVariable">
  1384. <xsl:with-param name="id" select="'Remember'"/>
  1385. </xsl:call-template>
  1386. </fo:inline>
  1387. </xsl:when>
  1388. <xsl:when test="@type='attention'">
  1389. <fo:inline xsl:use-attribute-sets="note__label__attention">
  1390. <xsl:call-template name="getVariable">
  1391. <xsl:with-param name="id" select="'Attention'"/>
  1392. </xsl:call-template>
  1393. </fo:inline>
  1394. </xsl:when>
  1395. <xsl:when test="@type='caution'">
  1396. <fo:inline xsl:use-attribute-sets="note__label__caution">
  1397. <xsl:call-template name="getVariable">
  1398. <xsl:with-param name="id" select="'Caution'"/>
  1399. </xsl:call-template>
  1400. </fo:inline>
  1401. </xsl:when>
  1402. <xsl:when test="@type='danger'">
  1403. <fo:inline xsl:use-attribute-sets="note__label__danger">
  1404. <xsl:call-template name="getVariable">
  1405. <xsl:with-param name="id" select="'Danger'"/>
  1406. </xsl:call-template>
  1407. </fo:inline>
  1408. </xsl:when>
  1409. <xsl:when test="@type='warning'">
  1410. <fo:inline xsl:use-attribute-sets="note__label__danger">
  1411. <xsl:call-template name="getVariable">
  1412. <xsl:with-param name="id" select="'Warning'"/>
  1413. </xsl:call-template>
  1414. </fo:inline>
  1415. </xsl:when>
  1416. <xsl:when test="@type='trouble'">
  1417. <fo:inline xsl:use-attribute-sets="note__label__trouble">
  1418. <xsl:call-template name="getVariable">
  1419. <xsl:with-param name="id" select="'Trouble'"/>
  1420. </xsl:call-template>
  1421. </fo:inline>
  1422. </xsl:when>
  1423. <xsl:when test="@type='other'">
  1424. <fo:inline xsl:use-attribute-sets="note__label__other">
  1425. <xsl:choose>
  1426. <xsl:when test="@othertype">
  1427. <xsl:value-of select="@othertype"/>
  1428. </xsl:when>
  1429. <xsl:otherwise>
  1430. <xsl:text>[</xsl:text>
  1431. <xsl:value-of select="@type"/>
  1432. <xsl:text>]</xsl:text>
  1433. </xsl:otherwise>
  1434. </xsl:choose>
  1435. </fo:inline>
  1436. </xsl:when>
  1437. </xsl:choose>
  1438. <xsl:call-template name="getVariable">
  1439. <xsl:with-param name="id" select="'#note-separator'"/>
  1440. </xsl:call-template>
  1441. </fo:inline>
  1442. <xsl:text> </xsl:text>
  1443. <xsl:apply-templates/>
  1444. </fo:block>
  1445. </xsl:template>
  1446. <xsl:template match="*[contains(@class,' topic/note ')]" mode="setNoteImagePath">
  1447. <xsl:variable name="noteType" as="xs:string">
  1448. <xsl:choose>
  1449. <xsl:when test="@type">
  1450. <xsl:value-of select="@type"/>
  1451. </xsl:when>
  1452. <xsl:otherwise>
  1453. <xsl:value-of select="'note'"/>
  1454. </xsl:otherwise>
  1455. </xsl:choose>
  1456. </xsl:variable>
  1457. <xsl:call-template name="getVariable">
  1458. <xsl:with-param name="id" select="concat($noteType, ' Note Image Path')"/>
  1459. </xsl:call-template>
  1460. </xsl:template>
  1461. <xsl:template match="*[contains(@class,' topic/note ')]">
  1462. <xsl:variable name="noteImagePath">
  1463. <xsl:apply-templates select="." mode="setNoteImagePath"/>
  1464. </xsl:variable>
  1465. <xsl:choose>
  1466. <xsl:when test="not($noteImagePath = '')">
  1467. <fo:table xsl:use-attribute-sets="note__table">
  1468. <fo:table-column xsl:use-attribute-sets="note__image__column"/>
  1469. <fo:table-column xsl:use-attribute-sets="note__text__column"/>
  1470. <fo:table-body>
  1471. <fo:table-row>
  1472. <fo:table-cell xsl:use-attribute-sets="note__image__entry">
  1473. <fo:block>
  1474. <fo:external-graphic src="url('{concat($artworkPrefix, $noteImagePath)}')" xsl:use-attribute-sets="image"/>
  1475. </fo:block>
  1476. </fo:table-cell>
  1477. <fo:table-cell xsl:use-attribute-sets="note__text__entry">
  1478. <xsl:apply-templates select="." mode="placeNoteContent"/>
  1479. </fo:table-cell>
  1480. </fo:table-row>
  1481. </fo:table-body>
  1482. </fo:table>
  1483. </xsl:when>
  1484. <xsl:otherwise>
  1485. <xsl:apply-templates select="." mode="placeNoteContent"/>
  1486. </xsl:otherwise>
  1487. </xsl:choose>
  1488. </xsl:template>
  1489. <xsl:template match="*[contains(@class,' topic/lq ')]">
  1490. <fo:block>
  1491. <xsl:call-template name="commonattributes"/>
  1492. <xsl:choose>
  1493. <xsl:when test="@href or @reftitle">
  1494. <xsl:call-template name="processAttrSetReflection">
  1495. <xsl:with-param name="attrSet" select="'lq'"/>
  1496. <xsl:with-param name="path" select="'../../cfg/fo/attrs/commons-attr.xsl'"/>
  1497. </xsl:call-template>
  1498. </xsl:when>
  1499. <xsl:otherwise>
  1500. <xsl:call-template name="processAttrSetReflection">
  1501. <xsl:with-param name="attrSet" select="'lq_simple'"/>
  1502. <xsl:with-param name="path" select="'../../cfg/fo/attrs/commons-attr.xsl'"/>
  1503. </xsl:call-template>
  1504. </xsl:otherwise>
  1505. </xsl:choose>
  1506. <xsl:apply-templates/>
  1507. </fo:block>
  1508. <xsl:choose>
  1509. <xsl:when test="@href">
  1510. <fo:block xsl:use-attribute-sets="lq_link">
  1511. <fo:basic-link>
  1512. <xsl:call-template name="buildBasicLinkDestination">
  1513. <xsl:with-param name="scope" select="@scope"/>
  1514. <xsl:with-param name="format" select="@format"/>
  1515. <xsl:with-param name="href" select="@href"/>
  1516. </xsl:call-template>
  1517. <xsl:choose>
  1518. <xsl:when test="@reftitle">
  1519. <xsl:value-of select="@reftitle"/>
  1520. </xsl:when>
  1521. <xsl:when test="not(@type = 'external' or @format = 'html')">
  1522. <xsl:apply-templates select="." mode="insertReferenceTitle">
  1523. <xsl:with-param name="href" select="@href"/>
  1524. <xsl:with-param name="titlePrefix" select="''"/>
  1525. </xsl:apply-templates>
  1526. </xsl:when>
  1527. <xsl:otherwise>
  1528. <xsl:value-of select="@href"/>
  1529. </xsl:otherwise>
  1530. </xsl:choose>
  1531. </fo:basic-link>
  1532. </fo:block>
  1533. </xsl:when>
  1534. <xsl:when test="@reftitle">
  1535. <fo:block xsl:use-attribute-sets="lq_title">
  1536. <xsl:value-of select="@reftitle"/>
  1537. </fo:block>
  1538. </xsl:when>
  1539. </xsl:choose>
  1540. </xsl:template>
  1541. <xsl:template match="*[contains(@class,' topic/q ')]">
  1542. <fo:inline xsl:use-attribute-sets="q">
  1543. <xsl:call-template name="commonattributes"/>
  1544. <xsl:call-template name="getVariable">
  1545. <xsl:with-param name="id" select="'#quote-start'"/>
  1546. </xsl:call-template>
  1547. <xsl:apply-templates/>
  1548. <xsl:call-template name="getVariable">
  1549. <xsl:with-param name="id" select="'#quote-end'"/>
  1550. </xsl:call-template>
  1551. </fo:inline>
  1552. </xsl:template>
  1553. <xsl:template match="*[contains(@class,' topic/fig ')]">
  1554. <fo:block xsl:use-attribute-sets="fig">
  1555. <xsl:call-template name="commonattributes"/>
  1556. <xsl:call-template name="setFrame"/>
  1557. <xsl:call-template name="setExpanse"/>
  1558. <xsl:if test="not(@id)">
  1559. <xsl:attribute name="id">
  1560. <xsl:call-template name="get-id"/>
  1561. </xsl:attribute>
  1562. </xsl:if>
  1563. <xsl:apply-templates select="*[not(contains(@class,' topic/title '))]"/>
  1564. <xsl:apply-templates select="*[contains(@class,' topic/title ')]"/>
  1565. </fo:block>
  1566. </xsl:template>
  1567. <xsl:template match="*[contains(@class,' topic/figgroup ')]">
  1568. <fo:block xsl:use-attribute-sets="figgroup">
  1569. <xsl:call-template name="commonattributes"/>
  1570. <xsl:apply-templates/>
  1571. </fo:block>
  1572. </xsl:template>
  1573. <xsl:template match="*[contains(@class,' topic/pre ')]">
  1574. <xsl:call-template name="setSpecTitle"/>
  1575. <fo:block xsl:use-attribute-sets="pre">
  1576. <xsl:call-template name="commonattributes"/>
  1577. <xsl:call-template name="setFrame"/>
  1578. <xsl:call-template name="setScale"/>
  1579. <xsl:call-template name="setExpanse"/>
  1580. <xsl:apply-templates/>
  1581. </fo:block>
  1582. </xsl:template>
  1583. <xsl:template name="setSpecTitle">
  1584. <xsl:if test="@spectitle">
  1585. <fo:block xsl:use-attribute-sets="__spectitle">
  1586. <xsl:value-of select="@spectitle"/>
  1587. </fo:block>
  1588. </xsl:if>
  1589. </xsl:template>
  1590. <xsl:template name="setScale">
  1591. <xsl:if test="@scale">
  1592. <!-- For applications that do not yet take percentages. need to divide by 10 and use "pt" -->
  1593. <xsl:attribute name="font-size">
  1594. <xsl:value-of select="concat(@scale, '%')"/>
  1595. </xsl:attribute>
  1596. </xsl:if>
  1597. </xsl:template>
  1598. <!-- Process the frame attribute -->
  1599. <!-- frame styles (setframe) must be called within a block that defines the content being framed -->
  1600. <xsl:template name="setFrame" as="attribute()*">
  1601. <xsl:variable name="container" as="element()*">
  1602. <xsl:choose>
  1603. <xsl:when test="@frame = 'top'">
  1604. <element xsl:use-attribute-sets="__border__top"/>
  1605. </xsl:when>
  1606. <xsl:when test="@frame = 'bot'">
  1607. <element xsl:use-attribute-sets="__border__bot"/>
  1608. </xsl:when>
  1609. <xsl:when test="@frame = 'topbot'">
  1610. <element xsl:use-attribute-sets="__border__topbot"/>
  1611. </xsl:when>
  1612. <xsl:when test="@frame = 'sides'">
  1613. <element xsl:use-attribute-sets="__border__sides"/>
  1614. </xsl:when>
  1615. <xsl:when test="@frame = 'all'">
  1616. <element xsl:use-attribute-sets="__border__all"/>
  1617. </xsl:when>
  1618. </xsl:choose>
  1619. </xsl:variable>
  1620. <xsl:sequence select="$container/@*"/>
  1621. </xsl:template>
  1622. <xsl:template name="setExpanse" as="attribute()*">
  1623. <xsl:variable name="container" as="element()*">
  1624. <xsl:choose>
  1625. <xsl:when test="@expanse = 'page'">
  1626. <element xsl:use-attribute-sets="__expanse__page"/>
  1627. </xsl:when>
  1628. <xsl:when test="@expanse = 'column'">
  1629. <element xsl:use-attribute-sets="__expanse__column"/>
  1630. </xsl:when>
  1631. <xsl:when test="@expanse = 'spread'">
  1632. <element xsl:use-attribute-sets="__expanse__spread"/>
  1633. </xsl:when>
  1634. <xsl:when test="@expanse = 'column'">
  1635. <element xsl:use-attribute-sets="__expanse__textline"/>
  1636. </xsl:when>
  1637. </xsl:choose>
  1638. </xsl:variable>
  1639. <xsl:sequence select="$container/@*"/>
  1640. </xsl:template>
  1641. <xsl:template match="*[contains(@class,' topic/lines ')]">
  1642. <xsl:call-template name="setSpecTitle"/>
  1643. <fo:block xsl:use-attribute-sets="lines">
  1644. <xsl:call-template name="commonattributes"/>
  1645. <xsl:call-template name="setFrame"/>
  1646. <xsl:call-template name="setScale"/>
  1647. <xsl:call-template name="setExpanse"/>
  1648. <xsl:apply-templates/>
  1649. </fo:block>
  1650. </xsl:template>
  1651. <!-- The text element has no default semantics or formatting -->
  1652. <xsl:template match="*[contains(@class,' topic/text ')]">
  1653. <fo:inline>
  1654. <xsl:call-template name="commonattributes"/>
  1655. <xsl:apply-templates/>
  1656. </fo:inline>
  1657. </xsl:template>
  1658. <xsl:template match="*[contains(@class,' topic/keyword ')]" name="topic.keyword">
  1659. <xsl:param name="keys" select="@keyref" as="attribute()?"/>
  1660. <xsl:param name="contents" as="node()*">
  1661. <xsl:variable name="target" select="key('id', substring(@href, 2))"/>
  1662. <xsl:choose>
  1663. <xsl:when test="not(normalize-space(.)) and $keys and $target/self::*[contains(@class,' topic/topic ')]">
  1664. <xsl:apply-templates select="$target/*[contains(@class, ' topic/title ')]/node()"/>
  1665. </xsl:when>
  1666. <xsl:otherwise>
  1667. <xsl:apply-templates/>
  1668. </xsl:otherwise>
  1669. </xsl:choose>
  1670. </xsl:param>
  1671. <xsl:variable name="topicref" select="key('map-id', substring(@href, 2))"/>
  1672. <xsl:choose>
  1673. <xsl:when test="$keys and @href and not($topicref/ancestor-or-self::*[@linking][1]/@linking = ('none', 'sourceonly'))">
  1674. <fo:basic-link xsl:use-attribute-sets="xref keyword">
  1675. <xsl:call-template name="commonattributes"/>
  1676. <xsl:call-template name="buildBasicLinkDestination"/>
  1677. <xsl:copy-of select="$contents"/>
  1678. </fo:basic-link>
  1679. </xsl:when>
  1680. <xsl:otherwise>
  1681. <fo:inline xsl:use-attribute-sets="keyword">
  1682. <xsl:call-template name="commonattributes"/>
  1683. <xsl:copy-of select="$contents"/>
  1684. </fo:inline>
  1685. </xsl:otherwise>
  1686. </xsl:choose>
  1687. </xsl:template>
  1688. <xsl:template match="*[contains(@class,' topic/ph ')]">
  1689. <fo:inline xsl:use-attribute-sets="ph">
  1690. <xsl:call-template name="commonattributes"/>
  1691. <xsl:apply-templates/>
  1692. </fo:inline>
  1693. </xsl:template>
  1694. <xsl:template match="*[contains(@class,' topic/boolean ')]">
  1695. <fo:inline xsl:use-attribute-sets="boolean">
  1696. <xsl:call-template name="commonattributes"/>
  1697. <xsl:value-of select="name()"/>
  1698. <xsl:text>: </xsl:text>
  1699. <xsl:value-of select="@state"/>
  1700. </fo:inline>
  1701. </xsl:template>
  1702. <xsl:template match="*[contains(@class,' topic/state ')]">
  1703. <fo:inline xsl:use-attribute-sets="state">
  1704. <xsl:call-template name="commonattributes"/>
  1705. <xsl:value-of select="name()"/>
  1706. <xsl:text>: </xsl:text>
  1707. <xsl:value-of select="@name"/>
  1708. <xsl:text>=</xsl:text>
  1709. <xsl:value-of select="@value"/>
  1710. </fo:inline>
  1711. </xsl:template>
  1712. <xsl:template match="*[contains(@class,' topic/image ')]">
  1713. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')]" mode="outofline"/>
  1714. <xsl:choose>
  1715. <xsl:when test="empty(@href)"/>
  1716. <xsl:when test="@placement = 'break'">
  1717. <fo:block xsl:use-attribute-sets="image__block">
  1718. <xsl:call-template name="commonattributes"/>
  1719. <xsl:apply-templates select="." mode="placeImage">
  1720. <xsl:with-param name="imageAlign" select="@align"/>
  1721. <xsl:with-param name="href" select="if (@scope = 'external' or opentopic-func:isAbsolute(@href)) then @href else concat($input.dir.url, @href)"/>
  1722. <xsl:with-param name="height" select="@height"/>
  1723. <xsl:with-param name="width" select="@width"/>
  1724. </xsl:apply-templates>
  1725. </fo:block>
  1726. <xsl:if test="$artLabel='yes'">
  1727. <fo:block>
  1728. <xsl:apply-templates select="." mode="image.artlabel"/>
  1729. </fo:block>
  1730. </xsl:if>
  1731. </xsl:when>
  1732. <xsl:otherwise>
  1733. <fo:inline xsl:use-attribute-sets="image__inline">
  1734. <xsl:call-template name="commonattributes"/>
  1735. <xsl:apply-templates select="." mode="placeImage">
  1736. <xsl:with-param name="imageAlign" select="@align"/>
  1737. <xsl:with-param name="href" select="if (@scope = 'external' or opentopic-func:isAbsolute(@href)) then @href else concat($input.dir.url, @href)"/>
  1738. <xsl:with-param name="height" select="@height"/>
  1739. <xsl:with-param name="width" select="@width"/>
  1740. </xsl:apply-templates>
  1741. </fo:inline>
  1742. <xsl:if test="$artLabel='yes'">
  1743. <xsl:apply-templates select="." mode="image.artlabel"/>
  1744. </xsl:if>
  1745. </xsl:otherwise>
  1746. </xsl:choose>
  1747. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-endprop ')]" mode="outofline"/>
  1748. </xsl:template>
  1749. <xsl:template match="*" mode="image.artlabel">
  1750. <fo:inline xsl:use-attribute-sets="image.artlabel">
  1751. <xsl:text> </xsl:text>
  1752. <xsl:value-of select="@href"/>
  1753. <xsl:text> </xsl:text>
  1754. </fo:inline>
  1755. </xsl:template>
  1756. <!-- Test whether URI is absolute -->
  1757. <xsl:function name="opentopic-func:isAbsolute" as="xs:boolean">
  1758. <xsl:param name="uri" as="xs:anyURI"/>
  1759. <xsl:sequence select="some $prefix in ('/', 'file:') satisfies starts-with($uri, $prefix) or
  1760. contains($uri, '://')"/>
  1761. </xsl:function>
  1762. <xsl:template match="*" mode="placeImage">
  1763. <xsl:param name="imageAlign"/>
  1764. <xsl:param name="href"/>
  1765. <xsl:param name="height" as="xs:string?"/>
  1766. <xsl:param name="width" as="xs:string?"/>
  1767. <!--Using align attribute set according to image @align attribute-->
  1768. <xsl:call-template name="processAttrSetReflection">
  1769. <xsl:with-param name="attrSet" select="concat('__align__', $imageAlign)"/>
  1770. <xsl:with-param name="path" select="'../../cfg/fo/attrs/commons-attr.xsl'"/>
  1771. </xsl:call-template>
  1772. <fo:external-graphic src="url('{$href}')" xsl:use-attribute-sets="image">
  1773. <!--Setting image height if defined-->
  1774. <xsl:if test="$height">
  1775. <xsl:attribute name="content-height">
  1776. <!--The following test was commented out because most people found the behavior
  1777. surprising. It used to force images with a number specified for the dimensions
  1778. *but no units* to act as a measure of pixels, *if* you were printing at 72 DPI.
  1779. Uncomment if you really want it. -->
  1780. <xsl:choose>
  1781. <!--xsl:when test="not(string(number($height)) = 'NaN')">
  1782. <xsl:value-of select="concat($height div 72,'in')"/>
  1783. </xsl:when-->
  1784. <xsl:when test="not(string(number($height)) = 'NaN')">
  1785. <xsl:value-of select="concat($height, 'px')"/>
  1786. </xsl:when>
  1787. <xsl:otherwise>
  1788. <xsl:value-of select="$height"/>
  1789. </xsl:otherwise>
  1790. </xsl:choose>
  1791. </xsl:attribute>
  1792. </xsl:if>
  1793. <!--Setting image width if defined-->
  1794. <xsl:if test="$width">
  1795. <xsl:attribute name="content-width">
  1796. <xsl:choose>
  1797. <!--xsl:when test="not(string(number($width)) = 'NaN')">
  1798. <xsl:value-of select="concat($width div 72,'in')"/>
  1799. </xsl:when-->
  1800. <xsl:when test="not(string(number($width)) = 'NaN')">
  1801. <xsl:value-of select="concat($width, 'px')"/>
  1802. </xsl:when>
  1803. <xsl:otherwise>
  1804. <xsl:value-of select="$width"/>
  1805. </xsl:otherwise>
  1806. </xsl:choose>
  1807. </xsl:attribute>
  1808. </xsl:if>
  1809. <xsl:if test="not($width) and not($height) and @scale">
  1810. <xsl:attribute name="content-width">
  1811. <xsl:value-of select="concat(@scale,'%')"/>
  1812. </xsl:attribute>
  1813. </xsl:if>
  1814. <xsl:if test="@scalefit = 'yes' and not($width) and not($height) and not(@scale)">
  1815. <xsl:attribute name="width">100%</xsl:attribute>
  1816. <xsl:attribute name="height">100%</xsl:attribute>
  1817. <xsl:attribute name="content-width">scale-to-fit</xsl:attribute>
  1818. <xsl:attribute name="content-height">scale-to-fit</xsl:attribute>
  1819. <xsl:attribute name="scaling">uniform</xsl:attribute>
  1820. </xsl:if>
  1821. <xsl:apply-templates select="node() except (text(),
  1822. *[contains(@class, ' topic/alt ') or
  1823. contains(@class, ' topic/longdescref ')])"/>
  1824. </fo:external-graphic>
  1825. </xsl:template>
  1826. <xsl:template match="*[contains(@class,' topic/alt ')]">
  1827. <fo:block xsl:use-attribute-sets="alt">
  1828. </fo:block>
  1829. </xsl:template>
  1830. <xsl:template match="*[contains(@class,' topic/object ')]">
  1831. <fo:inline xsl:use-attribute-sets="object">
  1832. <xsl:call-template name="commonattributes"/>
  1833. </fo:inline>
  1834. </xsl:template>
  1835. <xsl:template match="*[contains(@class,' topic/param ')]">
  1836. <fo:inline xsl:use-attribute-sets="param">
  1837. <xsl:call-template name="commonattributes"/>
  1838. </fo:inline>
  1839. </xsl:template>
  1840. <xsl:template match="*[contains(@class,' topic/foreign ')]"/>
  1841. <xsl:template match="*[contains(@class,' topic/unknown ')]"/>
  1842. <xsl:template match="*[contains(@class,' topic/draft-comment ')]">
  1843. <xsl:if test="$publishRequiredCleanup = 'yes' or $DRAFT='yes'">
  1844. <fo:block xsl:use-attribute-sets="draft-comment">
  1845. <xsl:call-template name="commonattributes"/>
  1846. <fo:block xsl:use-attribute-sets="draft-comment__label">
  1847. <xsl:text>Disposition: </xsl:text>
  1848. <xsl:value-of select="@disposition"/>
  1849. <xsl:text> / </xsl:text>
  1850. <xsl:text>Status: </xsl:text>
  1851. <xsl:value-of select="@status"/>
  1852. </fo:block>
  1853. <xsl:apply-templates/>
  1854. </fo:block>
  1855. </xsl:if>
  1856. </xsl:template>
  1857. <xsl:template match="*[contains(@class,' topic/required-cleanup ')]">
  1858. <xsl:if test="$publishRequiredCleanup = 'yes' or $DRAFT='yes'">
  1859. <fo:inline xsl:use-attribute-sets="required-cleanup">
  1860. <xsl:call-template name="commonattributes"/>
  1861. <fo:inline xsl:use-attribute-sets="required-cleanup__label">
  1862. <xsl:call-template name="getVariable">
  1863. <xsl:with-param name="id" select="'Required-Cleanup'"/>
  1864. </xsl:call-template>
  1865. <xsl:if test="string(@remap)">
  1866. <xsl:text>(</xsl:text>
  1867. <xsl:value-of select="@remap"/>
  1868. <xsl:text>)</xsl:text>
  1869. </xsl:if>
  1870. <xsl:text>: </xsl:text>
  1871. </fo:inline>
  1872. <xsl:apply-templates/>
  1873. </fo:inline>
  1874. </xsl:if>
  1875. </xsl:template>
  1876. <xsl:function name="dita-ot:getFootnoteInternalID" as="xs:string">
  1877. <xsl:param name="ctx" as="element()"/>
  1878. <xsl:sequence select="concat('fn',generate-id($ctx))"/>
  1879. </xsl:function>
  1880. <xsl:template match="*[contains(@class,' topic/fn ')]">
  1881. <!--<fo:inline>
  1882. <xsl:call-template name="commonattributes"/>
  1883. </fo:inline>-->
  1884. <xsl:variable name="id" select="dita-ot:getFootnoteInternalID(.)" as="xs:string"/>
  1885. <xsl:variable name="callout" as="xs:string">
  1886. <xsl:apply-templates select="." mode="callout"/>
  1887. </xsl:variable>
  1888. <fo:footnote>
  1889. <xsl:choose>
  1890. <xsl:when test="not(@id)">
  1891. <fo:inline xsl:use-attribute-sets="fn__callout">
  1892. <fo:basic-link internal-destination="{$id}">
  1893. <xsl:copy-of select="$callout"/>
  1894. </fo:basic-link>
  1895. </fo:inline>
  1896. </xsl:when>
  1897. <xsl:otherwise>
  1898. <!-- Footnote with id does not generate its own callout. -->
  1899. <fo:inline/>
  1900. </xsl:otherwise>
  1901. </xsl:choose>
  1902. <fo:footnote-body>
  1903. <fo:list-block xsl:use-attribute-sets="fn__body">
  1904. <fo:list-item>
  1905. <fo:list-item-label end-indent="label-end()">
  1906. <fo:block text-align="right" id="{$id}">
  1907. <fo:inline xsl:use-attribute-sets="fn__callout">
  1908. <xsl:copy-of select="$callout"/>
  1909. </fo:inline>
  1910. </fo:block>
  1911. </fo:list-item-label>
  1912. <fo:list-item-body start-indent="body-start()">
  1913. <fo:block>
  1914. <xsl:apply-templates/>
  1915. </fo:block>
  1916. </fo:list-item-body>
  1917. </fo:list-item>
  1918. </fo:list-block>
  1919. </fo:footnote-body>
  1920. </fo:footnote>
  1921. </xsl:template>
  1922. <xsl:template match="*[contains(@class,' topic/fn ')]" mode="callout">
  1923. <xsl:choose>
  1924. <xsl:when test="@callout">
  1925. <xsl:value-of select="@callout"/>
  1926. </xsl:when>
  1927. <xsl:otherwise>
  1928. <xsl:value-of select="count(key('enumerableByClass', 'topic/fn')[. &lt;&lt; current()]) + 1"/>
  1929. </xsl:otherwise>
  1930. </xsl:choose>
  1931. </xsl:template>
  1932. <xsl:template match="*[contains(@class,' topic/indexterm ')]">
  1933. <fo:inline>
  1934. <xsl:call-template name="commonattributes"/>
  1935. </fo:inline>
  1936. <xsl:apply-templates/>
  1937. </xsl:template>
  1938. <xsl:template match="*[contains(@class,' topic/indextermref ')]">
  1939. <fo:inline xsl:use-attribute-sets="indextermref">
  1940. <xsl:call-template name="commonattributes"/>
  1941. <xsl:apply-templates/>
  1942. </fo:inline>
  1943. </xsl:template>
  1944. <xsl:template match="*[contains(@class,' topic/cite ')]">
  1945. <fo:inline xsl:use-attribute-sets="cite">
  1946. <xsl:call-template name="commonattributes"/>
  1947. <xsl:apply-templates/>
  1948. </fo:inline>
  1949. </xsl:template>
  1950. <xsl:template match="@platform | @product | @audience | @otherprops | @importance | @rev | @status"/>
  1951. <!-- Template to copy original IDs -->
  1952. <xsl:template match="@id">
  1953. <xsl:attribute name="id">
  1954. <xsl:value-of select="."/>
  1955. </xsl:attribute>
  1956. </xsl:template>
  1957. <!-- Process common attributes -->
  1958. <xsl:template name="commonattributes">
  1959. <xsl:apply-templates select="@id"/>
  1960. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')] |
  1961. *[contains(@class,' ditaot-d/ditaval-endprop ')]" mode="flag-attributes"/>
  1962. </xsl:template>
  1963. <!-- Get ID for an element, generate ID if not explicitly set. -->
  1964. <xsl:template name="get-id">
  1965. <xsl:param name="element" select="."/>
  1966. <xsl:choose>
  1967. <xsl:when test="$element/@id">
  1968. <xsl:value-of select="$element/@id"/>
  1969. </xsl:when>
  1970. <xsl:otherwise>
  1971. <xsl:value-of select="generate-id($element)"/>
  1972. </xsl:otherwise>
  1973. </xsl:choose>
  1974. </xsl:template>
  1975. <!-- Generate TOC ID -->
  1976. <xsl:template name="generate-toc-id">
  1977. <xsl:param name="element" select="."/>
  1978. <xsl:value-of select="concat('_OPENTOPIC_TOC_PROCESSING_', generate-id($element))"/>
  1979. </xsl:template>
  1980. <!-- BS: Template owerwrited to define new topic types (List's),
  1981. to create special processing for any of list you should use <template name="processUnknowTopic"/>
  1982. example below.-->
  1983. <xsl:template name="determineTopicType">
  1984. <xsl:variable name="foundTopicType" as="xs:string?">
  1985. <xsl:variable name="topic" select="ancestor-or-self::*[contains(@class, ' topic/topic ')][1]"/>
  1986. <xsl:variable name="id" select="$topic/@id"/>
  1987. <xsl:variable name="mapTopics" select="key('map-id', $id)"/>
  1988. <xsl:apply-templates select="$mapTopics[1]" mode="determineTopicType"/>
  1989. </xsl:variable>
  1990. <xsl:choose>
  1991. <xsl:when test="exists($foundTopicType) and $foundTopicType != ''">
  1992. <xsl:value-of select="$foundTopicType"/>
  1993. </xsl:when>
  1994. <xsl:otherwise>topicSimple</xsl:otherwise>
  1995. </xsl:choose>
  1996. </xsl:template>
  1997. <xsl:template match="*" mode="determineTopicType">
  1998. <!-- Default, when not matching a bookmap type, is topicSimple -->
  1999. <xsl:text>topicSimple</xsl:text>
  2000. </xsl:template>
  2001. <xsl:template match="*[contains(@class, ' bookmap/chapter ')]" mode="determineTopicType">
  2002. <xsl:text>topicChapter</xsl:text>
  2003. </xsl:template>
  2004. <xsl:template match="*[contains(@class, ' bookmap/appendix ')]" mode="determineTopicType">
  2005. <xsl:text>topicAppendix</xsl:text>
  2006. </xsl:template>
  2007. <xsl:template match="*[contains(@class, ' bookmap/preface ')]" mode="determineTopicType">
  2008. <xsl:text>topicPreface</xsl:text>
  2009. </xsl:template>
  2010. <xsl:template match="*[contains(@class, ' bookmap/appendices ')]" mode="determineTopicType">
  2011. <xsl:text>topicAppendices</xsl:text>
  2012. </xsl:template>
  2013. <xsl:template match="*[contains(@class, ' bookmap/part ')]" mode="determineTopicType">
  2014. <xsl:text>topicPart</xsl:text>
  2015. </xsl:template>
  2016. <xsl:template match="*[contains(@class, ' bookmap/abbrevlist ')]" mode="determineTopicType">
  2017. <xsl:text>topicAbbrevList</xsl:text>
  2018. </xsl:template>
  2019. <xsl:template match="*[contains(@class, ' bookmap/bibliolist ')]" mode="determineTopicType">
  2020. <xsl:text>topicBiblioList</xsl:text>
  2021. </xsl:template>
  2022. <xsl:template match="*[contains(@class, ' bookmap/booklist ')]" mode="determineTopicType">
  2023. <xsl:text>topicBookList</xsl:text>
  2024. </xsl:template>
  2025. <xsl:template match="*[contains(@class, ' bookmap/figurelist ')]" mode="determineTopicType">
  2026. <xsl:text>topicFigureList</xsl:text>
  2027. </xsl:template>
  2028. <xsl:template match="*[contains(@class, ' bookmap/indexlist ')]" mode="determineTopicType">
  2029. <xsl:text>topicIndexList</xsl:text>
  2030. </xsl:template>
  2031. <xsl:template match="*[contains(@class, ' bookmap/toc ')]" mode="determineTopicType">
  2032. <xsl:text>topicTocList</xsl:text>
  2033. </xsl:template>
  2034. <xsl:template match="*[contains(@class, ' bookmap/glossarylist ')]" mode="determineTopicType">
  2035. <xsl:text>topicGlossaryList</xsl:text>
  2036. </xsl:template>
  2037. <xsl:template match="*[contains(@class, ' bookmap/trademarklist ')]" mode="determineTopicType">
  2038. <xsl:text>topicTradeMarkList</xsl:text>
  2039. </xsl:template>
  2040. <xsl:template match="*[contains(@class, ' bookmap/notices ')]" mode="determineTopicType">
  2041. <xsl:text>topicNotices</xsl:text>
  2042. </xsl:template>
  2043. <xsl:template match="*[contains(@class,' bookmap/frontmatter ')]/* |
  2044. *[contains(@class,' bookmap/booklists ')]/*" mode="determineTopicType" priority="10">
  2045. <!-- Catch topics in front matter that do not have another match.
  2046. Changing priorities for the default rule or (e.g) preface can break customizations;
  2047. the high priority + variable fallback will support old and new without breaking customizations. -->
  2048. <xsl:variable name="fallback" as="xs:string"><xsl:next-match/></xsl:variable>
  2049. <xsl:value-of select="if ($fallback = 'topicSimple') then 'topicFrontMatter' else $fallback"/>
  2050. </xsl:template>
  2051. <xsl:template match="*[contains(@class, ' topic/data ')]"/>
  2052. <xsl:template match="*[contains(@class, ' topic/data ')]" mode="insert-text"/>
  2053. <xsl:template match="*[contains(@class, ' topic/data-about ')]"/>
  2054. <xsl:function name="opentopic-func:determineTopicType" as="xs:string">
  2055. <xsl:variable name="topicType" as="xs:string">
  2056. <xsl:call-template name="determineTopicType"/>
  2057. </xsl:variable>
  2058. <xsl:sequence select="$topicType"/>
  2059. </xsl:function>
  2060. </xsl:stylesheet>