topic.xsl 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547
  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 file for applicable license.
  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:template match="*[contains(@class, ' topic/topic ')]">
  40. <xsl:apply-templates select="." mode="processTopic"/>
  41. </xsl:template>
  42. <xsl:template match="*" mode="processTopic">
  43. <fo:block xsl:use-attribute-sets="topic">
  44. <xsl:apply-templates select="." mode="commonTopicProcessing"/>
  45. </fo:block>
  46. </xsl:template>
  47. <xsl:template match="*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/title ')]">
  48. <xsl:variable name="topicType" as="xs:string">
  49. <xsl:call-template name="determineTopicType"/>
  50. </xsl:variable>
  51. <xsl:choose>
  52. <!-- Disable chapter title processing when mini TOC is created -->
  53. <xsl:when test="(topicType = 'topicChapter') or (topicType = 'topicAppendix')" />
  54. <!-- Normal processing -->
  55. <xsl:otherwise>
  56. <xsl:apply-templates select="." mode="processTopicTitle"/>
  57. </xsl:otherwise>
  58. </xsl:choose>
  59. </xsl:template>
  60. <xsl:template match="*" mode="processTopicTitle">
  61. <xsl:variable name="level" as="xs:integer">
  62. <xsl:apply-templates select="." mode="get-topic-level"/>
  63. </xsl:variable>
  64. <xsl:variable name="attrSet1">
  65. <xsl:apply-templates select="." mode="createTopicAttrsName">
  66. <xsl:with-param name="theCounter" select="$level"/>
  67. </xsl:apply-templates>
  68. </xsl:variable>
  69. <xsl:variable name="attrSet2" select="concat($attrSet1, '__content')"/>
  70. <fo:block>
  71. <xsl:call-template name="commonattributes"/>
  72. <xsl:call-template name="processAttrSetReflection">
  73. <xsl:with-param name="attrSet" select="$attrSet1"/>
  74. <xsl:with-param name="path" select="'../../cfg/fo/attrs/commons-attr.xsl'"/>
  75. </xsl:call-template>
  76. <fo:block>
  77. <xsl:call-template name="processAttrSetReflection">
  78. <xsl:with-param name="attrSet" select="$attrSet2"/>
  79. <xsl:with-param name="path" select="'../../cfg/fo/attrs/commons-attr.xsl'"/>
  80. </xsl:call-template>
  81. <xsl:if test="$level = 1">
  82. <xsl:apply-templates select="." mode="insertTopicHeaderMarker"/>
  83. </xsl:if>
  84. <xsl:if test="$level = 2">
  85. <xsl:apply-templates select="." mode="insertTopicHeaderMarker">
  86. <xsl:with-param name="marker-class-name" as="xs:string">current-h2</xsl:with-param>
  87. </xsl:apply-templates>
  88. </xsl:if>
  89. <fo:wrapper id="{parent::node()/@id}"/>
  90. <fo:wrapper>
  91. <xsl:attribute name="id">
  92. <xsl:call-template name="generate-toc-id">
  93. <xsl:with-param name="element" select=".."/>
  94. </xsl:call-template>
  95. </xsl:attribute>
  96. </fo:wrapper>
  97. <xsl:apply-templates select="." mode="customTopicAnchor"/>
  98. <xsl:call-template name="pullPrologIndexTerms"/>
  99. <xsl:apply-templates select="preceding-sibling::*[contains(@class,' ditaot-d/ditaval-startprop ')]"/>
  100. <xsl:apply-templates select="." mode="getTitle"/>
  101. </fo:block>
  102. </fo:block>
  103. </xsl:template>
  104. <xsl:template match="*" mode="get-topic-level" as="xs:integer">
  105. <xsl:variable name="topicref"
  106. select="key('map-id', ancestor-or-self::*[contains(@class,' topic/topic ')][1]/@id)[1]"
  107. as="element()?"
  108. />
  109. <xsl:sequence select="count(ancestor-or-self::*[contains(@class,' topic/topic ')]) -
  110. count($topicref/ancestor-or-self::*[(contains(@class,' bookmap/part ') and
  111. ((exists(@navtitle) or
  112. *[contains(@class,' map/topicmeta ')]/*[contains(@class,' topic/navtitle ')]) or
  113. (exists(@href) and
  114. (empty(@format) or @format eq 'dita') and
  115. (empty(@scope) or @scope eq 'local')))) or
  116. (contains(@class,' bookmap/appendices ') and
  117. exists(@href) and
  118. (empty(@format) or @format eq 'dita') and
  119. (empty(@scope) or @scope eq 'local'))])"/>
  120. </xsl:template>
  121. <xsl:template match="*" mode="createTopicAttrsName">
  122. <xsl:param name="theCounter" as="xs:integer"/>
  123. <xsl:param name="theName" select="''" as="xs:string"/>
  124. <xsl:choose>
  125. <xsl:when test="$theCounter > 0">
  126. <xsl:apply-templates select="." mode="createTopicAttrsName">
  127. <xsl:with-param name="theCounter" select="$theCounter - 1"/>
  128. <xsl:with-param name="theName" select="concat($theName, 'topic.')"/>
  129. </xsl:apply-templates>
  130. </xsl:when>
  131. <xsl:otherwise>
  132. <xsl:value-of select="concat($theName, 'title')"/>
  133. </xsl:otherwise>
  134. </xsl:choose>
  135. </xsl:template>
  136. <!-- Hook that allows adding anchors to titled non topic elements. -->
  137. <xsl:template match="*[contains(@class,' topic/title ')]" mode="customTitleAnchor"/>
  138. <xsl:template match="*[contains(@class,' topic/section ')]/*[contains(@class,' topic/title ')]">
  139. <fo:block xsl:use-attribute-sets="section.title">
  140. <xsl:call-template name="commonattributes"/>
  141. <xsl:apply-templates select="." mode="customTitleAnchor"/>
  142. <xsl:apply-templates select="." mode="getTitle"/>
  143. </fo:block>
  144. </xsl:template>
  145. <xsl:template match="*[contains(@class,' topic/example ')]/*[contains(@class,' topic/title ')]">
  146. <fo:block xsl:use-attribute-sets="example.title">
  147. <xsl:call-template name="commonattributes"/>
  148. <xsl:apply-templates select="." mode="customTitleAnchor"/>
  149. <xsl:apply-templates/>
  150. </fo:block>
  151. </xsl:template>
  152. <xsl:template match="*[contains(@class,' topic/fig ')]/*[contains(@class,' topic/title ')]">
  153. <fo:block xsl:use-attribute-sets="fig.title">
  154. <xsl:call-template name="commonattributes"/>
  155. <xsl:apply-templates select="." mode="customTitleAnchor"/>
  156. <xsl:call-template name="getVariable">
  157. <xsl:with-param name="id" select="'Figure.title'"/>
  158. <xsl:with-param name="params">
  159. <number>
  160. <xsl:apply-templates select="." mode="fig.title-number"/>
  161. </number>
  162. <title>
  163. <xsl:apply-templates/>
  164. </title>
  165. </xsl:with-param>
  166. </xsl:call-template>
  167. </fo:block>
  168. </xsl:template>
  169. <xsl:template match="*[contains(@class,' topic/fig ')]/*[contains(@class,' topic/title ')]" mode="fig.title-number">
  170. <xsl:value-of select="count(key('enumerableByClass', 'topic/fig')[. &lt;&lt; current()][dita-ot:notExcludedByDraftElement(.)])"/>
  171. </xsl:template>
  172. <xsl:template match="*[contains(@class, ' topic/tm ')]">
  173. <xsl:variable name="generate-symbol" as="xs:boolean">
  174. <xsl:apply-templates select="." mode="tm-scope"/>
  175. </xsl:variable>
  176. <fo:inline xsl:use-attribute-sets="tm">
  177. <xsl:call-template name="commonattributes"/>
  178. <xsl:apply-templates/>
  179. <xsl:choose>
  180. <xsl:when test="not($generate-symbol)"/>
  181. <xsl:when test="@tmtype='service'">
  182. <fo:inline xsl:use-attribute-sets="tm__content__service">&#8480;</fo:inline>
  183. </xsl:when>
  184. <xsl:when test="@tmtype='tm'">
  185. <fo:inline xsl:use-attribute-sets="tm__content">&#8482;</fo:inline>
  186. </xsl:when>
  187. <xsl:when test="@tmtype='reg'">
  188. <fo:inline xsl:use-attribute-sets="tm__content">&#174;</fo:inline>
  189. </xsl:when>
  190. </xsl:choose>
  191. </fo:inline>
  192. </xsl:template>
  193. <xsl:template match="node() | @*" mode="tm-scope" as="xs:boolean" priority="-10">
  194. <xsl:sequence select="true()"/>
  195. </xsl:template>
  196. <xsl:template match="*[contains(@class,' topic/term ')]" name="topic.term">
  197. <xsl:param name="keys" select="@keyref" as="attribute()?"/>
  198. <xsl:param name="contents" as="node()*">
  199. <!-- Current node can be preprocessed and may not be part of source document, check for root() to ensure key() is resolvable -->
  200. <xsl:variable name="target" select="if (exists(root()) and @href) then key('id', substring(@href, 2))[1] else ()" as="element()?"/>
  201. <xsl:choose>
  202. <xsl:when test="not(normalize-space(.)) and $keys and $target/self::*[contains(@class,' topic/topic ')]">
  203. <xsl:apply-templates select="$target/*[contains(@class, ' topic/title ')]/node()"/>
  204. </xsl:when>
  205. <xsl:otherwise>
  206. <xsl:apply-templates/>
  207. </xsl:otherwise>
  208. </xsl:choose>
  209. </xsl:param>
  210. <xsl:variable name="topicref" select="key('map-id', substring(@href, 2))[1]" as="element()?"/>
  211. <xsl:choose>
  212. <xsl:when test="$keys and @href and not($topicref/ancestor-or-self::*[@linking][1]/@linking = ('none', 'sourceonly'))">
  213. <fo:basic-link xsl:use-attribute-sets="xref term">
  214. <xsl:call-template name="commonattributes"/>
  215. <xsl:call-template name="buildBasicLinkDestination"/>
  216. <xsl:copy-of select="$contents"/>
  217. </fo:basic-link>
  218. </xsl:when>
  219. <xsl:otherwise>
  220. <fo:inline xsl:use-attribute-sets="term">
  221. <xsl:call-template name="commonattributes"/>
  222. <xsl:copy-of select="$contents"/>
  223. </fo:inline>
  224. </xsl:otherwise>
  225. </xsl:choose>
  226. </xsl:template>
  227. <xsl:template match="*[contains(@class, ' topic/author ')]">
  228. <!--
  229. <fo:block xsl:use-attribute-sets="author">
  230. <xsl:apply-templates/>
  231. </fo:block>
  232. -->
  233. </xsl:template>
  234. <xsl:template match="*[contains(@class, ' topic/source ')]">
  235. <!--
  236. <fo:block xsl:use-attribute-sets="source">
  237. <xsl:apply-templates/>
  238. </fo:block>
  239. -->
  240. </xsl:template>
  241. <xsl:template match="*[contains(@class, ' topic/publisher ')]">
  242. <!--
  243. <fo:block xsl:use-attribute-sets="publisher">
  244. <xsl:apply-templates/>
  245. </fo:block>
  246. -->
  247. </xsl:template>
  248. <xsl:template match="*[contains(@class, ' topic/copyright ')]">
  249. <!--
  250. <fo:block xsl:use-attribute-sets="copyright">
  251. <xsl:apply-templates/>
  252. </fo:block>
  253. -->
  254. </xsl:template>
  255. <xsl:template match="*[contains(@class, ' topic/copyryear ')]">
  256. <!--
  257. <fo:block xsl:use-attribute-sets="copyryear">
  258. <xsl:apply-templates/>
  259. </fo:block>
  260. -->
  261. </xsl:template>
  262. <xsl:template match="*[contains(@class, ' topic/copyrholder ')]">
  263. <!--
  264. <fo:block xsl:use-attribute-sets="copyrholder">
  265. <xsl:apply-templates/>
  266. </fo:block>
  267. -->
  268. </xsl:template>
  269. <xsl:template match="*[contains(@class, ' topic/critdates ')]">
  270. <!--
  271. <fo:block xsl:use-attribute-sets="critdates">
  272. <xsl:apply-templates/>
  273. </fo:block>
  274. -->
  275. </xsl:template>
  276. <xsl:template match="*[contains(@class, ' topic/created ')]">
  277. <!--
  278. <fo:block xsl:use-attribute-sets="created">
  279. <xsl:apply-templates/>
  280. </fo:block>
  281. -->
  282. </xsl:template>
  283. <xsl:template match="*[contains(@class, ' topic/revised ')]">
  284. <!--
  285. <fo:block xsl:use-attribute-sets="revised">
  286. <xsl:apply-templates/>
  287. </fo:block>
  288. -->
  289. </xsl:template>
  290. <xsl:template match="*[contains(@class, ' topic/permissions ')]">
  291. <!--
  292. <fo:block xsl:use-attribute-sets="permissions">
  293. <xsl:apply-templates/>
  294. </fo:block>
  295. -->
  296. </xsl:template>
  297. <xsl:template match="*[contains(@class, ' topic/category ')]">
  298. <!--
  299. <fo:block xsl:use-attribute-sets="category">
  300. <xsl:apply-templates/>
  301. </fo:block>
  302. -->
  303. </xsl:template>
  304. <xsl:template match="*[contains(@class, ' topic/audience ')]">
  305. <!--
  306. <fo:block xsl:use-attribute-sets="audience">
  307. <xsl:apply-templates/>
  308. </fo:block>
  309. -->
  310. </xsl:template>
  311. <xsl:template match="*[contains(@class, ' topic/keywords ')]">
  312. <!--
  313. <fo:block xsl:use-attribute-sets="keywords">
  314. <xsl:apply-templates/>
  315. </fo:block>
  316. -->
  317. </xsl:template>
  318. <xsl:template match="*[contains(@class, ' topic/prodinfo ')]">
  319. <!--
  320. <fo:block xsl:use-attribute-sets="prodinfo">
  321. <xsl:apply-templates/>
  322. </fo:block>
  323. -->
  324. </xsl:template>
  325. <xsl:template match="*[contains(@class, ' topic/prodname ')]">
  326. <!--
  327. <fo:block xsl:use-attribute-sets="prodname">
  328. <xsl:apply-templates/>
  329. </fo:block>
  330. -->
  331. </xsl:template>
  332. <xsl:template match="*[contains(@class, ' topic/vrmlist ')]">
  333. <!--
  334. <fo:block xsl:use-attribute-sets="vrmlist">
  335. <xsl:apply-templates/>
  336. </fo:block>
  337. -->
  338. </xsl:template>
  339. <xsl:template match="*[contains(@class, ' topic/vrm ')]">
  340. <!--
  341. <fo:block xsl:use-attribute-sets="vrm">
  342. <xsl:apply-templates/>
  343. </fo:block>
  344. -->
  345. </xsl:template>
  346. <xsl:template match="*[contains(@class, ' topic/brand ')]">
  347. <!--
  348. <fo:block xsl:use-attribute-sets="brand">
  349. <xsl:apply-templates/>
  350. </fo:block>
  351. -->
  352. </xsl:template>
  353. <xsl:template match="*[contains(@class, ' topic/series ')]">
  354. <!--
  355. <fo:block xsl:use-attribute-sets="series">
  356. <xsl:apply-templates/>
  357. </fo:block>
  358. -->
  359. </xsl:template>
  360. <xsl:template match="*[contains(@class, ' topic/platform ')]">
  361. <!--
  362. <fo:block xsl:use-attribute-sets="platform">
  363. <xsl:apply-templates/>
  364. </fo:block>
  365. -->
  366. </xsl:template>
  367. <xsl:template match="*[contains(@class, ' topic/prognum ')]">
  368. <!--
  369. <fo:block xsl:use-attribute-sets="prognum">
  370. <xsl:apply-templates/>
  371. </fo:block>
  372. -->
  373. </xsl:template>
  374. <xsl:template match="*[contains(@class, ' topic/featnum ')]">
  375. <!--
  376. <fo:block xsl:use-attribute-sets="featnum">
  377. <xsl:apply-templates/>
  378. </fo:block>
  379. -->
  380. </xsl:template>
  381. <xsl:template match="*[contains(@class, ' topic/component ')]">
  382. <!--
  383. <fo:block xsl:use-attribute-sets="component">
  384. <xsl:apply-templates/>
  385. </fo:block>
  386. -->
  387. </xsl:template>
  388. <xsl:template match="*[contains(@class, ' topic/othermeta ')]">
  389. <!--
  390. <fo:block xsl:use-attribute-sets="othermeta">
  391. <xsl:apply-templates/>
  392. </fo:block>
  393. -->
  394. </xsl:template>
  395. <xsl:template match="*[contains(@class, ' topic/resourceid ')]">
  396. <!--
  397. <fo:block xsl:use-attribute-sets="resourceid">
  398. <xsl:apply-templates/>
  399. </fo:block>
  400. -->
  401. </xsl:template>
  402. <!-- Gets navigation title of current topic, used for bookmarks/TOC -->
  403. <xsl:template name="getNavTitle">
  404. <xsl:variable name="topicref" select="key('map-id', @id)[1]" as="element()?"/>
  405. <xsl:choose>
  406. <xsl:when test="$topicref/@locktitle='yes' and
  407. $topicref/*[contains(@class, ' map/topicmeta ')]/*[contains(@class, ' topic/navtitle ')]">
  408. <xsl:apply-templates select="$topicref/*[contains(@class, ' map/topicmeta ')]/*[contains(@class, ' topic/navtitle ')]/node()"/>
  409. </xsl:when>
  410. <xsl:when test="$topicref/@locktitle='yes' and
  411. $topicref/@navtitle">
  412. <xsl:value-of select="$topicref/@navtitle"/>
  413. </xsl:when>
  414. <xsl:when test="*[contains(@class,' topic/titlealts ')]/*[contains(@class,' topic/navtitle ')]">
  415. <xsl:apply-templates select="*[contains(@class,' topic/titlealts ')]/*[contains(@class,' topic/navtitle ')]/node()"/>
  416. </xsl:when>
  417. <xsl:otherwise>
  418. <xsl:apply-templates select="*[contains(@class,' topic/title ')]" mode="getTitle"/>
  419. </xsl:otherwise>
  420. </xsl:choose>
  421. </xsl:template>
  422. <xsl:template match="*" mode="getTitle">
  423. <xsl:choose>
  424. <!-- add keycol here once implemented-->
  425. <xsl:when test="@spectitle">
  426. <xsl:value-of select="@spectitle"/>
  427. </xsl:when>
  428. <xsl:otherwise>
  429. <xsl:apply-templates/>
  430. </xsl:otherwise>
  431. </xsl:choose>
  432. </xsl:template>
  433. <xsl:template match="*[contains(@class,' topic/titlealts ')]">
  434. <xsl:if test="$DRAFT='yes'">
  435. <xsl:if test="*">
  436. <fo:block xsl:use-attribute-sets="titlealts">
  437. <xsl:call-template name="commonattributes"/>
  438. <xsl:apply-templates/>
  439. </fo:block>
  440. </xsl:if>
  441. </xsl:if>
  442. </xsl:template>
  443. <xsl:template match="*[contains(@class,' topic/navtitle ')]">
  444. <fo:block xsl:use-attribute-sets="navtitle">
  445. <xsl:call-template name="commonattributes"/>
  446. <fo:inline xsl:use-attribute-sets="navtitle__label">
  447. <xsl:call-template name="getVariable">
  448. <xsl:with-param name="id" select="'Navigation title'"/>
  449. </xsl:call-template>
  450. <xsl:text>: </xsl:text>
  451. </fo:inline>
  452. <xsl:apply-templates/>
  453. </fo:block>
  454. </xsl:template>
  455. <!-- Map uses map/searchtitle, topic uses topic/searchtitle. This will likely be changed
  456. to a single value in DITA 2.0, but for now, recognize both. -->
  457. <xsl:template match="*[contains(@class,' topic/titlealts ')]/*[contains(@class,' topic/searchtitle ')] |
  458. *[contains(@class,' topic/titlealts ')]/*[contains(@class,' map/searchtitle ')]">
  459. <fo:block xsl:use-attribute-sets="searchtitle">
  460. <xsl:call-template name="commonattributes"/>
  461. <fo:inline xsl:use-attribute-sets="searchtitle__label">
  462. <xsl:call-template name="getVariable">
  463. <xsl:with-param name="id" select="'Search title'"/>
  464. </xsl:call-template>
  465. <xsl:text>: </xsl:text>
  466. </fo:inline>
  467. <xsl:apply-templates/>
  468. </fo:block>
  469. </xsl:template>
  470. <xsl:template match="*[contains(@class,' topic/abstract ')]">
  471. <fo:block xsl:use-attribute-sets="abstract">
  472. <xsl:call-template name="commonattributes"/>
  473. <xsl:apply-templates/>
  474. </fo:block>
  475. </xsl:template>
  476. <xsl:function name="dita-ot:formatShortdescAsBlock" as="xs:boolean">
  477. <xsl:param name="ctx" as="element()"/>
  478. <xsl:choose>
  479. <xsl:when test="not($ctx/parent::*[contains(@class,' topic/abstract ')])">
  480. <xsl:sequence select="true()"/>
  481. </xsl:when>
  482. <xsl:when test="$ctx/preceding-sibling::*[contains(@class,' topic/p ') or contains(@class,' topic/dl ') or
  483. contains(@class,' topic/fig ') or contains(@class,' topic/lines ') or
  484. contains(@class,' topic/lq ') or contains(@class,' topic/note ') or
  485. contains(@class,' topic/ol ') or contains(@class,' topic/pre ') or
  486. contains(@class,' topic/simpletable ') or contains(@class,' topic/sl ') or
  487. contains(@class,' topic/table ') or contains(@class,' topic/ul ') or
  488. contains(@class,' topic/div ')]">
  489. <xsl:sequence select="true()"/>
  490. </xsl:when>
  491. <xsl:when test="$ctx/following-sibling::*[contains(@class,' topic/p ') or contains(@class,' topic/dl ') or
  492. contains(@class,' topic/fig ') or contains(@class,' topic/lines ') or
  493. contains(@class,' topic/lq ') or contains(@class,' topic/note ') or
  494. contains(@class,' topic/ol ') or contains(@class,' topic/pre ') or
  495. contains(@class,' topic/simpletable ') or contains(@class,' topic/sl ') or
  496. contains(@class,' topic/table ') or contains(@class,' topic/ul ') or
  497. contains(@class,' topic/div ')]">
  498. <xsl:sequence select="true()"/>
  499. </xsl:when>
  500. <xsl:otherwise>
  501. <xsl:sequence select="false()"/>
  502. </xsl:otherwise>
  503. </xsl:choose>
  504. </xsl:function>
  505. <!-- For SF Bug 2879171: modify so that shortdesc is inline when inside
  506. abstract with only other text or inline markup. -->
  507. <xsl:template match="*[contains(@class,' topic/shortdesc ')]">
  508. <xsl:variable name="format-as-block" as="xs:boolean" select="dita-ot:formatShortdescAsBlock(.)"/>
  509. <xsl:choose>
  510. <xsl:when test="$format-as-block">
  511. <xsl:apply-templates select="." mode="format-shortdesc-as-block"/>
  512. </xsl:when>
  513. <xsl:otherwise>
  514. <xsl:apply-templates select="." mode="format-shortdesc-as-inline"/>
  515. </xsl:otherwise>
  516. </xsl:choose>
  517. </xsl:template>
  518. <xsl:template match="*" mode="format-shortdesc-as-block">
  519. <!--compare the length of shortdesc with the got max chars-->
  520. <fo:block xsl:use-attribute-sets="topic__shortdesc">
  521. <xsl:call-template name="commonattributes"/>
  522. <!-- If the shortdesc is sufficiently short, add keep-with-next. -->
  523. <xsl:if test="string-length(.) lt $maxCharsInShortDesc">
  524. <!-- Low-strength keep to avoid conflict with keeps on titles. -->
  525. <xsl:attribute name="keep-with-next.within-page">5</xsl:attribute>
  526. </xsl:if>
  527. <xsl:if test="parent::*[contains(@class,' topic/abstract ')]">
  528. <xsl:attribute name="start-indent">from-parent(start-indent)</xsl:attribute>
  529. </xsl:if>
  530. <xsl:apply-templates/>
  531. </fo:block>
  532. </xsl:template>
  533. <xsl:template match="*" mode="format-shortdesc-as-inline">
  534. <fo:inline xsl:use-attribute-sets="shortdesc">
  535. <xsl:call-template name="commonattributes"/>
  536. <xsl:if test="preceding-sibling::* | preceding-sibling::text()">
  537. <xsl:text> </xsl:text>
  538. </xsl:if>
  539. <xsl:apply-templates/>
  540. </fo:inline>
  541. </xsl:template>
  542. <xsl:template match="*[contains(@class,' map/shortdesc ')]">
  543. <xsl:apply-templates select="." mode="format-shortdesc-as-block"/>
  544. </xsl:template>
  545. <xsl:template match="*[contains(@class, ' topic/topic ')]/*[contains(@class,' topic/shortdesc ')]" priority="1">
  546. <xsl:variable name="topicType" as="xs:string">
  547. <xsl:call-template name="determineTopicType"/>
  548. </xsl:variable>
  549. <xsl:choose>
  550. <!-- Disable chapter summary processing when mini TOC is created -->
  551. <xsl:when test="$topicType = ('topicChapter', 'topicAppendix') and
  552. $chapterLayout != 'BASIC'"/>
  553. <!-- Normal processing -->
  554. <xsl:otherwise>
  555. <xsl:apply-templates select="." mode="format-shortdesc-as-block"/>
  556. </xsl:otherwise>
  557. </xsl:choose>
  558. </xsl:template>
  559. <xsl:template name="getMaxCharsForShortdescKeep" as="xs:integer">
  560. <!-- These values specify the length of a short description that will
  561. render with keep-with-next set, which should be (approximately) the
  562. character count in three lines of rendered shortdesc text. If you customize the
  563. default font, page margins, or shortdesc attribute sets, you may need
  564. to change these values. -->
  565. <xsl:choose>
  566. <xsl:when test="$locale = 'en_US' or $locale = 'fr_FR'">
  567. <xsl:sequence select="360"/>
  568. </xsl:when>
  569. <xsl:when test="$locale = 'ja_JP'">
  570. <xsl:sequence select="141"/>
  571. </xsl:when>
  572. <xsl:when test="$locale = 'zh_CN'">
  573. <xsl:sequence select="141"/>
  574. </xsl:when>
  575. <!-- Other languages require a template override to generate
  576. keep-with-next
  577. on shortdesc. Data was not available at the time this code released.
  578. -->
  579. <xsl:otherwise>
  580. <xsl:sequence select="0"/>
  581. </xsl:otherwise>
  582. </xsl:choose>
  583. </xsl:template>
  584. <!-- this is the fallthrough body for nested topics -->
  585. <xsl:template match="*[contains(@class,' topic/body ')]">
  586. <xsl:variable name="level" as="xs:integer">
  587. <xsl:apply-templates select="." mode="get-topic-level"/>
  588. </xsl:variable>
  589. <xsl:choose>
  590. <xsl:when test="not(node())"/>
  591. <xsl:when test="$level = 1">
  592. <fo:block xsl:use-attribute-sets="body__toplevel">
  593. <xsl:apply-templates/>
  594. </fo:block>
  595. </xsl:when>
  596. <xsl:when test="$level = 2">
  597. <fo:block xsl:use-attribute-sets="body__secondLevel">
  598. <xsl:apply-templates/>
  599. </fo:block>
  600. </xsl:when>
  601. <xsl:otherwise>
  602. <fo:block xsl:use-attribute-sets="body">
  603. <xsl:apply-templates/>
  604. </fo:block>
  605. </xsl:otherwise>
  606. </xsl:choose>
  607. </xsl:template>
  608. <xsl:template match="*[contains(@class,' topic/bodydiv ')]">
  609. <fo:block>
  610. <xsl:call-template name="commonattributes"/>
  611. <xsl:apply-templates/>
  612. </fo:block>
  613. </xsl:template>
  614. <xsl:template match="*[contains(@class,' topic/section ')]
  615. [@spectitle != '' and not(*[contains(@class, ' topic/title ')])]"
  616. mode="dita2xslfo:section-heading"
  617. priority="10">
  618. <fo:block xsl:use-attribute-sets="section.title">
  619. <xsl:call-template name="commonattributes"/>
  620. <xsl:variable name="spectitleValue" as="xs:string" select="string(@spectitle)"/>
  621. <xsl:variable name="resolvedVariable">
  622. <xsl:call-template name="getVariable">
  623. <xsl:with-param name="id" select="$spectitleValue"/>
  624. </xsl:call-template>
  625. </xsl:variable>
  626. <xsl:sequence select="if (not(normalize-space($resolvedVariable)))
  627. then $spectitleValue
  628. else $resolvedVariable" />
  629. </fo:block>
  630. </xsl:template>
  631. <xsl:template match="*[contains(@class,' topic/section ')]" mode="dita2xslfo:section-heading">
  632. <!-- Specialized section elements may override this rule to add
  633. default headings for a section. By default, titles are processed
  634. where they exist within the section, so overrides may need to
  635. check for the existence of a title first. -->
  636. </xsl:template>
  637. <xsl:template match="*[contains(@class,' topic/section ')]">
  638. <fo:block xsl:use-attribute-sets="section">
  639. <xsl:call-template name="commonattributes"/>
  640. <xsl:apply-templates select="." mode="dita2xslfo:section-heading"/>
  641. <xsl:apply-templates select="*[contains(@class,' topic/title ')]"/>
  642. <fo:block xsl:use-attribute-sets="section__content">
  643. <xsl:apply-templates select="node() except (*[contains(@class,' topic/title ')])"/>
  644. </fo:block>
  645. </fo:block>
  646. </xsl:template>
  647. <xsl:template match="*[contains(@class,' topic/sectiondiv ')]">
  648. <fo:block>
  649. <xsl:call-template name="commonattributes"/>
  650. <xsl:apply-templates/>
  651. </fo:block>
  652. </xsl:template>
  653. <xsl:template match="*[contains(@class,' topic/example ')]">
  654. <fo:block xsl:use-attribute-sets="example">
  655. <xsl:call-template name="commonattributes"/>
  656. <xsl:apply-templates select="*[contains(@class,' topic/title ')]"/>
  657. <fo:block xsl:use-attribute-sets="example__content">
  658. <xsl:apply-templates select="node() except (*[contains(@class,' topic/title ')])"/>
  659. </fo:block>
  660. </fo:block>
  661. </xsl:template>
  662. <xsl:template match="*[contains(@class,' topic/desc ')]">
  663. <fo:inline xsl:use-attribute-sets="desc">
  664. <xsl:call-template name="commonattributes"/>
  665. <xsl:apply-templates/>
  666. </fo:inline>
  667. </xsl:template>
  668. <xsl:template match="*[contains(@class,' topic/prolog ')]"/>
  669. <!--
  670. <fo:block xsl:use-attribute-sets="prolog">
  671. <xsl:apply-templates/>
  672. </fo:block>
  673. -->
  674. <!--xsl:copy-of select="node()"/-->
  675. <!--xsl:apply-templates select="descendant::opentopic-index:index.entry[not(parent::opentopic-index:index.entry)]"/-->
  676. <!--/xsl:template-->
  677. <xsl:template name="pullPrologIndexTerms">
  678. <!-- index terms and ranges from topic -->
  679. <xsl:apply-templates select="ancestor-or-self::*[contains(@class, ' topic/topic ')][1]/*[contains(@class, ' topic/prolog ')]
  680. //opentopic-index:index.entry[not(parent::opentopic-index:index.entry) and not(@end-range = 'true')]"/>
  681. <!-- index ranges from map -->
  682. <xsl:variable name="topicref" select="key('map-id', @id)[1]" as="element()?"/>
  683. <xsl:apply-templates select="$topicref/
  684. *[contains(@class, ' map/topicmeta ')]/
  685. *[contains(@class, ' topic/keywords ')]/
  686. descendant::opentopic-index:index.entry[@start-range = 'true']"/>
  687. </xsl:template>
  688. <xsl:template name="pullPrologIndexTerms.end-range">
  689. <!-- index ranges from topic -->
  690. <xsl:apply-templates select="ancestor-or-self::*[contains(@class, ' topic/topic ')][1]/
  691. *[contains(@class, ' topic/prolog ')]/
  692. descendant::opentopic-index:index.entry[not(parent::opentopic-index:index.entry) and
  693. @end-range = 'true']"/>
  694. <!-- index ranges from map -->
  695. <xsl:variable name="topicref" select="key('map-id', @id)[1]" as="element()?"/>
  696. <xsl:apply-templates select="$topicref/
  697. *[contains(@class, ' map/topicmeta ')]/
  698. *[contains(@class, ' topic/keywords ')]/
  699. descendant::opentopic-index:index.entry[@end-range = 'true']"/>
  700. </xsl:template>
  701. <xsl:template match="*[contains(@class, ' topic/metadata ')]">
  702. <!--
  703. <fo:block xsl:use-attribute-sets="metadata">
  704. <xsl:apply-templates/>
  705. </fo:block>
  706. -->
  707. <xsl:apply-templates select="descendant::opentopic-index:index.entry[not(parent::opentopic-index:index.entry)]"/>
  708. </xsl:template>
  709. <xsl:template match="*[contains(@class, ' topic/div ')]">
  710. <fo:block xsl:use-attribute-sets="div">
  711. <xsl:call-template name="commonattributes"/>
  712. <xsl:apply-templates/>
  713. </fo:block>
  714. </xsl:template>
  715. <xsl:template match="*[contains(@class, ' topic/p ')]">
  716. <fo:block xsl:use-attribute-sets="p">
  717. <xsl:call-template name="commonattributes"/>
  718. <xsl:apply-templates/>
  719. </fo:block>
  720. </xsl:template>
  721. <xsl:template match="*" mode="placeNoteContent">
  722. <fo:block xsl:use-attribute-sets="note">
  723. <xsl:call-template name="commonattributes"/>
  724. <fo:inline xsl:use-attribute-sets="note__label">
  725. <xsl:choose>
  726. <xsl:when test="@type='note' or not(@type)">
  727. <fo:inline xsl:use-attribute-sets="note__label__note">
  728. <xsl:call-template name="getVariable">
  729. <xsl:with-param name="id" select="'Note'"/>
  730. </xsl:call-template>
  731. </fo:inline>
  732. </xsl:when>
  733. <xsl:when test="@type='notice'">
  734. <fo:inline xsl:use-attribute-sets="note__label__notice">
  735. <xsl:call-template name="getVariable">
  736. <xsl:with-param name="id" select="'Notice'"/>
  737. </xsl:call-template>
  738. </fo:inline>
  739. </xsl:when>
  740. <xsl:when test="@type='tip'">
  741. <fo:inline xsl:use-attribute-sets="note__label__tip">
  742. <xsl:call-template name="getVariable">
  743. <xsl:with-param name="id" select="'Tip'"/>
  744. </xsl:call-template>
  745. </fo:inline>
  746. </xsl:when>
  747. <xsl:when test="@type='fastpath'">
  748. <fo:inline xsl:use-attribute-sets="note__label__fastpath">
  749. <xsl:call-template name="getVariable">
  750. <xsl:with-param name="id" select="'Fastpath'"/>
  751. </xsl:call-template>
  752. </fo:inline>
  753. </xsl:when>
  754. <xsl:when test="@type='restriction'">
  755. <fo:inline xsl:use-attribute-sets="note__label__restriction">
  756. <xsl:call-template name="getVariable">
  757. <xsl:with-param name="id" select="'Restriction'"/>
  758. </xsl:call-template>
  759. </fo:inline>
  760. </xsl:when>
  761. <xsl:when test="@type='important'">
  762. <fo:inline xsl:use-attribute-sets="note__label__important">
  763. <xsl:call-template name="getVariable">
  764. <xsl:with-param name="id" select="'Important'"/>
  765. </xsl:call-template>
  766. </fo:inline>
  767. </xsl:when>
  768. <xsl:when test="@type='remember'">
  769. <fo:inline xsl:use-attribute-sets="note__label__remember">
  770. <xsl:call-template name="getVariable">
  771. <xsl:with-param name="id" select="'Remember'"/>
  772. </xsl:call-template>
  773. </fo:inline>
  774. </xsl:when>
  775. <xsl:when test="@type='attention'">
  776. <fo:inline xsl:use-attribute-sets="note__label__attention">
  777. <xsl:call-template name="getVariable">
  778. <xsl:with-param name="id" select="'Attention'"/>
  779. </xsl:call-template>
  780. </fo:inline>
  781. </xsl:when>
  782. <xsl:when test="@type='caution'">
  783. <fo:inline xsl:use-attribute-sets="note__label__caution">
  784. <xsl:call-template name="getVariable">
  785. <xsl:with-param name="id" select="'Caution'"/>
  786. </xsl:call-template>
  787. </fo:inline>
  788. </xsl:when>
  789. <xsl:when test="@type='danger'">
  790. <fo:inline xsl:use-attribute-sets="note__label__danger">
  791. <xsl:call-template name="getVariable">
  792. <xsl:with-param name="id" select="'Danger'"/>
  793. </xsl:call-template>
  794. </fo:inline>
  795. </xsl:when>
  796. <xsl:when test="@type='warning'">
  797. <fo:inline xsl:use-attribute-sets="note__label__danger">
  798. <xsl:call-template name="getVariable">
  799. <xsl:with-param name="id" select="'Warning'"/>
  800. </xsl:call-template>
  801. </fo:inline>
  802. </xsl:when>
  803. <xsl:when test="@type='trouble'">
  804. <fo:inline xsl:use-attribute-sets="note__label__trouble">
  805. <xsl:call-template name="getVariable">
  806. <xsl:with-param name="id" select="'Trouble'"/>
  807. </xsl:call-template>
  808. </fo:inline>
  809. </xsl:when>
  810. <xsl:when test="@type='other'">
  811. <fo:inline xsl:use-attribute-sets="note__label__other">
  812. <xsl:choose>
  813. <xsl:when test="@othertype">
  814. <xsl:value-of select="@othertype"/>
  815. </xsl:when>
  816. <xsl:otherwise>
  817. <xsl:text>[</xsl:text>
  818. <xsl:value-of select="@type"/>
  819. <xsl:text>]</xsl:text>
  820. </xsl:otherwise>
  821. </xsl:choose>
  822. </fo:inline>
  823. </xsl:when>
  824. </xsl:choose>
  825. <xsl:call-template name="getVariable">
  826. <xsl:with-param name="id" select="'#note-separator'"/>
  827. </xsl:call-template>
  828. </fo:inline>
  829. <xsl:text> </xsl:text>
  830. <xsl:apply-templates/>
  831. </fo:block>
  832. </xsl:template>
  833. <xsl:template match="*[contains(@class,' topic/note ')]" mode="setNoteImagePath">
  834. <xsl:variable name="noteType" as="xs:string">
  835. <xsl:choose>
  836. <xsl:when test="@type">
  837. <xsl:value-of select="@type"/>
  838. </xsl:when>
  839. <xsl:otherwise>
  840. <xsl:value-of select="'note'"/>
  841. </xsl:otherwise>
  842. </xsl:choose>
  843. </xsl:variable>
  844. <xsl:call-template name="getVariable">
  845. <xsl:with-param name="id" select="concat($noteType, ' Note Image Path')"/>
  846. </xsl:call-template>
  847. </xsl:template>
  848. <xsl:template match="*[contains(@class,' topic/note ')]">
  849. <xsl:variable name="noteImagePath">
  850. <xsl:apply-templates select="." mode="setNoteImagePath"/>
  851. </xsl:variable>
  852. <xsl:choose>
  853. <xsl:when test="not($noteImagePath = '')">
  854. <fo:table xsl:use-attribute-sets="note__table">
  855. <fo:table-column xsl:use-attribute-sets="note__image__column"/>
  856. <fo:table-column xsl:use-attribute-sets="note__text__column"/>
  857. <fo:table-body>
  858. <fo:table-row>
  859. <fo:table-cell xsl:use-attribute-sets="note__image__entry">
  860. <fo:block>
  861. <fo:external-graphic src="url('{concat($artworkPrefix, $noteImagePath)}')"
  862. content-height="2em" padding-right="3pt"
  863. vertical-align="middle"
  864. baseline-shift="baseline"/>
  865. </fo:block>
  866. </fo:table-cell>
  867. <fo:table-cell xsl:use-attribute-sets="note__text__entry">
  868. <xsl:apply-templates select="." mode="placeNoteContent"/>
  869. </fo:table-cell>
  870. </fo:table-row>
  871. </fo:table-body>
  872. </fo:table>
  873. </xsl:when>
  874. <xsl:otherwise>
  875. <xsl:apply-templates select="." mode="placeNoteContent"/>
  876. </xsl:otherwise>
  877. </xsl:choose>
  878. </xsl:template>
  879. <xsl:template match="*[contains(@class,' topic/lq ')]">
  880. <fo:block xsl:use-attribute-sets="lq">
  881. <xsl:call-template name="commonattributes"/>
  882. <xsl:choose>
  883. <xsl:when test="@href or @reftitle">
  884. <xsl:call-template name="processAttrSetReflection">
  885. <xsl:with-param name="attrSet" select="'lq'"/>
  886. <xsl:with-param name="path" select="'../../cfg/fo/attrs/commons-attr.xsl'"/>
  887. </xsl:call-template>
  888. </xsl:when>
  889. <xsl:otherwise>
  890. <xsl:call-template name="processAttrSetReflection">
  891. <xsl:with-param name="attrSet" select="'lq_simple'"/>
  892. <xsl:with-param name="path" select="'../../cfg/fo/attrs/commons-attr.xsl'"/>
  893. </xsl:call-template>
  894. </xsl:otherwise>
  895. </xsl:choose>
  896. <xsl:apply-templates/>
  897. </fo:block>
  898. <xsl:choose>
  899. <xsl:when test="@href">
  900. <fo:block xsl:use-attribute-sets="lq_link">
  901. <fo:basic-link>
  902. <xsl:call-template name="buildBasicLinkDestination">
  903. <xsl:with-param name="scope" select="@scope"/>
  904. <xsl:with-param name="format" select="@format"/>
  905. <xsl:with-param name="href" select="@href"/>
  906. </xsl:call-template>
  907. <xsl:choose>
  908. <xsl:when test="@reftitle">
  909. <xsl:value-of select="@reftitle"/>
  910. </xsl:when>
  911. <xsl:when test="not(@type = 'external' or @format = 'html')">
  912. <xsl:apply-templates select="." mode="insertReferenceTitle">
  913. <xsl:with-param name="href" select="@href"/>
  914. <xsl:with-param name="titlePrefix" select="''"/>
  915. </xsl:apply-templates>
  916. </xsl:when>
  917. <xsl:otherwise>
  918. <xsl:value-of select="@href"/>
  919. </xsl:otherwise>
  920. </xsl:choose>
  921. </fo:basic-link>
  922. </fo:block>
  923. </xsl:when>
  924. <xsl:when test="@reftitle">
  925. <fo:block xsl:use-attribute-sets="lq_title">
  926. <xsl:value-of select="@reftitle"/>
  927. </fo:block>
  928. </xsl:when>
  929. </xsl:choose>
  930. </xsl:template>
  931. <xsl:template match="*[contains(@class,' topic/q ')]">
  932. <fo:inline xsl:use-attribute-sets="q">
  933. <xsl:call-template name="commonattributes"/>
  934. <xsl:call-template name="getVariable">
  935. <xsl:with-param name="id" select="'#quote-start'"/>
  936. </xsl:call-template>
  937. <xsl:apply-templates/>
  938. <xsl:call-template name="getVariable">
  939. <xsl:with-param name="id" select="'#quote-end'"/>
  940. </xsl:call-template>
  941. </fo:inline>
  942. </xsl:template>
  943. <xsl:template match="*[contains(@class,' topic/fig ')]">
  944. <fo:block xsl:use-attribute-sets="fig">
  945. <xsl:call-template name="commonattributes"/>
  946. <xsl:call-template name="setFrame"/>
  947. <xsl:call-template name="setExpanse"/>
  948. <xsl:call-template name="setScale"/>
  949. <xsl:if test="not(@id)">
  950. <xsl:attribute name="id">
  951. <xsl:call-template name="get-id"/>
  952. </xsl:attribute>
  953. </xsl:if>
  954. <xsl:apply-templates select="*[not(contains(@class,' topic/title '))]"/>
  955. <xsl:apply-templates select="*[contains(@class,' topic/title ')]"/>
  956. </fo:block>
  957. </xsl:template>
  958. <xsl:template match="*[contains(@class,' topic/figgroup ')]">
  959. <fo:block xsl:use-attribute-sets="figgroup">
  960. <xsl:call-template name="commonattributes"/>
  961. <xsl:apply-templates/>
  962. </fo:block>
  963. </xsl:template>
  964. <xsl:template match="*[contains(@class,' topic/pre ')]">
  965. <xsl:call-template name="setSpecTitle"/>
  966. <fo:block xsl:use-attribute-sets="pre">
  967. <xsl:call-template name="commonattributes"/>
  968. <xsl:call-template name="setFrame"/>
  969. <xsl:call-template name="setScale"/>
  970. <xsl:call-template name="setExpanse"/>
  971. <xsl:apply-templates/>
  972. </fo:block>
  973. </xsl:template>
  974. <xsl:template name="setSpecTitle">
  975. <xsl:if test="@spectitle">
  976. <fo:block xsl:use-attribute-sets="__spectitle">
  977. <xsl:value-of select="@spectitle"/>
  978. </fo:block>
  979. </xsl:if>
  980. </xsl:template>
  981. <xsl:template name="setScale">
  982. <xsl:if test="@scale">
  983. <!-- For applications that do not yet take percentages. need to divide by 10 and use "pt" -->
  984. <xsl:attribute name="font-size">
  985. <xsl:value-of select="concat(@scale, '%')"/>
  986. </xsl:attribute>
  987. </xsl:if>
  988. </xsl:template>
  989. <!-- Process the frame attribute -->
  990. <!-- frame styles (setframe) must be called within a block that defines the content being framed -->
  991. <xsl:template name="setFrame" as="attribute()*">
  992. <xsl:variable name="container" as="element()*">
  993. <xsl:choose>
  994. <xsl:when test="@frame = 'top'">
  995. <element xsl:use-attribute-sets="__border__top"/>
  996. </xsl:when>
  997. <xsl:when test="@frame = 'bot'">
  998. <element xsl:use-attribute-sets="__border__bot"/>
  999. </xsl:when>
  1000. <xsl:when test="@frame = 'topbot'">
  1001. <element xsl:use-attribute-sets="__border__topbot"/>
  1002. </xsl:when>
  1003. <xsl:when test="@frame = 'sides'">
  1004. <element xsl:use-attribute-sets="__border__sides"/>
  1005. </xsl:when>
  1006. <xsl:when test="@frame = 'all'">
  1007. <element xsl:use-attribute-sets="__border__all"/>
  1008. </xsl:when>
  1009. </xsl:choose>
  1010. </xsl:variable>
  1011. <xsl:sequence select="$container/@*"/>
  1012. </xsl:template>
  1013. <xsl:template name="setExpanse" as="attribute()*">
  1014. <xsl:variable name="container" as="element()*">
  1015. <xsl:choose>
  1016. <xsl:when test="@expanse = 'page'">
  1017. <element xsl:use-attribute-sets="__expanse__page"/>
  1018. </xsl:when>
  1019. <xsl:when test="@expanse = 'column'">
  1020. <element xsl:use-attribute-sets="__expanse__column"/>
  1021. </xsl:when>
  1022. <xsl:when test="@expanse = 'spread'">
  1023. <element xsl:use-attribute-sets="__expanse__spread"/>
  1024. </xsl:when>
  1025. <xsl:when test="@expanse = 'column'">
  1026. <element xsl:use-attribute-sets="__expanse__textline"/>
  1027. </xsl:when>
  1028. </xsl:choose>
  1029. </xsl:variable>
  1030. <xsl:sequence select="$container/@*"/>
  1031. </xsl:template>
  1032. <xsl:template match="*[contains(@class,' topic/lines ')]">
  1033. <xsl:call-template name="setSpecTitle"/>
  1034. <fo:block xsl:use-attribute-sets="lines">
  1035. <xsl:call-template name="commonattributes"/>
  1036. <xsl:call-template name="setFrame"/>
  1037. <xsl:call-template name="setScale"/>
  1038. <xsl:call-template name="setExpanse"/>
  1039. <xsl:apply-templates/>
  1040. </fo:block>
  1041. </xsl:template>
  1042. <!-- The text element has no default semantics or formatting -->
  1043. <xsl:template match="*[contains(@class,' topic/text ')]">
  1044. <fo:inline>
  1045. <xsl:call-template name="commonattributes"/>
  1046. <xsl:apply-templates/>
  1047. </fo:inline>
  1048. </xsl:template>
  1049. <xsl:template match="*" mode="inlineTextOptionalKeyref">
  1050. <xsl:param name="copyAttributes" as="element()?"/>
  1051. <xsl:param name="keys" select="@keyref" as="attribute()?"/>
  1052. <xsl:param name="contents" as="node()*">
  1053. <!-- Current node can be preprocessed and may not be part of source document, check for root() to ensure key() is resolvable -->
  1054. <xsl:variable name="target" select="if (exists(root()) and @href) then key('id', substring(@href, 2))[1] else ()" as="element()?"/>
  1055. <xsl:choose>
  1056. <xsl:when test="not(normalize-space(.)) and $keys and $target/self::*[contains(@class,' topic/topic ')]">
  1057. <xsl:apply-templates select="$target/*[contains(@class, ' topic/title ')]/node()"/>
  1058. </xsl:when>
  1059. <xsl:otherwise>
  1060. <xsl:apply-templates/>
  1061. </xsl:otherwise>
  1062. </xsl:choose>
  1063. </xsl:param>
  1064. <xsl:variable name="topicref" select="key('map-id', substring(@href, 2))[1]" as="element()?"/>
  1065. <xsl:choose>
  1066. <xsl:when test="$keys and @href and not($topicref/ancestor-or-self::*[@linking][1]/@linking = ('none', 'sourceonly'))">
  1067. <fo:basic-link xsl:use-attribute-sets="xref">
  1068. <xsl:sequence select="$copyAttributes/@*"/>
  1069. <xsl:call-template name="commonattributes"/>
  1070. <xsl:call-template name="buildBasicLinkDestination"/>
  1071. <xsl:copy-of select="$contents"/>
  1072. </fo:basic-link>
  1073. </xsl:when>
  1074. <xsl:otherwise>
  1075. <fo:inline>
  1076. <xsl:sequence select="$copyAttributes/@*"/>
  1077. <xsl:call-template name="commonattributes"/>
  1078. <xsl:copy-of select="$contents"/>
  1079. </fo:inline>
  1080. </xsl:otherwise>
  1081. </xsl:choose>
  1082. </xsl:template>
  1083. <xsl:template match="*[contains(@class,' topic/keyword ')]" name="topic.keyword">
  1084. <xsl:apply-templates select="." mode="inlineTextOptionalKeyref">
  1085. <xsl:with-param name="copyAttributes" as="element()"><wrapper xsl:use-attribute-sets="keyword"/></xsl:with-param>
  1086. </xsl:apply-templates>
  1087. </xsl:template>
  1088. <xsl:template match="*[contains(@class,' topic/ph ')]">
  1089. <xsl:apply-templates select="." mode="inlineTextOptionalKeyref">
  1090. <xsl:with-param name="copyAttributes" as="element()"><wrapper xsl:use-attribute-sets="ph"/></xsl:with-param>
  1091. </xsl:apply-templates>
  1092. </xsl:template>
  1093. <xsl:template match="*[contains(@class,' topic/boolean ')]">
  1094. <fo:inline xsl:use-attribute-sets="boolean">
  1095. <xsl:call-template name="commonattributes"/>
  1096. <xsl:value-of select="name()"/>
  1097. <xsl:text>: </xsl:text>
  1098. <xsl:value-of select="@state"/>
  1099. </fo:inline>
  1100. </xsl:template>
  1101. <xsl:template match="*[contains(@class,' topic/state ')]">
  1102. <fo:inline xsl:use-attribute-sets="state">
  1103. <xsl:call-template name="commonattributes"/>
  1104. <xsl:value-of select="name()"/>
  1105. <xsl:text>: </xsl:text>
  1106. <xsl:value-of select="@name"/>
  1107. <xsl:text>=</xsl:text>
  1108. <xsl:value-of select="@value"/>
  1109. </fo:inline>
  1110. </xsl:template>
  1111. <xsl:variable name="job" select="document(resolve-uri('.job.xml', $work.dir.url))" as="document-node()?"/>
  1112. <xsl:key name="jobFile" match="file" use="@uri"/>
  1113. <xsl:template match="*[contains(@class,' topic/image ')]" name="image">
  1114. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')]" mode="outofline"/>
  1115. <xsl:choose>
  1116. <xsl:when test="empty(@href)"/>
  1117. <xsl:when test="@placement = 'break'">
  1118. <fo:block xsl:use-attribute-sets="image__block">
  1119. <xsl:call-template name="commonattributes"/>
  1120. <xsl:apply-templates select="." mode="placeImage">
  1121. <xsl:with-param name="imageAlign" select="@align"/>
  1122. <xsl:with-param name="href">
  1123. <xsl:choose>
  1124. <xsl:when test="@scope = 'external' or opentopic-func:isAbsolute(@href)">
  1125. <xsl:value-of select="@href"/>
  1126. </xsl:when>
  1127. <xsl:when test="exists(key('jobFile', @href, $job))">
  1128. <xsl:value-of select="key('jobFile', @href, $job)/@src"/>
  1129. </xsl:when>
  1130. <xsl:otherwise>
  1131. <xsl:value-of select="concat($input.dir.url, @href)"/>
  1132. </xsl:otherwise>
  1133. </xsl:choose>
  1134. </xsl:with-param>
  1135. <xsl:with-param name="height" select="@height"/>
  1136. <xsl:with-param name="width" select="@width"/>
  1137. </xsl:apply-templates>
  1138. </fo:block>
  1139. <xsl:if test="$artLabel='yes'">
  1140. <fo:block>
  1141. <xsl:apply-templates select="." mode="image.artlabel"/>
  1142. </fo:block>
  1143. </xsl:if>
  1144. </xsl:when>
  1145. <xsl:otherwise>
  1146. <fo:inline xsl:use-attribute-sets="image__inline">
  1147. <xsl:call-template name="commonattributes"/>
  1148. <xsl:apply-templates select="." mode="placeImage">
  1149. <xsl:with-param name="imageAlign" select="@align"/>
  1150. <xsl:with-param name="href">
  1151. <xsl:choose>
  1152. <xsl:when test="@scope = 'external' or opentopic-func:isAbsolute(@href)">
  1153. <xsl:value-of select="@href"/>
  1154. </xsl:when>
  1155. <xsl:when test="exists(key('jobFile', @href, $job))">
  1156. <xsl:value-of select="key('jobFile', @href, $job)/@src"/>
  1157. </xsl:when>
  1158. <xsl:otherwise>
  1159. <xsl:value-of select="concat($input.dir.url, @href)"/>
  1160. </xsl:otherwise>
  1161. </xsl:choose>
  1162. </xsl:with-param>
  1163. <xsl:with-param name="height" select="@height"/>
  1164. <xsl:with-param name="width" select="@width"/>
  1165. </xsl:apply-templates>
  1166. </fo:inline>
  1167. <xsl:if test="$artLabel='yes'">
  1168. <xsl:apply-templates select="." mode="image.artlabel"/>
  1169. </xsl:if>
  1170. </xsl:otherwise>
  1171. </xsl:choose>
  1172. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-endprop ')]" mode="outofline"/>
  1173. </xsl:template>
  1174. <xsl:template match="*" mode="image.artlabel">
  1175. <fo:inline xsl:use-attribute-sets="image.artlabel">
  1176. <xsl:text> </xsl:text>
  1177. <xsl:value-of select="@href"/>
  1178. <xsl:text> </xsl:text>
  1179. </fo:inline>
  1180. </xsl:template>
  1181. <!-- Test whether URI is absolute -->
  1182. <xsl:function name="opentopic-func:isAbsolute" as="xs:boolean">
  1183. <xsl:param name="uri" as="xs:anyURI"/>
  1184. <xsl:sequence select="some $prefix in ('/', 'file:') satisfies starts-with($uri, $prefix) or
  1185. contains($uri, '://')"/>
  1186. </xsl:function>
  1187. <xsl:template match="*" mode="placeImage">
  1188. <xsl:param name="imageAlign"/>
  1189. <xsl:param name="href"/>
  1190. <xsl:param name="height" as="xs:string?"/>
  1191. <xsl:param name="width" as="xs:string?"/>
  1192. <xsl:param name="scale" as="xs:string?">
  1193. <xsl:choose>
  1194. <xsl:when test="@scale"><xsl:value-of select="@scale"/></xsl:when>
  1195. <xsl:when test="ancestor::*[@scale]"><xsl:value-of select="ancestor::*[@scale][1]/@scale"/></xsl:when>
  1196. </xsl:choose>
  1197. </xsl:param>
  1198. <!--Using align attribute set according to image @align attribute-->
  1199. <xsl:call-template name="processAttrSetReflection">
  1200. <xsl:with-param name="attrSet" select="concat('__align__', $imageAlign)"/>
  1201. <xsl:with-param name="path" select="'../../cfg/fo/attrs/commons-attr.xsl'"/>
  1202. </xsl:call-template>
  1203. <fo:external-graphic src="url('{$href}')" xsl:use-attribute-sets="image">
  1204. <!--Setting image height if defined-->
  1205. <xsl:if test="$height">
  1206. <xsl:attribute name="content-height">
  1207. <!--The following test was commented out because most people found the behavior
  1208. surprising. It used to force images with a number specified for the dimensions
  1209. *but no units* to act as a measure of pixels, *if* you were printing at 72 DPI.
  1210. Uncomment if you really want it. -->
  1211. <xsl:choose>
  1212. <!--xsl:when test="not(string(number($height)) = 'NaN')">
  1213. <xsl:value-of select="concat($height div 72,'in')"/>
  1214. </xsl:when-->
  1215. <xsl:when test="not(string(number($height)) = 'NaN')">
  1216. <xsl:value-of select="concat($height, 'px')"/>
  1217. </xsl:when>
  1218. <xsl:otherwise>
  1219. <xsl:value-of select="$height"/>
  1220. </xsl:otherwise>
  1221. </xsl:choose>
  1222. </xsl:attribute>
  1223. </xsl:if>
  1224. <!--Setting image width if defined-->
  1225. <xsl:if test="$width">
  1226. <xsl:attribute name="content-width">
  1227. <xsl:choose>
  1228. <!--xsl:when test="not(string(number($width)) = 'NaN')">
  1229. <xsl:value-of select="concat($width div 72,'in')"/>
  1230. </xsl:when-->
  1231. <xsl:when test="not(string(number($width)) = 'NaN')">
  1232. <xsl:value-of select="concat($width, 'px')"/>
  1233. </xsl:when>
  1234. <xsl:otherwise>
  1235. <xsl:value-of select="$width"/>
  1236. </xsl:otherwise>
  1237. </xsl:choose>
  1238. </xsl:attribute>
  1239. </xsl:if>
  1240. <xsl:if test="not($width) and not($height) and $scale">
  1241. <xsl:attribute name="content-width">
  1242. <xsl:value-of select="concat($scale,'%')"/>
  1243. </xsl:attribute>
  1244. </xsl:if>
  1245. <xsl:if test="@scalefit = 'yes' and not($width) and not($height) and not($scale)">
  1246. <xsl:attribute name="width">100%</xsl:attribute>
  1247. <xsl:attribute name="height">100%</xsl:attribute>
  1248. <xsl:attribute name="content-width">scale-to-fit</xsl:attribute>
  1249. <xsl:attribute name="content-height">scale-to-fit</xsl:attribute>
  1250. <xsl:attribute name="scaling">uniform</xsl:attribute>
  1251. </xsl:if>
  1252. <xsl:choose>
  1253. <xsl:when test="*[contains(@class,' topic/alt ')]">
  1254. <xsl:apply-templates select="*[contains(@class,' topic/alt ')]" mode="graphicAlternateText"/>
  1255. </xsl:when>
  1256. <xsl:when test="@alt">
  1257. <xsl:apply-templates select="@alt" mode="graphicAlternateText"/>
  1258. </xsl:when>
  1259. </xsl:choose>
  1260. <xsl:apply-templates select="node() except (text(),
  1261. *[contains(@class, ' topic/alt ') or
  1262. contains(@class, ' topic/longdescref ')])"/>
  1263. </fo:external-graphic>
  1264. </xsl:template>
  1265. <xsl:template match="*|@alt" mode="graphicAlternateText"/>
  1266. <xsl:template match="*[contains(@class,' topic/alt ')]">
  1267. <fo:block xsl:use-attribute-sets="alt">
  1268. </fo:block>
  1269. </xsl:template>
  1270. <xsl:template match="*[contains(@class,' topic/object ')]">
  1271. <fo:inline xsl:use-attribute-sets="object">
  1272. <xsl:call-template name="commonattributes"/>
  1273. </fo:inline>
  1274. </xsl:template>
  1275. <xsl:template match="*[contains(@class,' topic/param ')]">
  1276. <fo:inline xsl:use-attribute-sets="param">
  1277. <xsl:call-template name="commonattributes"/>
  1278. </fo:inline>
  1279. </xsl:template>
  1280. <xsl:template match="*[contains(@class,' topic/foreign ')]"/>
  1281. <xsl:template match="*[contains(@class,' topic/unknown ')]"/>
  1282. <xsl:template match="*[contains(@class,' topic/draft-comment ')]">
  1283. <xsl:if test="$publishRequiredCleanup = 'yes' or $DRAFT='yes'">
  1284. <fo:block xsl:use-attribute-sets="draft-comment">
  1285. <xsl:call-template name="commonattributes"/>
  1286. <fo:block xsl:use-attribute-sets="draft-comment__label">
  1287. <xsl:text>Disposition: </xsl:text>
  1288. <xsl:value-of select="@disposition"/>
  1289. <xsl:text> / </xsl:text>
  1290. <xsl:text>Status: </xsl:text>
  1291. <xsl:value-of select="@status"/>
  1292. </fo:block>
  1293. <xsl:apply-templates/>
  1294. </fo:block>
  1295. </xsl:if>
  1296. </xsl:template>
  1297. <xsl:template match="*[contains(@class,' topic/required-cleanup ')]">
  1298. <xsl:if test="$publishRequiredCleanup = 'yes' or $DRAFT='yes'">
  1299. <fo:inline xsl:use-attribute-sets="required-cleanup">
  1300. <xsl:call-template name="commonattributes"/>
  1301. <fo:inline xsl:use-attribute-sets="required-cleanup__label">
  1302. <xsl:call-template name="getVariable">
  1303. <xsl:with-param name="id" select="'Required-Cleanup'"/>
  1304. </xsl:call-template>
  1305. <xsl:if test="string(@remap)">
  1306. <xsl:text>(</xsl:text>
  1307. <xsl:value-of select="@remap"/>
  1308. <xsl:text>)</xsl:text>
  1309. </xsl:if>
  1310. <xsl:text>: </xsl:text>
  1311. </fo:inline>
  1312. <xsl:apply-templates/>
  1313. </fo:inline>
  1314. </xsl:if>
  1315. </xsl:template>
  1316. <xsl:function name="dita-ot:getFootnoteInternalID" as="xs:string">
  1317. <xsl:param name="ctx" as="element()"/>
  1318. <xsl:sequence select="concat('fn',generate-id($ctx))"/>
  1319. </xsl:function>
  1320. <xsl:template match="*[contains(@class,' topic/fn ')]">
  1321. <xsl:variable name="id" select="dita-ot:getFootnoteInternalID(.)" as="xs:string"/>
  1322. <xsl:variable name="callout" as="xs:string">
  1323. <xsl:apply-templates select="." mode="callout"/>
  1324. </xsl:variable>
  1325. <fo:footnote>
  1326. <xsl:choose>
  1327. <xsl:when test="not(@id)">
  1328. <fo:inline xsl:use-attribute-sets="fn__callout">
  1329. <fo:basic-link internal-destination="{$id}">
  1330. <xsl:copy-of select="$callout"/>
  1331. </fo:basic-link>
  1332. </fo:inline>
  1333. </xsl:when>
  1334. <xsl:otherwise>
  1335. <!-- Footnote with id does not generate its own callout. -->
  1336. <fo:inline/>
  1337. </xsl:otherwise>
  1338. </xsl:choose>
  1339. <fo:footnote-body>
  1340. <fo:list-block xsl:use-attribute-sets="fn__body">
  1341. <fo:list-item>
  1342. <fo:list-item-label end-indent="label-end()">
  1343. <fo:block text-align="right" id="{$id}">
  1344. <fo:inline xsl:use-attribute-sets="fn__callout">
  1345. <xsl:copy-of select="$callout"/>
  1346. </fo:inline>
  1347. </fo:block>
  1348. </fo:list-item-label>
  1349. <fo:list-item-body start-indent="body-start()" text-align="start">
  1350. <fo:block>
  1351. <xsl:apply-templates/>
  1352. </fo:block>
  1353. </fo:list-item-body>
  1354. </fo:list-item>
  1355. </fo:list-block>
  1356. </fo:footnote-body>
  1357. </fo:footnote>
  1358. </xsl:template>
  1359. <xsl:template match="*[contains(@class,' topic/fn ')]" mode="callout">
  1360. <xsl:choose>
  1361. <xsl:when test="@callout">
  1362. <xsl:value-of select="@callout"/>
  1363. </xsl:when>
  1364. <xsl:otherwise>
  1365. <xsl:value-of select="count(key('enumerableByClass', 'topic/fn')[. &lt;&lt; current()]) + 1"/>
  1366. </xsl:otherwise>
  1367. </xsl:choose>
  1368. </xsl:template>
  1369. <xsl:template match="*[contains(@class,' topic/indexterm ')]">
  1370. <xsl:apply-templates/>
  1371. </xsl:template>
  1372. <xsl:template match="*[contains(@class,' topic/indextermref ')]">
  1373. <fo:inline xsl:use-attribute-sets="indextermref">
  1374. <xsl:call-template name="commonattributes"/>
  1375. <xsl:apply-templates/>
  1376. </fo:inline>
  1377. </xsl:template>
  1378. <xsl:template match="*[contains(@class,' topic/cite ')]">
  1379. <xsl:apply-templates select="." mode="inlineTextOptionalKeyref">
  1380. <xsl:with-param name="copyAttributes" as="element()"><wrapper xsl:use-attribute-sets="cite"/></xsl:with-param>
  1381. </xsl:apply-templates>
  1382. </xsl:template>
  1383. <xsl:template match="@platform | @product | @audience | @otherprops | @importance | @rev | @status"/>
  1384. <!-- Template to copy original IDs -->
  1385. <xsl:template match="@id">
  1386. <xsl:attribute name="id">
  1387. <xsl:value-of select="."/>
  1388. </xsl:attribute>
  1389. </xsl:template>
  1390. <!-- Templates to reprocess reused content while dropping IDs from reuse context -->
  1391. <xsl:template match="@id" mode="dropCopiedIds"/>
  1392. <xsl:template match="*|@*|text()" mode="dropCopiedIds">
  1393. <xsl:copy>
  1394. <xsl:apply-templates select="@*|*|text()" mode="dropCopiedIds"/>
  1395. </xsl:copy>
  1396. </xsl:template>
  1397. <!-- Process common attributes -->
  1398. <xsl:template name="commonattributes">
  1399. <xsl:apply-templates select="@id"/>
  1400. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')] |
  1401. *[contains(@class,' ditaot-d/ditaval-endprop ')]" mode="flag-attributes"/>
  1402. <xsl:apply-templates select="@outputclass"/>
  1403. </xsl:template>
  1404. <xsl:template match="@outputclass"/>
  1405. <!-- Get ID for an element, generate ID if not explicitly set. -->
  1406. <xsl:template name="get-id">
  1407. <xsl:param name="element" select="."/>
  1408. <xsl:choose>
  1409. <xsl:when test="$element/@id">
  1410. <xsl:value-of select="$element/@id"/>
  1411. </xsl:when>
  1412. <xsl:otherwise>
  1413. <xsl:value-of select="generate-id($element)"/>
  1414. </xsl:otherwise>
  1415. </xsl:choose>
  1416. </xsl:template>
  1417. <!-- Generate TOC ID -->
  1418. <xsl:template name="generate-toc-id">
  1419. <xsl:param name="element" select="."/>
  1420. <xsl:value-of select="concat('_OPENTOPIC_TOC_PROCESSING_', generate-id($element))"/>
  1421. </xsl:template>
  1422. <xsl:template match="*[contains(@class, ' topic/data ')]"/>
  1423. <xsl:template match="*[contains(@class, ' topic/data ')]" mode="insert-text"/>
  1424. <xsl:template match="*[contains(@class, ' topic/data-about ')]"/>
  1425. </xsl:stylesheet>