topic.xsl 121 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. This file is part of the DITA Open Toolkit project.
  4. See the accompanying LICENSE file for applicable license.
  5. -->
  6. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  7. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  8. xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
  9. xmlns:dita2html="http://dita-ot.sourceforge.net/ns/200801/dita2html"
  10. xmlns:ditamsg="http://dita-ot.sourceforge.net/ns/200704/ditamsg"
  11. version="2.0"
  12. exclude-result-prefixes="xs dita-ot dita2html ditamsg">
  13. <xsl:include href="plugin:org.dita.html5:xsl/get-meta.xsl"/>
  14. <xsl:include href="plugin:org.dita.html5:xsl/rel-links.xsl"/>
  15. <!-- =========== DEFAULT VALUES FOR EXTERNALLY MODIFIABLE PARAMETERS =========== -->
  16. <!-- /CSS = default CSS filename parameter ('')-->
  17. <xsl:param name="CSS"/>
  18. <xsl:param name="dita-css" select="'commonltr.css'"/> <!-- left to right languages -->
  19. <xsl:param name="bidi-dita-css" select="'commonrtl.css'"/> <!-- bidirectional languages -->
  20. <!-- default CSS path parameter (null)-->
  21. <xsl:param name="CSSPATH"/>
  22. <!-- Preserve DITA class ancestry in XHTML output; values are 'yes' or 'no' -->
  23. <xsl:param name="PRESERVE-DITA-CLASS" select="'yes'"/>
  24. <!-- the file name containing XHTML to be placed in the HEAD area
  25. (file name and extension only - no path). -->
  26. <xsl:param name="HDF"/>
  27. <!-- the file name containing XHTML to be placed in the BODY running-heading area
  28. (file name and extension only - no path). -->
  29. <xsl:param name="HDR"/>
  30. <!-- the file name containing XHTML to be placed in the BODY running-footing area
  31. (file name and extension only - no path). -->
  32. <xsl:param name="FTR"/>
  33. <!-- default "output artwork filenames" processing parameter ('no')-->
  34. <xsl:param name="ARTLBL" select="'no'"/><!-- "no" and "yes" are valid values; non-'yes' is ignored -->
  35. <!-- default "hide draft & cleanup content" processing parameter ('no' = hide them)-->
  36. <xsl:param name="DRAFT" select="'no'"/><!-- "no" and "yes" are valid values; non-'yes' is ignored -->
  37. <!-- default "hide index entries" processing parameter ('no' = hide them)-->
  38. <xsl:param name="INDEXSHOW" select="'no'"/><!-- "no" and "yes" are valid values; non-'yes' is ignored -->
  39. <!-- the year for the copyright -->
  40. <xsl:param name="YEAR" select="format-date(current-date(), '[Y]')"/>
  41. <!-- default "output extension" processing parameter ('.html')-->
  42. <xsl:param name="OUTEXT" select="'.html'"/><!-- "htm" and "html" are valid values -->
  43. <!-- the working directory that contains the document being transformed.
  44. Needed as a directory prefix for the @conref "document()" function calls.
  45. default is '../doc/')-->
  46. <xsl:param name="WORKDIR">
  47. <xsl:apply-templates select="/processing-instruction('workdir-uri')[1]" mode="get-work-dir"/>
  48. </xsl:param>
  49. <!-- the path back to the project. Used for c.gif, delta.gif, css to allow user's to have
  50. these files in 1 location. -->
  51. <xsl:param name="PATH2PROJ">
  52. <xsl:apply-templates select="/processing-instruction('path2project-uri')[1]" mode="get-path2project"/>
  53. </xsl:param>
  54. <!-- the file name (file name and extension only - no path) of the document being transformed.
  55. Needed to help with debugging.
  56. default is 'myfile.xml')-->
  57. <xsl:param name="FILENAME"/>
  58. <xsl:param name="FILEDIR"/>
  59. <xsl:param name="CURRENTFILE" select="concat($FILEDIR, '/', $FILENAME)"/>
  60. <!-- the file name containing filter/flagging/revision information
  61. (file name and extension only - no path). - testfile: revflag.dita -->
  62. <xsl:param name="FILTERFILE"/>
  63. <!-- Switch to enable or disable the generation of default meta message in html header -->
  64. <xsl:param name="genDefMeta" select="'no'"/>
  65. <xsl:param name="BASEDIR"/>
  66. <xsl:param name="OUTPUTDIR"/>
  67. <!-- =========== "GLOBAL" DECLARATIONS (see 35) =========== -->
  68. <!-- The document tree of filterfile returned by document($FILTERFILE,/)-->
  69. <xsl:variable name="FILTERFILEURL">
  70. <xsl:choose>
  71. <xsl:when test="not($FILTERFILE)"/> <!-- If no filterfile leave empty -->
  72. <xsl:when test="starts-with($FILTERFILE, 'file:')">
  73. <xsl:value-of select="$FILTERFILE"/>
  74. </xsl:when>
  75. <xsl:otherwise>
  76. <xsl:choose>
  77. <xsl:when test="starts-with($FILTERFILE, '/')">
  78. <xsl:text>file://</xsl:text><xsl:value-of select="$FILTERFILE"/>
  79. </xsl:when>
  80. <xsl:otherwise>
  81. <xsl:text>file:/</xsl:text><xsl:value-of select="$FILTERFILE"/>
  82. </xsl:otherwise>
  83. </xsl:choose>
  84. </xsl:otherwise>
  85. </xsl:choose>
  86. </xsl:variable>
  87. <xsl:variable name="FILTERDOC"
  88. select="if (string-length($FILTERFILEURL) > 0)
  89. then document($FILTERFILEURL, /)
  90. else ()"/>
  91. <xsl:variable name="passthrough-attrs" as="element()*"
  92. select="$FILTERDOC/val/prop[@action = 'passthrough']"/>
  93. <!--Check the file Url Definition of HDF HDR FTR-->
  94. <xsl:variable name="HDFFILE">
  95. <xsl:choose>
  96. <xsl:when test="not($HDF)"/> <!-- If no filterfile leave empty -->
  97. <xsl:when test="starts-with($HDF, 'file:')">
  98. <xsl:value-of select="$HDF"/>
  99. </xsl:when>
  100. <xsl:otherwise>
  101. <xsl:choose>
  102. <xsl:when test="starts-with($HDF, '/')">
  103. <xsl:text>file://</xsl:text><xsl:value-of select="$HDF"/>
  104. </xsl:when>
  105. <xsl:otherwise>
  106. <xsl:text>file:/</xsl:text><xsl:value-of select="$HDF"/>
  107. </xsl:otherwise>
  108. </xsl:choose>
  109. </xsl:otherwise>
  110. </xsl:choose>
  111. </xsl:variable>
  112. <xsl:variable name="HDRFILE">
  113. <xsl:choose>
  114. <xsl:when test="not($HDR)"/> <!-- If no filterfile leave empty -->
  115. <xsl:when test="starts-with($HDR, 'file:')">
  116. <xsl:value-of select="$HDR"/>
  117. </xsl:when>
  118. <xsl:otherwise>
  119. <xsl:choose>
  120. <xsl:when test="starts-with($HDR, '/')">
  121. <xsl:text>file://</xsl:text><xsl:value-of select="$HDR"/>
  122. </xsl:when>
  123. <xsl:otherwise>
  124. <xsl:text>file:/</xsl:text><xsl:value-of select="$HDR"/>
  125. </xsl:otherwise>
  126. </xsl:choose>
  127. </xsl:otherwise>
  128. </xsl:choose>
  129. </xsl:variable>
  130. <xsl:variable name="FTRFILE">
  131. <xsl:choose>
  132. <xsl:when test="not($FTR)"/> <!-- If no filterfile leave empty -->
  133. <xsl:when test="starts-with($FTR, 'file:')">
  134. <xsl:value-of select="$FTR"/>
  135. </xsl:when>
  136. <xsl:otherwise>
  137. <xsl:choose>
  138. <xsl:when test="starts-with($FTR, '/')">
  139. <xsl:text>file://</xsl:text><xsl:value-of select="$FTR"/>
  140. </xsl:when>
  141. <xsl:otherwise>
  142. <xsl:text>file:/</xsl:text><xsl:value-of select="$FTR"/>
  143. </xsl:otherwise>
  144. </xsl:choose>
  145. </xsl:otherwise>
  146. </xsl:choose>
  147. </xsl:variable>
  148. <!-- Define the error message prefix identifier -->
  149. <!-- Deprecated since 2.3 -->
  150. <xsl:variable name="msgprefix">DOTX</xsl:variable>
  151. <!-- these elements are never processed in a conventional presentation. can be overridden. -->
  152. <xsl:template match="*[contains(@class, ' topic/no-topic-nesting ')]"/>
  153. <!-- =========== ROOT RULE (just fall through; no side effects for new delivery contexts =========== -->
  154. <xsl:template match="/">
  155. <xsl:apply-templates/>
  156. </xsl:template>
  157. <!-- =========== NESTED TOPIC RULES =========== -->
  158. <!-- This first template rule generates the outer-level shell for a delivery context.
  159. In an override stylesheet, the same call to "chapter-setup" must be issued to
  160. maintain the consistency of overall look'n'feel of the output HTML.
  161. Match on the first DITA element -or- the first root 'topic' element. -->
  162. <xsl:template match="/dita | *[contains(@class, ' topic/topic ')]">
  163. <xsl:choose>
  164. <xsl:when test="not(parent::*)">
  165. <xsl:apply-templates select="." mode="root_element"/>
  166. </xsl:when>
  167. <xsl:otherwise>
  168. <xsl:apply-templates select="." mode="child.topic"/>
  169. </xsl:otherwise>
  170. </xsl:choose>
  171. </xsl:template>
  172. <!-- Matches /dita or a root topic -->
  173. <xsl:template match="*" mode="root_element" name="root_element">
  174. <xsl:call-template name="chapter-setup"/>
  175. </xsl:template>
  176. <!-- child topics get a div wrapper and fall through -->
  177. <xsl:template match="*[contains(@class, ' topic/topic ')]" mode="child.topic" name="child.topic">
  178. <xsl:param name="nestlevel" as="xs:integer">
  179. <xsl:choose>
  180. <!-- Limit depth for historical reasons, could allow any depth. Previously limit was 5. -->
  181. <xsl:when test="count(ancestor::*[contains(@class, ' topic/topic ')]) > 9">9</xsl:when>
  182. <xsl:otherwise><xsl:sequence select="count(ancestor::*[contains(@class, ' topic/topic ')])"/></xsl:otherwise>
  183. </xsl:choose>
  184. </xsl:param>
  185. <article class="nested{$nestlevel}">
  186. <xsl:attribute name="aria-labelledby">
  187. <xsl:apply-templates select="*[contains(@class,' topic/title ')]" mode="return-aria-label-id"/>
  188. </xsl:attribute>
  189. <xsl:call-template name="gen-topic">
  190. <xsl:with-param name="nestlevel" select="$nestlevel"/>
  191. </xsl:call-template>
  192. </article>
  193. </xsl:template>
  194. <xsl:template name="gen-topic">
  195. <xsl:param name="nestlevel" as="xs:integer">
  196. <xsl:choose>
  197. <!-- Limit depth for historical reasons, could allow any depth. Previously limit was 5. -->
  198. <xsl:when test="count(ancestor::*[contains(@class, ' topic/topic ')]) > 9">9</xsl:when>
  199. <xsl:otherwise><xsl:sequence select="count(ancestor::*[contains(@class, ' topic/topic ')])"/></xsl:otherwise>
  200. </xsl:choose>
  201. </xsl:param>
  202. <xsl:choose>
  203. <xsl:when test="parent::dita and not(preceding-sibling::*)">
  204. <!-- Do not reset xml:lang if it is already set on <html> -->
  205. <!-- Moved outputclass to the body tag -->
  206. <!-- Keep ditaval based styling at this point (replace DITA-OT 1.6 and earlier call to gen-style) -->
  207. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]/@outputclass" mode="add-ditaval-style"/>
  208. </xsl:when>
  209. <xsl:otherwise>
  210. <xsl:call-template name="commonattributes">
  211. <xsl:with-param name="default-output-class" select="concat('nested', $nestlevel)"/>
  212. </xsl:call-template>
  213. </xsl:otherwise>
  214. </xsl:choose>
  215. <xsl:call-template name="gen-toc-id"/>
  216. <xsl:call-template name="setidaname"/>
  217. <xsl:apply-templates/>
  218. </xsl:template>
  219. <!-- NESTED TOPIC TITLES (sensitive to nesting depth, but are still processed for contained markup) -->
  220. <!-- 1st level - topic/title -->
  221. <!-- Condensed topic title into single template without priorities; use $headinglevel to set heading.
  222. If desired, somebody could pass in the value to manually set the heading level -->
  223. <xsl:template match="*[contains(@class, ' topic/topic ')]/*[contains(@class, ' topic/title ')]">
  224. <xsl:param name="headinglevel" as="xs:integer">
  225. <xsl:choose>
  226. <xsl:when test="count(ancestor::*[contains(@class, ' topic/topic ')]) > 6">6</xsl:when>
  227. <xsl:otherwise><xsl:sequence select="count(ancestor::*[contains(@class, ' topic/topic ')])"/></xsl:otherwise>
  228. </xsl:choose>
  229. </xsl:param>
  230. <xsl:element name="h{$headinglevel}">
  231. <xsl:attribute name="class">topictitle<xsl:value-of select="$headinglevel"/></xsl:attribute>
  232. <xsl:call-template name="commonattributes">
  233. <xsl:with-param name="default-output-class">topictitle<xsl:value-of select="$headinglevel"/></xsl:with-param>
  234. </xsl:call-template>
  235. <xsl:attribute name="id"><xsl:apply-templates select="." mode="return-aria-label-id"/></xsl:attribute>
  236. <xsl:apply-templates/>
  237. </xsl:element>
  238. </xsl:template>
  239. <xsl:template match="*[contains(@class, ' topic/topic ')]/*[contains(@class, ' topic/title ')]" mode="return-aria-label-id">
  240. <xsl:choose>
  241. <xsl:when test="@id">
  242. <xsl:sequence select="dita-ot:generate-id(parent::*/@id, @id)"/>
  243. </xsl:when>
  244. <xsl:otherwise>
  245. <xsl:text>ariaid-title</xsl:text>
  246. <xsl:number count="*[contains(@class, ' topic/title ')][parent::*[contains(@class,' topic/topic ')]]" level="any"/>
  247. </xsl:otherwise>
  248. </xsl:choose>
  249. </xsl:template>
  250. <!-- Hide titlealts - they need to get pulled into the proper places -->
  251. <xsl:template match="*[contains(@class, ' topic/titlealts ')]"/>
  252. <!-- =========== BODY/SECTION (not sensitive to nesting depth) =========== -->
  253. <xsl:template match="*[contains(@class, ' topic/body ')]" name="topic.body">
  254. <div>
  255. <xsl:call-template name="commonattributes"/>
  256. <xsl:call-template name="setidaname"/>
  257. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
  258. <!-- here, you can generate a toc based on what's a child of body -->
  259. <!--xsl:call-template name="gen-sect-ptoc"/--><!-- Works; not always wanted, though; could add a param to enable it.-->
  260. <!-- Insert prev/next links. since they need to be scoped by who they're 'pooled' with, apply-templates in 'hierarchylink' mode to linkpools (or related-links itself) when they have children that have any of the following characteristics:
  261. - role=ancestor (used for breadcrumb)
  262. - role=next or role=previous (used for left-arrow and right-arrow before the breadcrumb)
  263. - importance=required AND no role, or role=sibling or role=friend or role=previous or role=cousin (to generate prerequisite links)
  264. - we can't just assume that links with importance=required are prerequisites, since a topic with eg role='next' might be required, while at the same time by definition not a prerequisite -->
  265. <!-- Added for DITA 1.1 "Shortdesc proposal" -->
  266. <!-- get the abstract para -->
  267. <xsl:apply-templates select="preceding-sibling::*[contains(@class, ' topic/abstract ')]" mode="outofline"/>
  268. <!-- get the shortdesc para -->
  269. <xsl:apply-templates select="preceding-sibling::*[contains(@class, ' topic/shortdesc ')]" mode="outofline"/>
  270. <!-- Insert pre-req links - after shortdesc - unless there is a prereq section about -->
  271. <xsl:apply-templates select="following-sibling::*[contains(@class, ' topic/related-links ')]" mode="prereqs"/>
  272. <xsl:apply-templates/>
  273. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  274. </div>
  275. </xsl:template>
  276. <!-- Added for DITA 1.1 "Shortdesc proposal" -->
  277. <xsl:template match="*[contains(@class, ' topic/abstract ')]">
  278. <xsl:if test="not(following-sibling::*[contains(@class, ' topic/body ')])">
  279. <xsl:apply-templates select="." mode="outofline"/>
  280. <xsl:apply-templates select="following-sibling::*[contains(@class, ' topic/related-links ')]" mode="prereqs"/>
  281. </xsl:if>
  282. </xsl:template>
  283. <!-- Added for DITA 1.1 "Shortdesc proposal" -->
  284. <!-- called abstract processing - para at start of topic -->
  285. <xsl:template match="*[contains(@class, ' topic/abstract ')]" mode="outofline">
  286. <div>
  287. <xsl:call-template name="commonattributes"/>
  288. <xsl:apply-templates/>
  289. </div>
  290. </xsl:template>
  291. <!-- Updated for DITA 1.1 "Shortdesc proposal" -->
  292. <!-- Added for SF 1363055: Shortdesc disappears when optional body is removed -->
  293. <xsl:template match="*[contains(@class, ' topic/shortdesc ')]">
  294. <xsl:choose>
  295. <xsl:when test="parent::*[contains(@class, ' topic/abstract ')]">
  296. <xsl:apply-templates select="." mode="outofline.abstract"/>
  297. </xsl:when>
  298. <xsl:when test="not(following-sibling::*[contains(@class, ' topic/body ')])">
  299. <xsl:apply-templates select="." mode="outofline"/>
  300. <xsl:apply-templates select="following-sibling::*[contains(@class, ' topic/related-links ')]" mode="prereqs"/>
  301. </xsl:when>
  302. <xsl:otherwise></xsl:otherwise>
  303. </xsl:choose>
  304. </xsl:template>
  305. <!-- called shortdesc processing when it is in abstract -->
  306. <xsl:template match="*[contains(@class, ' topic/shortdesc ')]" mode="outofline.abstract">
  307. <xsl:choose>
  308. <xsl:when test="exists(preceding-sibling::*[dita-ot:is-block(.)] | following-sibling::*[dita-ot:is-block(.)])">
  309. <p>
  310. <xsl:call-template name="commonattributes"/>
  311. <xsl:apply-templates/>
  312. </p>
  313. </xsl:when>
  314. <xsl:otherwise>
  315. <xsl:if test="preceding-sibling::* | preceding-sibling::text()">
  316. <xsl:text> </xsl:text>
  317. </xsl:if>
  318. <span>
  319. <xsl:call-template name="commonattributes"/>
  320. <xsl:apply-templates/>
  321. </span>
  322. </xsl:otherwise>
  323. </xsl:choose>
  324. </xsl:template>
  325. <!-- called shortdesc processing - para at start of topic -->
  326. <xsl:template match="*[contains(@class, ' topic/shortdesc ')]" mode="outofline">
  327. <p>
  328. <xsl:call-template name="commonattributes"/>
  329. <xsl:apply-templates/>
  330. </p>
  331. </xsl:template>
  332. <!-- section processor - div with no generated title -->
  333. <xsl:template match="*[contains(@class, ' topic/section ')]" name="topic.section">
  334. <section class="section">
  335. <xsl:call-template name="commonattributes"/>
  336. <xsl:call-template name="gen-toc-id"/>
  337. <xsl:call-template name="setidaname"/>
  338. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
  339. <xsl:apply-templates select="." mode="dita2html:section-heading"/>
  340. <xsl:apply-templates select="*[not(contains(@class, ' topic/title '))] | text() | comment() | processing-instruction()"/>
  341. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  342. </section>
  343. </xsl:template>
  344. <!-- example processor - div with no generated title -->
  345. <xsl:template match="*[contains(@class, ' topic/example ')]" name="topic.example">
  346. <div class="example">
  347. <xsl:call-template name="commonattributes"/>
  348. <xsl:call-template name="gen-toc-id"/>
  349. <xsl:call-template name="setidaname"/>
  350. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
  351. <xsl:apply-templates select="." mode="dita2html:section-heading"/>
  352. <xsl:apply-templates select="*[not(contains(@class, ' topic/title '))] | text() | comment() | processing-instruction()"/>
  353. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  354. </div>
  355. </xsl:template>
  356. <!-- ===================================================================== -->
  357. <!-- =========== BASIC BODY ELEMENTS =========== -->
  358. <xsl:template match="*[contains(@class, ' topic/div ')]">
  359. <div>
  360. <xsl:call-template name="commonattributes"/>
  361. <xsl:call-template name="setid"/>
  362. <xsl:apply-templates/>
  363. </div>
  364. </xsl:template>
  365. <!-- paragraphs -->
  366. <xsl:template match="*[contains(@class, ' topic/p ')]" name="topic.p">
  367. <!-- To ensure XHTML validity, need to determine whether the DITA kids are block elements.
  368. If so, use div_class="p" instead of p -->
  369. <xsl:choose>
  370. <xsl:when test="descendant::*[dita-ot:is-block(.)]">
  371. <div class="p">
  372. <xsl:call-template name="commonattributes"/>
  373. <xsl:call-template name="setid"/>
  374. <xsl:apply-templates/>
  375. </div>
  376. </xsl:when>
  377. <xsl:otherwise>
  378. <p>
  379. <xsl:call-template name="commonattributes"/>
  380. <xsl:call-template name="setid"/>
  381. <xsl:apply-templates/>
  382. </p>
  383. </xsl:otherwise>
  384. </xsl:choose>
  385. </xsl:template>
  386. <!-- Left for users who call this template in an override -->
  387. <xsl:template name="note">
  388. <xsl:apply-templates select="." mode="process.note"/>
  389. </xsl:template>
  390. <!-- RFE 2703335 reduces duplicated code by adding common processing rules.
  391. To override all notes, match the note element's class attribute directly, as in this rule.
  392. To override a single note type, match the class with mode="process.note.(selected-type)"
  393. To override all notes except danger and caution, match the class with mode="process.note.common-processing" -->
  394. <xsl:template match="*[contains(@class, ' topic/note ')]" name="topic.note">
  395. <xsl:call-template name="spec-title"/>
  396. <xsl:choose>
  397. <xsl:when test="@type = 'note'">
  398. <xsl:apply-templates select="." mode="process.note"/>
  399. </xsl:when>
  400. <xsl:when test="@type = 'tip'">
  401. <xsl:apply-templates select="." mode="process.note.tip"/>
  402. </xsl:when>
  403. <xsl:when test="@type = 'fastpath'">
  404. <xsl:apply-templates select="." mode="process.note.fastpath"/>
  405. </xsl:when>
  406. <xsl:when test="@type = 'important'">
  407. <xsl:apply-templates select="." mode="process.note.important"/>
  408. </xsl:when>
  409. <xsl:when test="@type = 'remember'">
  410. <xsl:apply-templates select="." mode="process.note.remember"/>
  411. </xsl:when>
  412. <xsl:when test="@type = 'restriction'">
  413. <xsl:apply-templates select="." mode="process.note.restriction"/>
  414. </xsl:when>
  415. <xsl:when test="@type = 'attention'">
  416. <xsl:apply-templates select="." mode="process.note.attention"/>
  417. </xsl:when>
  418. <xsl:when test="@type = 'caution'">
  419. <xsl:apply-templates select="." mode="process.note.caution"/>
  420. </xsl:when>
  421. <xsl:when test="@type = 'danger'">
  422. <xsl:apply-templates select="." mode="process.note.danger"/>
  423. </xsl:when>
  424. <xsl:when test="@type = 'warning'">
  425. <xsl:apply-templates select="." mode="process.note.warning"/>
  426. </xsl:when>
  427. <xsl:when test="@type = 'trouble'">
  428. <xsl:apply-templates select="." mode="process.note.trouble"/>
  429. </xsl:when>
  430. <xsl:when test="@type = 'other'">
  431. <xsl:apply-templates select="." mode="process.note.other"/>
  432. </xsl:when>
  433. <xsl:otherwise>
  434. <xsl:apply-templates select="." mode="process.note"/>
  435. </xsl:otherwise>
  436. </xsl:choose>
  437. </xsl:template>
  438. <xsl:template match="*" mode="process.note">
  439. <xsl:apply-templates select="." mode="process.note.common-processing">
  440. <!-- Force the type to note, in case new unrecognized values are added
  441. before translations exist (such as Warning) -->
  442. <xsl:with-param name="type" select="'note'"/>
  443. </xsl:apply-templates>
  444. </xsl:template>
  445. <xsl:template match="*" mode="process.note.tip">
  446. <xsl:apply-templates select="." mode="process.note.common-processing"/>
  447. </xsl:template>
  448. <xsl:template match="*" mode="process.note.fastpath">
  449. <xsl:apply-templates select="." mode="process.note.common-processing"/>
  450. </xsl:template>
  451. <xsl:template match="*" mode="process.note.important">
  452. <xsl:apply-templates select="." mode="process.note.common-processing"/>
  453. </xsl:template>
  454. <xsl:template match="*" mode="process.note.remember">
  455. <xsl:apply-templates select="." mode="process.note.common-processing"/>
  456. </xsl:template>
  457. <xsl:template match="*" mode="process.note.restriction">
  458. <xsl:apply-templates select="." mode="process.note.common-processing"/>
  459. </xsl:template>
  460. <xsl:template match="*" mode="process.note.warning">
  461. <xsl:apply-templates select="." mode="process.note.common-processing"/>
  462. </xsl:template>
  463. <xsl:template match="*" mode="process.note.attention">
  464. <xsl:apply-templates select="." mode="process.note.common-processing"/>
  465. </xsl:template>
  466. <xsl:template match="*" mode="process.note.trouble">
  467. <xsl:apply-templates select="." mode="process.note.common-processing"/>
  468. </xsl:template>
  469. <xsl:template match="*" mode="process.note.other">
  470. <xsl:choose>
  471. <xsl:when test="@othertype">
  472. <xsl:apply-templates select="." mode="process.note.common-processing">
  473. <xsl:with-param name="type" select="'note'"/>
  474. <xsl:with-param name="title" select="string(@othertype)"/>
  475. </xsl:apply-templates>
  476. </xsl:when>
  477. <xsl:otherwise>
  478. <xsl:apply-templates select="." mode="process.note.common-processing">
  479. <xsl:with-param name="type" select="'note'"/>
  480. </xsl:apply-templates>
  481. </xsl:otherwise>
  482. </xsl:choose>
  483. </xsl:template>
  484. <!-- long quote (bibliographic association).
  485. @reftitle contains the citation for the excerpt.
  486. With a link if @href is used. -->
  487. <xsl:template match="*[contains(@class, ' topic/lq ')]" name="topic.lq">
  488. <blockquote>
  489. <xsl:call-template name="commonattributes"/>
  490. <xsl:call-template name="setidaname"/>
  491. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
  492. <xsl:apply-templates/>
  493. <xsl:choose>
  494. <xsl:when test="@href">
  495. <br/><div style="text-align:right"><a>
  496. <xsl:attribute name="href">
  497. <xsl:call-template name="href"/>
  498. </xsl:attribute>
  499. <xsl:choose>
  500. <xsl:when test="@type = 'external'">
  501. <xsl:attribute name="target">_blank</xsl:attribute>
  502. </xsl:when>
  503. <xsl:otherwise><!--nop - no target needed for internal or biblio types (OR-should internal force DITA xref-like processing? What is intent? @type is only internal/external/bibliographic) --></xsl:otherwise>
  504. </xsl:choose>
  505. <cite><xsl:choose>
  506. <xsl:when test="@reftitle"><xsl:value-of select="@reftitle"/></xsl:when>
  507. <xsl:otherwise><xsl:value-of select="@href"/></xsl:otherwise>
  508. </xsl:choose></cite></a></div>
  509. </xsl:when>
  510. <xsl:when test="@reftitle"> <!-- Insert citation text -->
  511. <br/><div style="text-align:right"><cite><xsl:value-of select="@reftitle"/></cite></div>
  512. </xsl:when>
  513. <xsl:otherwise><!--nop - do nothing--></xsl:otherwise>
  514. </xsl:choose>
  515. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  516. </blockquote>
  517. </xsl:template>
  518. <!-- =========== SINGLE PART LISTS =========== -->
  519. <!-- Ignore empty lists with all content filtered out -->
  520. <xsl:template match="*[contains(@class, ' topic/ol ')][empty(*[contains(@class,' topic/li ')])]" priority="10"/>
  521. <xsl:template match="*[contains(@class, ' topic/ul ')][empty(*[contains(@class,' topic/li ')])]" priority="10"/>
  522. <xsl:template match="*[contains(@class, ' topic/sl ')][empty(*[contains(@class,' topic/sli ')])]" priority="10"/>
  523. <!-- Unordered List -->
  524. <!-- handle all levels thru browser processing -->
  525. <xsl:template match="*[contains(@class, ' topic/ul ')]" name="topic.ul">
  526. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
  527. <xsl:call-template name="setaname"/>
  528. <ul>
  529. <xsl:call-template name="commonattributes"/>
  530. <xsl:apply-templates select="@compact"/>
  531. <xsl:call-template name="setid"/>
  532. <xsl:apply-templates/>
  533. </ul>
  534. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  535. </xsl:template>
  536. <!-- Simple List -->
  537. <!-- handle all levels thru browser processing -->
  538. <xsl:template match="*[contains(@class, ' topic/sl ')]" name="topic.sl">
  539. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
  540. <xsl:call-template name="setaname"/>
  541. <ul class="simple">
  542. <xsl:call-template name="commonattributes">
  543. <xsl:with-param name="default-output-class" select="'simple'"/>
  544. </xsl:call-template>
  545. <xsl:apply-templates select="@compact"/>
  546. <xsl:call-template name="setid"/>
  547. <xsl:apply-templates/>
  548. </ul>
  549. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  550. </xsl:template>
  551. <!-- Ordered List - 1st level - Handle levels 1 to 9 thru OL-TYPE attribution -->
  552. <!-- Updated to use a single template, use count and mod to set the list type -->
  553. <xsl:template match="*[contains(@class, ' topic/ol ')]" name="topic.ol">
  554. <xsl:variable name="olcount" select="count(ancestor-or-self::*[contains(@class, ' topic/ol ')])"/>
  555. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
  556. <xsl:call-template name="setaname"/>
  557. <ol>
  558. <xsl:call-template name="commonattributes"/>
  559. <xsl:apply-templates select="@compact"/>
  560. <xsl:choose>
  561. <xsl:when test="$olcount mod 3 = 1"/>
  562. <xsl:when test="$olcount mod 3 = 2"><xsl:attribute name="type">a</xsl:attribute></xsl:when>
  563. <xsl:otherwise><xsl:attribute name="type">i</xsl:attribute></xsl:otherwise>
  564. </xsl:choose>
  565. <xsl:call-template name="setid"/>
  566. <xsl:apply-templates/>
  567. </ol>
  568. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  569. </xsl:template>
  570. <!-- list item -->
  571. <xsl:template match="*[contains(@class, ' topic/li ')]" name="topic.li">
  572. <li>
  573. <xsl:choose>
  574. <xsl:when test="parent::*/@compact = 'no'">
  575. <xsl:attribute name="class">liexpand</xsl:attribute>
  576. <!-- handle non-compact list items -->
  577. <xsl:call-template name="commonattributes">
  578. <xsl:with-param name="default-output-class" select="'liexpand'"/>
  579. </xsl:call-template>
  580. </xsl:when>
  581. <xsl:otherwise>
  582. <xsl:call-template name="commonattributes"/>
  583. </xsl:otherwise>
  584. </xsl:choose>
  585. <xsl:call-template name="setidaname"/>
  586. <xsl:apply-templates/>
  587. </li>
  588. </xsl:template>
  589. <!-- simple list item -->
  590. <xsl:template match="*[contains(@class, ' topic/sli ')]" name="topic.sli">
  591. <li>
  592. <xsl:choose>
  593. <xsl:when test="parent::*/@compact = 'no'">
  594. <xsl:attribute name="class">sliexpand</xsl:attribute>
  595. <!-- handle non-compact list items -->
  596. <xsl:call-template name="commonattributes">
  597. <xsl:with-param name="default-output-class" select="'sliexpand'"/>
  598. </xsl:call-template>
  599. </xsl:when>
  600. <xsl:otherwise>
  601. <xsl:call-template name="commonattributes"/>
  602. </xsl:otherwise>
  603. </xsl:choose>
  604. <xsl:call-template name="commonattributes"/>
  605. <xsl:call-template name="setidaname"/>
  606. <xsl:apply-templates/>
  607. </li>
  608. </xsl:template>
  609. <!-- list item section is like li/lq but without presentation (indent) -->
  610. <xsl:template match="*[contains(@class, ' topic/itemgroup ')]" name="topic.itemgroup">
  611. <!-- insert a space before all but the first itemgroups in a LI -->
  612. <xsl:variable name="itemgroupcount"><xsl:number count="*[contains(@class, ' topic/itemgroup ')]"/></xsl:variable>
  613. <xsl:if test="$itemgroupcount > 1">
  614. <xsl:text> </xsl:text>
  615. </xsl:if>
  616. <!-- DITA-OT 1.6 and earlier created a span/font tag when active revs; otherwise, no wrapper.
  617. Maintain that for now, though may want to update in the future to keep a wrapper in all cases.
  618. Considering using div instead of span, with a default inline CSS style. -->
  619. <xsl:choose>
  620. <xsl:when test="*[contains(@class, ' ditaot-d/ditaval-startprop ')]/revprop |
  621. *[contains(@class, ' ditaot-d/ditaval-startprop ')]/@outputclass">
  622. <span>
  623. <xsl:call-template name="commonattributes"/>
  624. <xsl:apply-templates/>
  625. </span>
  626. </xsl:when>
  627. <xsl:otherwise>
  628. <xsl:apply-templates/>
  629. </xsl:otherwise>
  630. </xsl:choose>
  631. </xsl:template>
  632. <!-- =========== DEFINITION LIST =========== -->
  633. <!-- DL -->
  634. <xsl:template match="*[contains(@class,' topic/dl ')][empty(*[contains(@class,' topic/dlentry ')])]" priority="10"/>
  635. <xsl:template match="*[contains(@class, ' topic/dl ')]" name="topic.dl">
  636. <xsl:call-template name="setaname"/>
  637. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
  638. <dl>
  639. <!-- handle DL compacting - default=yes -->
  640. <xsl:if test="@compact = 'no'">
  641. <xsl:attribute name="class">dlexpand</xsl:attribute>
  642. </xsl:if>
  643. <xsl:call-template name="commonattributes"/>
  644. <xsl:apply-templates select="@compact"/>
  645. <xsl:call-template name="setid"/>
  646. <xsl:apply-templates/>
  647. </dl>
  648. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  649. </xsl:template>
  650. <!-- DL entry -->
  651. <xsl:template match="*[contains(@class, ' topic/dlentry ')]" name="topic.dlentry">
  652. <xsl:apply-templates/>
  653. </xsl:template>
  654. <!-- SF Patch 2185423: condensed code so that dt processing is not repeated for keyref or when $dtcount!=1
  655. Code could be reduced further by compressing the flagging templates. -->
  656. <xsl:template match="*[contains(@class, ' topic/dt ')]" mode="output-dt">
  657. <xsl:variable name="is-first-dt" select="empty(preceding-sibling::*[contains(@class, ' topic/dt ')])"/>
  658. <xsl:variable name="dt-class">
  659. <xsl:choose>
  660. <!-- handle non-compact list items -->
  661. <xsl:when test="$is-first-dt and ../../@compact = 'no'">dltermexpand</xsl:when>
  662. <xsl:otherwise>dlterm</xsl:otherwise>
  663. </xsl:choose>
  664. </xsl:variable>
  665. <dt>
  666. <!-- Get xml:lang and ditaval styling from DLENTRY, then override with local -->
  667. <xsl:apply-templates select="../@xml:lang"/>
  668. <xsl:apply-templates select="../*[contains(@class, ' ditaot-d/ditaval-startprop ')]/@outputclass" mode="add-ditaval-style"/>
  669. <xsl:for-each select="..">
  670. <xsl:call-template name="commonattributes"/>
  671. </xsl:for-each>
  672. <xsl:call-template name="commonattributes">
  673. <xsl:with-param name="default-output-class" select="$dt-class"/>
  674. </xsl:call-template>
  675. <!-- handle ID on a DLENTRY -->
  676. <xsl:choose>
  677. <xsl:when test="$is-first-dt and exists(../@id) and exists(@id)">
  678. <xsl:call-template name="setidaname"/>
  679. <a id="{dita-ot:get-prefixed-id(.., ../@id)}"/>
  680. </xsl:when>
  681. <xsl:when test="$is-first-dt and exists(../@id) and empty(@id)">
  682. <xsl:for-each select="..">
  683. <xsl:call-template name="setidaname"/>
  684. </xsl:for-each>
  685. </xsl:when>
  686. <xsl:otherwise>
  687. <xsl:call-template name="setidaname"/>
  688. </xsl:otherwise>
  689. </xsl:choose>
  690. <!-- Use flags from parent dlentry, if present -->
  691. <xsl:apply-templates select="../*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
  692. <xsl:apply-templates/>
  693. <xsl:apply-templates select="../*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  694. </dt>
  695. </xsl:template>
  696. <!-- DL term -->
  697. <xsl:template match="*[contains(@class, ' topic/dt ')]" name="topic.dt">
  698. <xsl:choose>
  699. <xsl:when test="@keyref and @href">
  700. <a>
  701. <xsl:apply-templates select="." mode="add-linking-attributes"/>
  702. <xsl:apply-templates select="." mode="output-dt"/>
  703. </a>
  704. </xsl:when>
  705. <xsl:otherwise>
  706. <xsl:apply-templates select="." mode="output-dt"/>
  707. </xsl:otherwise>
  708. </xsl:choose>
  709. </xsl:template>
  710. <!-- DL description -->
  711. <xsl:template match="*[contains(@class, ' topic/dd ')]" name="topic.dd">
  712. <xsl:variable name="is-first-dd" select="empty(preceding-sibling::*[contains(@class, ' topic/dd ')])"/>
  713. <dd>
  714. <xsl:for-each select="..">
  715. <xsl:call-template name="commonattributes"/>
  716. </xsl:for-each>
  717. <xsl:call-template name="commonattributes">
  718. <xsl:with-param name="default-output-class">
  719. <xsl:if test="not($is-first-dd)"> <!-- para space before 2 thru N -->
  720. <xsl:text>ddexpand</xsl:text>
  721. </xsl:if>
  722. </xsl:with-param>
  723. </xsl:call-template>
  724. <xsl:call-template name="setidaname"/>
  725. <xsl:apply-templates select="../*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
  726. <xsl:apply-templates/>
  727. <xsl:apply-templates select="../*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  728. </dd>
  729. </xsl:template>
  730. <!-- DL heading -->
  731. <xsl:template match="*[contains(@class, ' topic/dlhead ')]" name="topic.dlhead">
  732. <xsl:apply-templates/>
  733. </xsl:template>
  734. <!-- DL heading, term -->
  735. <xsl:template match="*[contains(@class, ' topic/dthd ')]" name="topic.dthd">
  736. <dt>
  737. <!-- Get ditaval style and xml:lang from DLHEAD, then override with local -->
  738. <xsl:apply-templates select="../*[contains(@class, ' ditaot-d/ditaval-startprop ')]/@outputclass" mode="add-ditaval-style"/>
  739. <xsl:apply-templates select="../@xml:lang"/>
  740. <xsl:call-template name="commonattributes"/>
  741. <xsl:call-template name="setidaname"/>
  742. <xsl:apply-templates select="../*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
  743. <strong>
  744. <xsl:apply-templates/>
  745. </strong>
  746. <xsl:apply-templates select="../*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  747. </dt>
  748. </xsl:template>
  749. <!-- DL heading, description -->
  750. <xsl:template match="*[contains(@class, ' topic/ddhd ')]" name="topic.ddhd">
  751. <dd>
  752. <!-- Get ditaval style and xml:lang from DLHEAD, then override with local -->
  753. <xsl:apply-templates select="../*[contains(@class, ' ditaot-d/ditaval-startprop ')]/@outputclass" mode="add-ditaval-style"/>
  754. <xsl:apply-templates select="../@xml:lang"/>
  755. <xsl:call-template name="commonattributes"/>
  756. <xsl:call-template name="setidaname"/>
  757. <xsl:apply-templates select="../*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
  758. <strong>
  759. <xsl:apply-templates/>
  760. </strong>
  761. <xsl:apply-templates select="../*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  762. </dd>
  763. </xsl:template>
  764. <!-- =========== PHRASES =========== -->
  765. <!-- phrase presentational style - have to use a low priority otherwise topic/ph always wins -->
  766. <!-- should not need priority, default is low enough -->
  767. <xsl:template match="*[contains(@class, ' topic/ph ')]" name="topic.ph">
  768. <xsl:choose>
  769. <xsl:when test="@keyref and @href">
  770. <xsl:apply-templates select="." mode="turning-to-link">
  771. <xsl:with-param name="type" select="'ph'"/>
  772. </xsl:apply-templates>
  773. </xsl:when>
  774. <xsl:otherwise>
  775. <span>
  776. <xsl:call-template name="commonattributes"/>
  777. <xsl:call-template name="setidaname"/>
  778. <xsl:apply-templates/>
  779. </span>
  780. </xsl:otherwise>
  781. </xsl:choose>
  782. </xsl:template>
  783. <!-- keyword presentational style - have to use priority else topic/keyword always wins -->
  784. <!-- should not need priority, default is low enough -->
  785. <xsl:template match="*[contains(@class, ' topic/keyword ')]" name="topic.keyword">
  786. <xsl:choose>
  787. <xsl:when test="@keyref and @href">
  788. <xsl:apply-templates select="." mode="turning-to-link">
  789. <xsl:with-param name="type" select="'keyword'"/>
  790. </xsl:apply-templates>
  791. </xsl:when>
  792. <xsl:otherwise>
  793. <span class="keyword">
  794. <xsl:call-template name="commonattributes"/>
  795. <xsl:call-template name="setidaname"/>
  796. <xsl:apply-templates/>
  797. </span>
  798. </xsl:otherwise>
  799. </xsl:choose>
  800. </xsl:template>
  801. <!-- trademarks -->
  802. <!-- prepare a key for each trademark tag -->
  803. <xsl:key name="tm" match="*[contains(@class, ' topic/tm ')]" use="."/>
  804. <!-- process the TM tag -->
  805. <!-- removed priority 1 : should not be needed -->
  806. <xsl:template match="*[contains(@class, ' topic/tm ')]" name="topic.tm">
  807. <xsl:param name="root" select="root()" as="document-node()" tunnel="yes"/>
  808. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
  809. <xsl:apply-templates/> <!-- output the TM content -->
  810. <!-- Test for TM area's language -->
  811. <xsl:variable name="tmtest">
  812. <xsl:apply-templates select="." mode="mark-tm-in-this-area"/>
  813. </xsl:variable>
  814. <!-- If this language should get trademark markers, continue... -->
  815. <xsl:if test="$tmtest = 'tm'">
  816. <xsl:variable name="tmvalue" select="@trademark"/>
  817. <!-- Determine if this is in a title, and should be marked -->
  818. <!-- TODO: should return boolean -->
  819. <xsl:variable name="usetitle">
  820. <xsl:if test="ancestor::*[contains(@class, ' topic/title ')]/parent::*[contains(@class, ' topic/topic ')]">
  821. <xsl:choose>
  822. <!-- Not the first one in a title -->
  823. <xsl:when test="generate-id(.) != generate-id($root/key('tm', .)[1])">skip</xsl:when>
  824. <!-- First one in the topic, BUT it appears in a shortdesc or body -->
  825. <xsl:when test="//*[contains(@class, ' topic/shortdesc ') or contains(@class, ' topic/body ')]//*[contains(@class, ' topic/tm ')][@trademark = $tmvalue]">skip</xsl:when>
  826. <xsl:otherwise>use</xsl:otherwise>
  827. </xsl:choose>
  828. </xsl:if>
  829. </xsl:variable>
  830. <!-- Determine if this is in a body, and should be marked -->
  831. <!-- TODO: should return boolean -->
  832. <xsl:variable name="usebody">
  833. <xsl:choose>
  834. <!-- If in a title or prolog, skip -->
  835. <xsl:when test="ancestor::*[contains(@class, ' topic/title ') or contains(@class, ' topic/prolog ')]/parent::*[contains(@class, ' topic/topic ')]">skip</xsl:when>
  836. <!-- If first in the document, use it -->
  837. <xsl:when test="generate-id(.) = generate-id($root/key('tm', .)[1])">use</xsl:when>
  838. <!-- If there is another before this that is in the body or shortdesc, skip -->
  839. <xsl:when test="preceding::*[contains(@class, ' topic/tm ')][@trademark = $tmvalue][ancestor::*[contains(@class, ' topic/body ') or contains(@class, ' topic/shortdesc ')]]">skip</xsl:when>
  840. <!-- Otherwise, any before this must be in a title or ignored section -->
  841. <xsl:otherwise>use</xsl:otherwise>
  842. </xsl:choose>
  843. </xsl:variable>
  844. <!-- If it should be used in a title or used in the body, output your favorite TM marker based on the attributes -->
  845. <xsl:if test="$usetitle = 'use' or $usebody = 'use'">
  846. <xsl:choose> <!-- ignore @tmtype=service or anything else -->
  847. <xsl:when test="@tmtype = 'tm'">&#x2122;</xsl:when>
  848. <xsl:when test="@tmtype = 'reg'">&#174;</xsl:when>
  849. <xsl:when test="@tmtype = 'service'">&#8480;</xsl:when>
  850. <xsl:otherwise/>
  851. </xsl:choose>
  852. </xsl:if>
  853. </xsl:if>
  854. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  855. </xsl:template>
  856. <!-- TODO: this should return boolean, not "tm" or something else -->
  857. <xsl:template match="*" mode="mark-tm-in-this-area" as="xs:string">
  858. <xsl:text>tm</xsl:text>
  859. </xsl:template>
  860. <!-- phrase "semantic" classes -->
  861. <!-- citations -->
  862. <xsl:template match="*[contains(@class, ' topic/cite ')]" name="topic.cite">
  863. <xsl:choose>
  864. <xsl:when test="@keyref and @href">
  865. <xsl:apply-templates select="." mode="turning-to-link">
  866. <xsl:with-param name="type" select="'cite'"/>
  867. </xsl:apply-templates>
  868. </xsl:when>
  869. <xsl:otherwise>
  870. <cite>
  871. <xsl:call-template name="commonattributes"/>
  872. <xsl:call-template name="setidaname"/>
  873. <xsl:apply-templates/>
  874. </cite>
  875. </xsl:otherwise>
  876. </xsl:choose>
  877. </xsl:template>
  878. <!-- quotes - only do 1 level, no flip-flopping -->
  879. <xsl:template match="*[contains(@class, ' topic/q ')]" name="topic.q">
  880. <q>
  881. <xsl:call-template name="commonattributes"/>
  882. <xsl:apply-templates/>
  883. </q>
  884. </xsl:template>
  885. <xsl:template match="*[contains(@class, ' topic/term ')]" mode="output-term">
  886. <!-- Deprecated since 2.1 -->
  887. <xsl:param name="displaytext"/>
  888. <dfn class="term">
  889. <xsl:call-template name="commonattributes"/>
  890. <xsl:call-template name="setidaname"/>
  891. <xsl:choose>
  892. <xsl:when test="normalize-space($displaytext)">
  893. <xsl:value-of select="$displaytext"/>
  894. </xsl:when>
  895. <xsl:otherwise>
  896. <xsl:apply-templates/>
  897. </xsl:otherwise>
  898. </xsl:choose>
  899. </dfn>
  900. </xsl:template>
  901. <!-- Templates for internal usage in terms/abbreviation resolving -->
  902. <xsl:template name="getMatchingTarget" as="element()?">
  903. <xsl:param name="m_glossid" select="''" as="xs:string"/>
  904. <xsl:param name="m_entry-file-contents" as="node()?"/>
  905. <xsl:param name="m_reflang" select="'en-US'" as="xs:string"/>
  906. <xsl:variable name="glossentries" select="$m_entry-file-contents/descendant-or-self::*[contains(@class, ' glossentry/glossentry ')]" as="element()*"/>
  907. <xsl:choose>
  908. <xsl:when test="$m_glossid = '' and $glossentries[lang($m_reflang)]">
  909. <xsl:sequence select="$glossentries[lang($m_reflang)][1]"/>
  910. </xsl:when>
  911. <xsl:when test="not($m_glossid = '') and $glossentries[@id = $m_glossid][lang($m_reflang)]">
  912. <xsl:sequence select="$glossentries[@id = $m_glossid][lang($m_reflang)]"/>
  913. </xsl:when>
  914. <xsl:when test="$m_glossid = '' and $glossentries[lang($DEFAULTLANG)]">
  915. <xsl:sequence select="$glossentries[lang($DEFAULTLANG)][1]"/>
  916. </xsl:when>
  917. <xsl:when test="not($m_glossid = '') and $glossentries[@id = $m_glossid][lang($DEFAULTLANG)]">
  918. <xsl:sequence select="$glossentries[@id = $m_glossid][lang($DEFAULTLANG)]"/>
  919. </xsl:when>
  920. <xsl:when test="$m_glossid = '' and $glossentries[not(@xml:lang) or normalize-space(@xml:lang) = '']">
  921. <xsl:sequence select="$glossentries[not(@xml:lang) or normalize-space(@xml:lang) = ''][1]"/>
  922. </xsl:when>
  923. <xsl:when test="not($m_glossid = '') and $glossentries[@id = $m_glossid][not(@xml:lang) or normalize-space(@xml:lang) = '']">
  924. <xsl:sequence select="$glossentries[@id = $m_glossid][not(@xml:lang) or normalize-space(@xml:lang) = ''][1]"/>
  925. </xsl:when>
  926. <!--xsl:otherwise>
  927. <xsl:value-of select="'#none#'"/>
  928. </xsl:otherwise-->
  929. </xsl:choose>
  930. </xsl:template>
  931. <xsl:template match="*" mode="getMatchingSurfaceForm">
  932. <xsl:param name="m_matched-target" as="element()?"/>
  933. <xsl:param name="m_keys"/>
  934. <xsl:choose>
  935. <xsl:when test="exists($m_matched-target)">
  936. <xsl:variable name="glossentry" select="$m_matched-target"/>
  937. <xsl:choose>
  938. <xsl:when test="$glossentry//*[contains(@class, ' glossentry/glossSurfaceForm ')][normalize-space(.) != '']">
  939. <xsl:apply-templates select="$glossentry//*[contains(@class, ' glossentry/glossSurfaceForm ')][normalize-space(.) != '']" mode="dita-ot:text-only"/>
  940. </xsl:when>
  941. <xsl:otherwise>
  942. <xsl:apply-templates select="$glossentry//*[contains(@class, ' glossentry/glossterm ')]" mode="dita-ot:text-only"/>
  943. </xsl:otherwise>
  944. </xsl:choose>
  945. </xsl:when>
  946. <xsl:otherwise>
  947. <xsl:apply-templates select="." mode="ditamsg:no-glossentry-for-key">
  948. <xsl:with-param name="matching-keys" select="$m_keys"/>
  949. </xsl:apply-templates>
  950. </xsl:otherwise>
  951. </xsl:choose>
  952. </xsl:template>
  953. <xsl:template match="*" mode="getMatchingGlossdef">
  954. <xsl:param name="m_matched-target" as="element()?"/>
  955. <xsl:param name="m_keys"/>
  956. <xsl:choose>
  957. <xsl:when test="exists($m_matched-target)">
  958. <xsl:variable name="glossentry" select="$m_matched-target" as="element()?"/>
  959. <xsl:choose>
  960. <xsl:when test="$glossentry/*[contains(@class, ' glossentry/glossdef ')]">
  961. <xsl:apply-templates select="$glossentry/*[contains(@class, ' glossentry/glossdef ')]" mode="dita-ot:text-only"/>
  962. </xsl:when>
  963. <xsl:when test="$glossentry//*[contains(@class, ' glossentry/glossSurfaceForm ')][normalize-space(.) != '']">
  964. <!-- Second choice: surface form, as it may contain *slightly* more information than the original term -->
  965. <xsl:apply-templates select="$glossentry//*[contains(@class, ' glossentry/glossSurfaceForm ')][normalize-space(.) != '']" mode="dita-ot:text-only"/>
  966. </xsl:when>
  967. <xsl:otherwise>
  968. <!-- Fall back to term if there is no definition and no surface form -->
  969. <xsl:apply-templates select="$glossentry//*[contains(@class, ' glossentry/glossterm ')]" mode="dita-ot:text-only"/>
  970. </xsl:otherwise>
  971. </xsl:choose>
  972. </xsl:when>
  973. <xsl:when test="normalize-space(.) = '' and
  974. (boolean(ancestor::*[contains(@class, ' topic/copyright ')]) or generate-id(.) = generate-id(key('keyref', @keyref)[1]))">
  975. <!-- Already generating a message when looking for the term, do not generate a "missing glossentry" message here too -->
  976. </xsl:when>
  977. <xsl:when test="boolean(ancestor::*[contains(@class, ' topic/copyright ')]) or generate-id(.) = generate-id(key('keyref', @keyref)[1])">
  978. <!-- Didn't look up term because it was specified, but this is the first occurrence
  979. and the glossentry was not found, so generate "missing glossentry" message -->
  980. <xsl:apply-templates select="." mode="ditamsg:no-glossentry-for-key">
  981. <xsl:with-param name="matching-keys" select="$m_keys"/>
  982. </xsl:apply-templates>
  983. </xsl:when>
  984. </xsl:choose>
  985. </xsl:template>
  986. <xsl:template match="*" mode="getMatchingAcronym">
  987. <xsl:param name="m_matched-target" as="element()?"/>
  988. <xsl:param name="m_keys"/>
  989. <xsl:choose>
  990. <xsl:when test="exists($m_matched-target)">
  991. <xsl:variable name="glossentry" select="$m_matched-target"/>
  992. <xsl:choose>
  993. <xsl:when test="$glossentry//*[contains(@class, ' glossentry/glossStatus ')][@value = 'preferred'][1]/preceding-sibling::*[contains(@class, ' glossentry/glossAcronym ') or contains(@class, ' glossentry/glossAbbreviation ')][normalize-space(.) != '']">
  994. <xsl:apply-templates select="$glossentry//*[contains(@class, ' glossentry/glossStatus ')][@value = 'preferred'][1]/preceding-sibling::*[contains(@class, ' glossentry/glossAcronym ') or contains(@class, ' glossentry/glossAbbreviation ')][normalize-space(.) != '']" mode="dita-ot:text-only"/>
  995. </xsl:when>
  996. <xsl:when test="$glossentry//*[contains(@class, ' glossentry/glossStatus ')][@value != 'prohibited' and @value != 'obsolete'][1]/preceding-sibling::*[contains(@class, ' glossentry/glossAcronym ') or contains(@class, ' glossentry/glossAbbreviation ')][normalize-space(.) != '']">
  997. <xsl:apply-templates select="$glossentry//*[contains(@class, ' glossentry/glossStatus ')][@value != 'prohibited' and @value != 'obsolete'][1]/preceding-sibling::*[contains(@class, ' glossentry/glossAcronym ') or contains(@class, ' glossentry/glossAbbreviation ')][normalize-space(.) != '']" mode="dita-ot:text-only"/>
  998. </xsl:when>
  999. <xsl:when test="$glossentry//*[contains(@class, ' glossentry/glossAlt ')][1]/*[contains(@class, ' glossentry/glossAcronym ') or contains(@class, ' glossentry/glossAbbreviation ')][not(following-sibling::glossStatus)][normalize-space(.) != '']">
  1000. <xsl:apply-templates select="$glossentry//*[contains(@class, ' glossentry/glossAlt ')][1]/*[contains(@class, ' glossentry/glossAcronym ') or contains(@class, ' glossentry/glossAbbreviation ')][count(following-sibling::glossStatus) = 0][normalize-space(.) != '']" mode="dita-ot:text-only"/>
  1001. </xsl:when>
  1002. <xsl:otherwise>
  1003. <xsl:apply-templates select="$glossentry/*[contains(@class, ' glossentry/glossterm ')]" mode="dita-ot:text-only"/>
  1004. </xsl:otherwise>
  1005. </xsl:choose>
  1006. </xsl:when>
  1007. <xsl:otherwise>
  1008. <!-- No matching entries found with reference language or default language. -->
  1009. <xsl:apply-templates select="." mode="ditamsg:no-glossentry-for-key">
  1010. <xsl:with-param name="matching-keys" select="$m_keys"/>
  1011. </xsl:apply-templates>
  1012. </xsl:otherwise>
  1013. </xsl:choose>
  1014. </xsl:template>
  1015. <!-- Note: processing for the term specialization abbreviated-form is located in abbrev-d.xsl. -->
  1016. <xsl:key name="keyref" match="*[contains(@class, ' topic/term ')]" use="@keyref"/>
  1017. <!-- terms and abbreviated-forms -->
  1018. <xsl:template match="*[contains(@class, ' topic/term ')]" name="topic.term">
  1019. <xsl:variable name="keys" select="@keyref" as="attribute()?"/>
  1020. <xsl:choose>
  1021. <xsl:when test="@keyref and @href">
  1022. <xsl:variable name="updatedTarget" as="xs:string">
  1023. <xsl:apply-templates select="." mode="find-keyref-target"/>
  1024. </xsl:variable>
  1025. <xsl:variable name="entry-file-contents" as="node()?">
  1026. <xsl:if test="empty(@scope) or @scope = 'local'">
  1027. <xsl:sequence select="dita-ot:retrieve-href-target(@href)"/>
  1028. </xsl:if>
  1029. </xsl:variable>
  1030. <!-- Glossary id defined in <glossentry> -->
  1031. <xsl:variable name="glossid" select="substring-after($updatedTarget, '#')" as="xs:string"/>
  1032. <!--
  1033. Language preference.
  1034. NOTE: glossid overrides language preference.
  1035. -->
  1036. <xsl:variable name="reflang" as="xs:string?">
  1037. <xsl:call-template name="getLowerCaseLang"/>
  1038. </xsl:variable>
  1039. <xsl:variable name="matched-target" as="element()?">
  1040. <xsl:call-template name="getMatchingTarget">
  1041. <xsl:with-param name="m_entry-file-contents" select="$entry-file-contents"/>
  1042. <xsl:with-param name="m_glossid" select="$glossid"/>
  1043. <xsl:with-param name="m_reflang" select="$reflang"/>
  1044. </xsl:call-template>
  1045. </xsl:variable>
  1046. <!-- End: Language preference. -->
  1047. <!-- Text should be displayed -->
  1048. <xsl:variable name="displaytext">
  1049. <xsl:choose>
  1050. <xsl:when test="normalize-space(.) != '' and empty(processing-instruction('ditaot')[. = 'gentext'])">
  1051. <xsl:apply-templates mode="dita-ot:text-only"/>
  1052. </xsl:when>
  1053. <xsl:when test="exists(ancestor::*[contains(@class, ' topic/copyright ')]) or generate-id(.) = generate-id(key('keyref', @keyref)[1])">
  1054. <xsl:apply-templates select="." mode="getMatchingSurfaceForm">
  1055. <xsl:with-param name="m_matched-target" select="$matched-target"/>
  1056. <xsl:with-param name="m_keys" select="$keys"/>
  1057. </xsl:apply-templates>
  1058. </xsl:when>
  1059. <xsl:otherwise>
  1060. <xsl:apply-templates select="." mode="getMatchingAcronym">
  1061. <xsl:with-param name="m_matched-target" select="$matched-target"/>
  1062. <xsl:with-param name="m_keys" select="$keys"/>
  1063. </xsl:apply-templates>
  1064. </xsl:otherwise>
  1065. </xsl:choose>
  1066. </xsl:variable>
  1067. <!-- End of displaytext -->
  1068. <!-- hovertip text -->
  1069. <xsl:variable name="hovertext">
  1070. <xsl:apply-templates select="." mode="getMatchingGlossdef">
  1071. <xsl:with-param name="m_matched-target" select="$matched-target"/>
  1072. <xsl:with-param name="m_keys" select="$keys"/>
  1073. </xsl:apply-templates>
  1074. </xsl:variable>
  1075. <!-- End of hovertip text -->
  1076. <a>
  1077. <xsl:apply-templates select="." mode="add-linking-attributes"/>
  1078. <xsl:apply-templates select="." mode="add-desc-as-hoverhelp">
  1079. <xsl:with-param name="hovertext" select="$hovertext">
  1080. </xsl:with-param>
  1081. </xsl:apply-templates>
  1082. <xsl:apply-templates select="." mode="output-term">
  1083. <xsl:with-param name="displaytext" select="normalize-space($displaytext)"/>
  1084. </xsl:apply-templates>
  1085. </a>
  1086. </xsl:when>
  1087. <xsl:otherwise>
  1088. <xsl:apply-templates select="." mode="output-term">
  1089. <xsl:with-param name="displaytext">
  1090. <xsl:apply-templates select="." mode="dita-ot:text-only"/>
  1091. </xsl:with-param>
  1092. </xsl:apply-templates>
  1093. </xsl:otherwise>
  1094. </xsl:choose>
  1095. </xsl:template>
  1096. <!-- =========== BOOLEAN-STATE DATA TYPES =========== -->
  1097. <!-- Use color to indicate these types for now -->
  1098. <!-- output the tag & it's state -->
  1099. <xsl:template match="*[contains(@class, ' topic/boolean ')]" name="topic.boolean">
  1100. <span style="color:green">
  1101. <xsl:call-template name="commonattributes"/>
  1102. <xsl:call-template name="setidaname"/>
  1103. <xsl:value-of select="name()"/><xsl:text>: </xsl:text><xsl:value-of select="@state"/>
  1104. </span>
  1105. </xsl:template>
  1106. <!-- output the tag, it's name & value -->
  1107. <xsl:template match="*[contains(@class, ' topic/state ')]" name="topic.state">
  1108. <span style="color:red">
  1109. <xsl:call-template name="commonattributes"/>
  1110. <xsl:call-template name="setidaname"/>
  1111. <xsl:value-of select="name()"/><xsl:text>: </xsl:text><xsl:value-of select="@name"/><xsl:text>=</xsl:text><xsl:value-of select="@value"/>
  1112. </span>
  1113. </xsl:template>
  1114. <!-- PRE -->
  1115. <xsl:template match="*[contains(@class, ' topic/pre ')]" name="topic.pre">
  1116. <xsl:if test="contains(@frame, 'top')"><hr /></xsl:if>
  1117. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
  1118. <xsl:call-template name="spec-title-nospace"/>
  1119. <pre>
  1120. <xsl:attribute name="class" select="name()"/>
  1121. <xsl:call-template name="commonattributes"/>
  1122. <xsl:call-template name="setscale"/>
  1123. <xsl:call-template name="setidaname"/>
  1124. <xsl:apply-templates/>
  1125. </pre>
  1126. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  1127. <xsl:if test="contains(@frame, 'bot')"><hr /></xsl:if>
  1128. </xsl:template>
  1129. <!-- lines - body font -->
  1130. <xsl:template match="*[contains(@class, ' topic/lines ')]" name="topic.lines">
  1131. <xsl:if test="contains(@frame, 'top')"><hr /></xsl:if>
  1132. <xsl:call-template name="spec-title-nospace"/>
  1133. <p>
  1134. <xsl:call-template name="commonattributes"/>
  1135. <xsl:call-template name="setscale"/>
  1136. <xsl:call-template name="setidaname"/>
  1137. <xsl:apply-templates/>
  1138. </p>
  1139. <xsl:if test="contains(@frame, 'bot')"><hr /></xsl:if>
  1140. </xsl:template>
  1141. <xsl:template match="*[contains(@class, ' topic/lines ')]//text()">
  1142. <xsl:analyze-string select="replace(., ' ', '&#xA0;&#xA0;')" regex="&#xA;">
  1143. <xsl:matching-substring>
  1144. <br/>
  1145. </xsl:matching-substring>
  1146. <xsl:non-matching-substring>
  1147. <xsl:value-of select="."/>
  1148. </xsl:non-matching-substring>
  1149. </xsl:analyze-string>
  1150. </xsl:template>
  1151. <!-- =========== FIGURE =========== -->
  1152. <xsl:template match="*[contains(@class, ' topic/fig ')]" name="topic.fig">
  1153. <xsl:variable name="default-fig-class">
  1154. <xsl:apply-templates select="." mode="dita2html:get-default-fig-class"/>
  1155. </xsl:variable>
  1156. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
  1157. <figure>
  1158. <xsl:if test="$default-fig-class != ''">
  1159. <xsl:attribute name="class" select="$default-fig-class"/>
  1160. </xsl:if>
  1161. <xsl:call-template name="commonattributes">
  1162. <xsl:with-param name="default-output-class" select="$default-fig-class"/>
  1163. </xsl:call-template>
  1164. <xsl:call-template name="setscale"/>
  1165. <xsl:call-template name="setidaname"/>
  1166. <xsl:call-template name="place-fig-lbl"/>
  1167. <xsl:apply-templates select="node() except *[contains(@class, ' topic/title ') or contains(@class, ' topic/desc ')]"/>
  1168. </figure>
  1169. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  1170. </xsl:template>
  1171. <!-- Determine the default XHTML class attribute for a figure -->
  1172. <xsl:template match="*" mode="dita2html:get-default-fig-class">
  1173. <xsl:choose>
  1174. <xsl:when test="@frame = 'all'">figborder</xsl:when>
  1175. <xsl:when test="@frame = 'sides'">figsides</xsl:when>
  1176. <xsl:when test="@frame = 'top'">figtop</xsl:when>
  1177. <xsl:when test="@frame = 'bottom'">figbottom</xsl:when>
  1178. <xsl:when test="@frame = 'topbot'">figtopbot</xsl:when>
  1179. <xsl:otherwise>fignone</xsl:otherwise>
  1180. </xsl:choose>
  1181. </xsl:template>
  1182. <!-- should not need priority, default is low enough; was set to 1 -->
  1183. <xsl:template match="*[contains(@class, ' topic/figgroup ')]" name="topic.figgroup">
  1184. <!-- Figgroup can contain blocks, maybe this should be a div?
  1185. Changing to <div> with DITA-OT 2.3 -->
  1186. <div>
  1187. <xsl:call-template name="commonattributes"/>
  1188. <xsl:call-template name="setidaname"/>
  1189. <!-- Allow title to fallthrough -->
  1190. <xsl:apply-templates/>
  1191. </div>
  1192. </xsl:template>
  1193. <!-- =========== IMAGE/OBJECT =========== -->
  1194. <xsl:template match="*[contains(@class, ' topic/image ')]" name="topic.image">
  1195. <!-- build any pre break indicated by style -->
  1196. <xsl:choose>
  1197. <xsl:when test="parent::*[contains(@class, ' topic/fig ')][contains(@frame, 'top ')]">
  1198. <!-- NOP if there is already a break implied by a parent property -->
  1199. </xsl:when>
  1200. <xsl:when test="@placement = 'break'">
  1201. <br/>
  1202. </xsl:when>
  1203. </xsl:choose>
  1204. <xsl:call-template name="setaname"/>
  1205. <xsl:choose>
  1206. <xsl:when test="@placement = 'break'"><!--Align only works for break-->
  1207. <xsl:choose>
  1208. <xsl:when test="@align = 'left'">
  1209. <div class="imageleft">
  1210. <xsl:call-template name="topic-image"/>
  1211. </div>
  1212. </xsl:when>
  1213. <xsl:when test="@align = 'right'">
  1214. <div class="imageright">
  1215. <xsl:call-template name="topic-image"/>
  1216. </div>
  1217. </xsl:when>
  1218. <xsl:when test="@align = 'center'">
  1219. <div class="imagecenter">
  1220. <xsl:call-template name="topic-image"/>
  1221. </div>
  1222. </xsl:when>
  1223. <xsl:otherwise>
  1224. <xsl:call-template name="topic-image"/>
  1225. </xsl:otherwise>
  1226. </xsl:choose>
  1227. </xsl:when>
  1228. <xsl:otherwise>
  1229. <xsl:call-template name="topic-image"/>
  1230. </xsl:otherwise>
  1231. </xsl:choose>
  1232. <!-- build any post break indicated by style -->
  1233. <xsl:if test="not(@placement = 'inline')"><br/></xsl:if>
  1234. <!-- image name for review -->
  1235. <xsl:if test="$ARTLBL = 'yes'"> [<xsl:value-of select="@href"/>] </xsl:if>
  1236. </xsl:template>
  1237. <xsl:template name="topic-image">
  1238. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
  1239. <img>
  1240. <xsl:call-template name="commonattributes">
  1241. <xsl:with-param name="default-output-class">
  1242. <xsl:if test="@placement = 'break'"><!--Align only works for break-->
  1243. <xsl:choose>
  1244. <xsl:when test="@align = 'left'">imageleft</xsl:when>
  1245. <xsl:when test="@align = 'right'">imageright</xsl:when>
  1246. <xsl:when test="@align = 'center'">imagecenter</xsl:when>
  1247. </xsl:choose>
  1248. </xsl:if>
  1249. </xsl:with-param>
  1250. </xsl:call-template>
  1251. <xsl:call-template name="setid"/>
  1252. <xsl:choose>
  1253. <xsl:when test="*[contains(@class, ' topic/longdescref ')]">
  1254. <xsl:apply-templates select="*[contains(@class, ' topic/longdescref ')]"/>
  1255. </xsl:when>
  1256. <xsl:otherwise>
  1257. <xsl:apply-templates select="@longdescref"/>
  1258. </xsl:otherwise>
  1259. </xsl:choose>
  1260. <xsl:apply-templates select="@href|@height|@width"/>
  1261. <xsl:apply-templates select="@scale"/>
  1262. <xsl:choose>
  1263. <xsl:when test="*[contains(@class, ' topic/alt ')]">
  1264. <xsl:variable name="alt-content"><xsl:apply-templates select="*[contains(@class, ' topic/alt ')]" mode="text-only"/></xsl:variable>
  1265. <xsl:attribute name="alt" select="normalize-space($alt-content)"/>
  1266. </xsl:when>
  1267. <xsl:when test="@alt">
  1268. <xsl:attribute name="alt" select="@alt"/>
  1269. </xsl:when>
  1270. </xsl:choose>
  1271. </img>
  1272. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  1273. </xsl:template>
  1274. <xsl:template match="*[contains(@class, ' topic/alt ')]">
  1275. <xsl:apply-templates select="." mode="text-only"/>
  1276. </xsl:template>
  1277. <!-- Process image attributes. Using priority, in case default @href is added at some point. -->
  1278. <!-- 20090303: Removed priority; does not appear to be needed. -->
  1279. <xsl:template match="*[contains(@class, ' topic/image ')]/@href">
  1280. <xsl:attribute name="src" select="."/>
  1281. </xsl:template>
  1282. <!-- AM: handling for scale attribute -->
  1283. <xsl:template match="*[contains(@class, ' topic/image ')]/@scale">
  1284. <xsl:variable name="width" select="../@dita-ot:image-width"/>
  1285. <xsl:variable name="height" select="../@dita-ot:image-height"/>
  1286. <xsl:if test="not(../@width) and not(../@height)">
  1287. <xsl:attribute name="height" select="floor(number($height) * number(.) div 100)"/>
  1288. <xsl:attribute name="width" select="floor(number($width) * number(.) div 100)"/>
  1289. </xsl:if>
  1290. </xsl:template>
  1291. <xsl:template match="*[contains(@class, ' topic/image ')]/@height">
  1292. <xsl:variable name="height-in-pixel">
  1293. <xsl:call-template name="length-to-pixels">
  1294. <xsl:with-param name="dimen" select="."/>
  1295. </xsl:call-template>
  1296. </xsl:variable>
  1297. <xsl:if test="not($height-in-pixel = '100%')">
  1298. <xsl:attribute name="height">
  1299. <!--xsl:choose>
  1300. <xsl:when test="../@scale and string(number(../@scale))!='NaN'">
  1301. <xsl:value-of select="number($height-in-pixel) * number(../@scale)"/>
  1302. </xsl:when>
  1303. <xsl:otherwise-->
  1304. <xsl:value-of select="number($height-in-pixel)"/>
  1305. <!--/xsl:otherwise>
  1306. </xsl:choose-->
  1307. </xsl:attribute>
  1308. </xsl:if>
  1309. </xsl:template>
  1310. <xsl:template match="*[contains(@class, ' topic/image ')]/@width">
  1311. <xsl:variable name="width-in-pixel">
  1312. <xsl:call-template name="length-to-pixels">
  1313. <xsl:with-param name="dimen" select="."/>
  1314. </xsl:call-template>
  1315. </xsl:variable>
  1316. <xsl:if test="not($width-in-pixel = '100%')">
  1317. <xsl:attribute name="width">
  1318. <!--xsl:choose>
  1319. <xsl:when test="../@scale and string(number(../@scale))!='NaN'">
  1320. <xsl:value-of select="number($width-in-pixel) * number(../@scale)"/>
  1321. </xsl:when>
  1322. <xsl:otherwise-->
  1323. <xsl:value-of select="number($width-in-pixel)"/>
  1324. <!--/xsl:otherwise>
  1325. </xsl:choose-->
  1326. </xsl:attribute>
  1327. </xsl:if>
  1328. </xsl:template>
  1329. <xsl:template match="*[contains(@class, ' topic/image ')]/@longdescref">
  1330. <xsl:attribute name="longdesc">
  1331. <xsl:choose>
  1332. <!-- Guess whether link target is a DITA topic or something else -->
  1333. <xsl:when test="contains(., '.dita') or contains(., '.xml')">
  1334. <xsl:call-template name="replace-extension">
  1335. <xsl:with-param name="filename" select="."/>
  1336. <xsl:with-param name="extension" select="$OUTEXT"/>
  1337. </xsl:call-template>
  1338. </xsl:when>
  1339. <xsl:otherwise>
  1340. <xsl:value-of select="."/>
  1341. </xsl:otherwise>
  1342. </xsl:choose>
  1343. </xsl:attribute>
  1344. </xsl:template>
  1345. <xsl:template match="*[contains(@class, ' topic/image ')]/*[contains(@class, ' topic/longdescref ')]">
  1346. <xsl:if test="@href and not (@href = '')">
  1347. <xsl:attribute name="longdesc">
  1348. <xsl:choose>
  1349. <xsl:when test="not(@format) or @format = 'dita'">
  1350. <xsl:call-template name="replace-extension">
  1351. <xsl:with-param name="filename" select="@href"/>
  1352. <xsl:with-param name="extension" select="$OUTEXT"/>
  1353. </xsl:call-template>
  1354. </xsl:when>
  1355. <xsl:otherwise>
  1356. <xsl:value-of select="@href"/>
  1357. </xsl:otherwise>
  1358. </xsl:choose>
  1359. </xsl:attribute>
  1360. </xsl:if>
  1361. </xsl:template>
  1362. <!-- object, desc, & param -->
  1363. <xsl:template match="*[contains(@class, ' topic/object ')]" name="topic.object">
  1364. <object>
  1365. <xsl:copy-of select="@id | @declare | @codebase | @type | @archive | @height | @usemap | @tabindex | @classid | @data | @codetype | @standby | @width | @name"/>
  1366. <xsl:if test="@longdescref or *[contains(@class, ' topic/longdescref ')]">
  1367. <xsl:apply-templates select="." mode="ditamsg:longdescref-on-object"/>
  1368. </xsl:if>
  1369. <xsl:apply-templates/>
  1370. <!-- Test for Flash movie; include EMBED statement for non-IE browsers -->
  1371. <xsl:if test="contains(@codebase, 'swflash.cab')">
  1372. <embed>
  1373. <xsl:if test="@id"><xsl:attribute name="name" select="@id"/></xsl:if>
  1374. <xsl:copy-of select="@height | @width"/>
  1375. <xsl:attribute name="type"><xsl:text>application/x-shockwave-flash</xsl:text></xsl:attribute>
  1376. <xsl:attribute name="pluginspage"><xsl:text>http://www.macromedia.com/go/getflashplayer</xsl:text></xsl:attribute>
  1377. <xsl:if test="*[contains(@class, ' topic/param ')]/@name = 'movie'">
  1378. <xsl:attribute name="src" select="*[contains(@class, ' topic/param ')][@name = 'movie']/@value"/>
  1379. </xsl:if>
  1380. <xsl:if test="*[contains(@class, ' topic/param ')]/@name = 'quality'">
  1381. <xsl:attribute name="quality" select="*[contains(@class, ' topic/param ')][@name = 'quality']/@value"/>
  1382. </xsl:if>
  1383. <xsl:if test="*[contains(@class, ' topic/param ')]/@name = 'bgcolor'">
  1384. <xsl:attribute name="bgcolor" select="*[contains(@class, ' topic/param ')][@name = 'bgcolor']/@value"/>
  1385. </xsl:if>
  1386. </embed>
  1387. </xsl:if>
  1388. </object>
  1389. </xsl:template>
  1390. <xsl:template match="*[contains(@class, ' topic/param ')]" name="topic.param">
  1391. <param>
  1392. <xsl:copy-of select="@name | @id | @value"/>
  1393. </param>
  1394. </xsl:template>
  1395. <!-- need to add test for object/desc to avoid conflicts -->
  1396. <xsl:template match="*[contains(@class, ' topic/object ')]/*[contains(@class, ' topic/desc ')]" name="topic.object_desc">
  1397. <span>
  1398. <xsl:copy-of select="@name | @id | value"/>
  1399. <xsl:apply-templates/>
  1400. </span>
  1401. </xsl:template>
  1402. <!-- =========== FOOTNOTE =========== -->
  1403. <xsl:template match="*[contains(@class, ' topic/fn ')]" name="topic.fn">
  1404. <xsl:param name="xref"/>
  1405. <!-- when FN has an ID, it can only be referenced, otherwise, output an a-name & a counter -->
  1406. <xsl:if test="not(@id) or $xref = 'yes'">
  1407. <xsl:variable name="fnid"><xsl:number from="/" level="any"/></xsl:variable>
  1408. <xsl:variable name="callout" select="@callout"/>
  1409. <xsl:variable name="convergedcallout" select="if (string-length($callout)> 0) then $callout else $fnid"/>
  1410. <a name="fnsrc_{$fnid}" href="#fntarg_{$fnid}">
  1411. <sup>
  1412. <xsl:value-of select="$convergedcallout"/>
  1413. </sup>
  1414. </a>
  1415. </xsl:if>
  1416. </xsl:template>
  1417. <!-- =========== REQUIRED CLEANUP and REVIEW COMMENT =========== -->
  1418. <xsl:template match="*[contains(@class, ' topic/required-cleanup ')]" mode="default-required-cleanup-style">
  1419. <xsl:call-template name="style">
  1420. <xsl:with-param name="contents">background-color: #FFFF99; color:#CC3333; border: 1pt black solid;</xsl:with-param>
  1421. </xsl:call-template>
  1422. </xsl:template>
  1423. <xsl:template match="*[contains(@class, ' topic/draft-comment ')]" mode="default-draft-comment-style">
  1424. <xsl:call-template name="style">
  1425. <xsl:with-param name="contents">background-color: #99FF99; border: 1pt black solid;</xsl:with-param>
  1426. </xsl:call-template>
  1427. </xsl:template>
  1428. <xsl:template match="*[contains(@class, ' topic/required-cleanup ')]" name="topic.required-cleanup">
  1429. <xsl:if test="$DRAFT = 'yes'">
  1430. <xsl:apply-templates select="." mode="ditamsg:required-cleanup-in-content"/>
  1431. <div>
  1432. <xsl:call-template name="commonattributes"/>
  1433. <xsl:apply-templates select="." mode="default-required-cleanup-style"/>
  1434. <xsl:call-template name="setidaname"/>
  1435. <strong><xsl:call-template name="getVariable">
  1436. <xsl:with-param name="id" select="'Required cleanup'"/>
  1437. </xsl:call-template>
  1438. <xsl:call-template name="getVariable">
  1439. <xsl:with-param name="id" select="'ColonSymbol'"/>
  1440. </xsl:call-template><xsl:text> </xsl:text></strong>
  1441. <xsl:if test="@remap">[<xsl:value-of select="@remap"/>] </xsl:if>
  1442. <xsl:apply-templates/>
  1443. </div>
  1444. </xsl:if>
  1445. </xsl:template>
  1446. <xsl:template match="*[contains(@class, ' topic/draft-comment ')]" name="topic.draft-comment">
  1447. <xsl:if test="$DRAFT = 'yes'">
  1448. <xsl:apply-templates select="." mode="ditamsg:draft-comment-in-content"/>
  1449. <div>
  1450. <xsl:call-template name="commonattributes"/>
  1451. <xsl:apply-templates select="." mode="default-draft-comment-style"/>
  1452. <xsl:call-template name="setidaname"/>
  1453. <strong><xsl:call-template name="getVariable">
  1454. <xsl:with-param name="id" select="'Draft comment'"/>
  1455. </xsl:call-template>
  1456. <xsl:call-template name="getVariable">
  1457. <xsl:with-param name="id" select="'ColonSymbol'"/>
  1458. </xsl:call-template><xsl:text> </xsl:text></strong>
  1459. <xsl:if test="@author"><xsl:value-of select="@author"/><xsl:text> </xsl:text></xsl:if>
  1460. <xsl:if test="@disposition"><xsl:value-of select="@disposition"/><xsl:text> </xsl:text></xsl:if>
  1461. <xsl:if test="@time"><xsl:value-of select="@time"/></xsl:if>
  1462. <br/>
  1463. <xsl:apply-templates/>
  1464. </div>
  1465. </xsl:if>
  1466. </xsl:template>
  1467. <!--Dita comment passthru-->
  1468. <xsl:template match="processing-instruction()">
  1469. <xsl:if test="name()='dita-comment'"><xsl:comment><xsl:value-of select="."/></xsl:comment></xsl:if>
  1470. </xsl:template>
  1471. <!-- =========== INDEX =========== -->
  1472. <!-- TBD: this needs practical implementation. currently the support merely
  1473. echoes the content back, indicating any nesting. Useful view for authoring!-->
  1474. <xsl:template match="*[contains(@class, ' topic/indexterm ')]" name="topic.indexterm">
  1475. <xsl:if test="$INDEXSHOW = 'yes'">
  1476. <xsl:choose>
  1477. <xsl:when test="@keyref and @href">
  1478. <a>
  1479. <xsl:apply-templates select="." mode="add-linking-attributes"/>
  1480. <span style="margin: 1pt; background-color: #ffddff; border: 1pt black solid;">
  1481. <xsl:call-template name="commonattributes"/>
  1482. <xsl:apply-templates/>
  1483. </span>
  1484. </a>
  1485. </xsl:when>
  1486. <xsl:otherwise>
  1487. <span style="margin: 1pt; background-color: #ffddff; border: 1pt black solid;">
  1488. <xsl:call-template name="commonattributes"/>
  1489. <xsl:apply-templates/>
  1490. </span>
  1491. </xsl:otherwise>
  1492. </xsl:choose>
  1493. </xsl:if>
  1494. </xsl:template>
  1495. <xsl:template match="*[contains(@class, ' topic/indextermref ')]"/>
  1496. <!-- ===================================================================== -->
  1497. <!-- =========== PROLOG =========== -->
  1498. <!-- all handled in get-meta.xsl -->
  1499. <xsl:template match="*[contains(@class, ' topic/prolog ')]"/>
  1500. <!-- ===================================================================== -->
  1501. <!-- ================= COMMON ATTRIBUTE PROCESSORS ====================== -->
  1502. <!-- If the element has an ID, set it as an ID and anchor-->
  1503. <!-- Set ID and output A-name -->
  1504. <xsl:template name="setidaname">
  1505. <xsl:if test="@id">
  1506. <xsl:call-template name="setidattr">
  1507. <xsl:with-param name="idvalue" select="@id"/>
  1508. </xsl:call-template>
  1509. <xsl:call-template name="setanametag">
  1510. <xsl:with-param name="idvalue" select="@id"/>
  1511. </xsl:call-template>
  1512. </xsl:if>
  1513. </xsl:template>
  1514. <!-- Set ID only -->
  1515. <xsl:template name="setid">
  1516. <xsl:if test="@id">
  1517. <xsl:call-template name="setidattr">
  1518. <xsl:with-param name="idvalue" select="@id"/>
  1519. </xsl:call-template>
  1520. </xsl:if>
  1521. </xsl:template>
  1522. <!-- Set A-name only -->
  1523. <xsl:template name="setaname">
  1524. <xsl:if test="@id">
  1525. <xsl:call-template name="setanametag">
  1526. <xsl:with-param name="idvalue" select="@id"/>
  1527. </xsl:call-template>
  1528. </xsl:if>
  1529. </xsl:template>
  1530. <!-- Set the ID attr for IE -->
  1531. <xsl:template name="setidattr">
  1532. <xsl:param name="idvalue"/>
  1533. <xsl:attribute name="id"
  1534. select="dita-ot:get-prefixed-id($idvalue/parent::*, $idvalue)"/>
  1535. </xsl:template>
  1536. <!-- Legacy named template for generating HTML4 anchors -->
  1537. <xsl:template name="setanametag">
  1538. <xsl:param name="idvalue"/>
  1539. </xsl:template>
  1540. <!-- Create & insert an ID for the generated table of contents -->
  1541. <xsl:template name="gen-toc-id">
  1542. </xsl:template>
  1543. <!-- Process standard attributes that may appear anywhere. Previously this was "setclass" -->
  1544. <xsl:template name="commonattributes">
  1545. <xsl:param name="default-output-class"/>
  1546. <xsl:apply-templates select="@xml:lang"/>
  1547. <xsl:apply-templates select="@dir"/>
  1548. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]/@outputclass" mode="add-ditaval-style"/>
  1549. <xsl:apply-templates select="." mode="set-output-class">
  1550. <xsl:with-param name="default" select="$default-output-class"/>
  1551. </xsl:apply-templates>
  1552. <xsl:choose>
  1553. <xsl:when test="exists($passthrough-attrs[empty(@att) and empty(@value)])">
  1554. <xsl:variable name="specializations" as="xs:string*">
  1555. <xsl:for-each select="ancestor-or-self::*[@domains][1]/@domains">
  1556. <xsl:analyze-string select="normalize-space(.)" regex="a\(props (.+?)\)">
  1557. <xsl:matching-substring>
  1558. <xsl:sequence select="tokenize(regex-group(1), '\s+')"/>
  1559. </xsl:matching-substring>
  1560. </xsl:analyze-string>
  1561. </xsl:for-each>
  1562. </xsl:variable>
  1563. <xsl:for-each select="@props |
  1564. @audience |
  1565. @platform |
  1566. @product |
  1567. @otherprops |
  1568. @deliveryTarget |
  1569. @*[local-name() = $specializations]">
  1570. <xsl:attribute name="data-{name()}" select="."/>
  1571. </xsl:for-each>
  1572. </xsl:when>
  1573. <xsl:when test="exists($passthrough-attrs)">
  1574. <xsl:for-each select="@*">
  1575. <xsl:if test="$passthrough-attrs[@att = name(current()) and (empty(@val) or (some $v in tokenize(current(), '\s+') satisfies $v = @val))]">
  1576. <xsl:attribute name="data-{name()}" select="."/>
  1577. </xsl:if>
  1578. </xsl:for-each>
  1579. </xsl:when>
  1580. </xsl:choose>
  1581. </xsl:template>
  1582. <!-- Set the class attribute on the resulting output element. The default for a class of elements
  1583. may be passed in with $default, but that default can be overridden with mode="get-output-class". -->
  1584. <xsl:template match="*" mode="set-output-class">
  1585. <xsl:param name="default"/>
  1586. <xsl:variable name="output-class">
  1587. <xsl:apply-templates select="." mode="get-output-class"/>
  1588. </xsl:variable>
  1589. <xsl:variable name="draft-revs" as="xs:string*">
  1590. <!-- If draft is on, add revisions to default class. Simplifies processing in DITA-OT 1.6 and earlier
  1591. that created an extra div or span around revised content, just to hold @class with revs. -->
  1592. <xsl:if test="$DRAFT = 'yes'">
  1593. <xsl:sequence select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]/revprop/@val"/>
  1594. </xsl:if>
  1595. </xsl:variable>
  1596. <xsl:variable name="using-output-class" as="xs:string*">
  1597. <xsl:choose>
  1598. <xsl:when test="string-length(normalize-space($output-class)) > 0">
  1599. <xsl:value-of select="tokenize(normalize-space($output-class), '\s+')"/>
  1600. </xsl:when>
  1601. <xsl:when test="string-length(normalize-space($default)) > 0">
  1602. <xsl:value-of select="tokenize(normalize-space($default), '\s+')"/>
  1603. </xsl:when>
  1604. </xsl:choose>
  1605. </xsl:variable>
  1606. <xsl:variable name="ancestry" as="xs:string?">
  1607. <xsl:if test="$PRESERVE-DITA-CLASS = 'yes'">
  1608. <xsl:value-of>
  1609. <xsl:apply-templates select="." mode="get-element-ancestry"/>
  1610. </xsl:value-of>
  1611. </xsl:if>
  1612. </xsl:variable>
  1613. <xsl:variable name="outputclass-attribute" as="xs:string">
  1614. <xsl:value-of>
  1615. <xsl:apply-templates select="@outputclass" mode="get-value-for-class"/>
  1616. </xsl:value-of>
  1617. </xsl:variable>
  1618. <!-- Revised design with DITA-OT 1.5: include class ancestry if requested;
  1619. combine user output class with element default, giving priority to the user value. -->
  1620. <xsl:variable name="classes" as="xs:string*"
  1621. select="tokenize($ancestry, '\s+'),
  1622. $using-output-class,
  1623. $draft-revs,
  1624. tokenize($outputclass-attribute, '\s+')"/>
  1625. <xsl:if test="exists($classes)">
  1626. <xsl:attribute name="class" select="string-join(distinct-values($classes), ' ')"/>
  1627. </xsl:if>
  1628. </xsl:template>
  1629. <!-- If an element has @outputclass, create a class value -->
  1630. <xsl:template match="@outputclass">
  1631. <xsl:attribute name="class" select="."/>
  1632. </xsl:template>
  1633. <!-- Determine what @outputclass value goes into XHTML's @class. If the value should
  1634. NOT fall through, override this template to remove it. -->
  1635. <xsl:template match="@outputclass" mode="get-value-for-class">
  1636. <xsl:value-of select="."/>
  1637. </xsl:template>
  1638. <!-- Most elements don't get a class attribute. -->
  1639. <xsl:template match="node() | @*" mode="get-output-class"/>
  1640. <!-- Get the ancestry of the current element (name only, not module) -->
  1641. <xsl:template match="*" mode="get-element-ancestry">
  1642. <xsl:param name="checkclass" select="@class"/>
  1643. <xsl:if test="contains($checkclass, '/')">
  1644. <xsl:variable name="lastpair">
  1645. <xsl:call-template name="get-last-class-pair">
  1646. <xsl:with-param name="checkclass" select="$checkclass"/>
  1647. </xsl:call-template>
  1648. </xsl:variable>
  1649. <!-- If there are any module/element pairs before the last one, process them and add a space -->
  1650. <xsl:if test="contains(substring-before($checkclass, $lastpair), '/')">
  1651. <xsl:apply-templates select="." mode="get-element-ancestry">
  1652. <xsl:with-param name="checkclass" select="substring-before($checkclass, $lastpair)"/>
  1653. </xsl:apply-templates>
  1654. <xsl:text> </xsl:text>
  1655. </xsl:if>
  1656. <xsl:value-of select="substring-after($lastpair, '/')"/>
  1657. </xsl:if>
  1658. </xsl:template>
  1659. <!-- Find the last module/element pair in a class string -->
  1660. <xsl:template name="get-last-class-pair">
  1661. <xsl:param name="checkclass" select="@class"/>
  1662. <xsl:choose>
  1663. <xsl:when test="contains(substring-after($checkclass, ' '), '/')">
  1664. <xsl:call-template name="get-last-class-pair">
  1665. <xsl:with-param name="checkclass" select="substring-after($checkclass, ' ')"/>
  1666. </xsl:call-template>
  1667. </xsl:when>
  1668. <xsl:when test="contains($checkclass, '/')">
  1669. <xsl:value-of select="normalize-space($checkclass)"/>
  1670. </xsl:when>
  1671. <xsl:otherwise><!-- Error condition --></xsl:otherwise>
  1672. </xsl:choose>
  1673. </xsl:template>
  1674. <!-- If an element has @xml:lang, copy it to the output -->
  1675. <xsl:template match="@xml:lang" name="generate-lang">
  1676. <xsl:param name="lang" select="."/>
  1677. <xsl:attribute name="lang" select="$lang"/>
  1678. </xsl:template>
  1679. <!-- If an element has @dir, copy it to the output -->
  1680. <xsl:template match="@dir">
  1681. <xsl:attribute name="dir" select="."/>
  1682. </xsl:template>
  1683. <!-- if the element has a compact=yes attribute, assert it in XHTML form -->
  1684. <xsl:template match="@compact">
  1685. <xsl:if test=". = 'yes'">
  1686. <xsl:attribute name="compact">compact</xsl:attribute><!-- assumes that no compaction is default -->
  1687. </xsl:if>
  1688. </xsl:template>
  1689. <xsl:template name="setscale">
  1690. <xsl:if test="@scale">
  1691. <!-- <xsl:attribute name="style">font-size: <xsl:value-of select="@scale"/>%;</xsl:attribute> -->
  1692. </xsl:if>
  1693. </xsl:template>
  1694. <xsl:template name="style">
  1695. <xsl:param name="contents"/>
  1696. <xsl:if test="normalize-space($contents)">
  1697. <xsl:attribute name="style" select="$contents"/>
  1698. </xsl:if>
  1699. </xsl:template>
  1700. <!-- ===================================================================== -->
  1701. <!-- ========== GENERAL SUPPORT/DOC CONTENT MANAGEMENT ========== -->
  1702. <!-- ===================================================================== -->
  1703. <!-- =========== CATCH UNDEFINED ELEMENTS (for stylesheet maintainers) =========== -->
  1704. <!-- (this rule should NOT produce output in production setting) -->
  1705. <xsl:template match="*" name="topic.undefined_element">
  1706. <xsl:call-template name="output-message">
  1707. <xsl:with-param name="id" select="'DOTX074W'"/>
  1708. <xsl:with-param name="msgparams">%1=<xsl:value-of select="@class"/></xsl:with-param>
  1709. </xsl:call-template>
  1710. <span class="undefined_element">
  1711. <xsl:apply-templates/>
  1712. </span>
  1713. </xsl:template>
  1714. <!-- ========= NAMED TEMPLATES (call by name, only) ========== -->
  1715. <!-- named templates that can be used anywhere -->
  1716. <!-- Process spectitle attribute - if one exists - needs to be called on tags that allow it -->
  1717. <xsl:template name="spec-title">
  1718. <xsl:if test="@spectitle"><div style="margin-top: 1em;"><strong><xsl:value-of select="@spectitle"/></strong></div></xsl:if>
  1719. </xsl:template>
  1720. <xsl:template name="spec-title-nospace">
  1721. <xsl:if test="@spectitle"><div style="margin-bottom: 0;"><strong><xsl:value-of select="@spectitle"/></strong></div></xsl:if>
  1722. </xsl:template>
  1723. <xsl:template name="copyright">
  1724. </xsl:template>
  1725. <!-- Break replace - used for LINES -->
  1726. <!-- this replaces newlines with the BR element. Forces breaks. -->
  1727. <xsl:template name="br-replace">
  1728. <xsl:param name="brtext" as="xs:string"/>
  1729. <xsl:variable name="cr" select="'&#xA;'" as="xs:string"/>
  1730. <xsl:choose>
  1731. <xsl:when test="contains($brtext, $cr)">
  1732. <xsl:value-of select="substring-before($brtext, $cr)"/>
  1733. <br/>
  1734. <xsl:value-of select="$cr"/>
  1735. <xsl:call-template name="br-replace">
  1736. <xsl:with-param name="brtext" select="substring-after($brtext, $cr)"/>
  1737. </xsl:call-template>
  1738. </xsl:when>
  1739. <xsl:otherwise>
  1740. <xsl:value-of select="$brtext"/>
  1741. </xsl:otherwise>
  1742. </xsl:choose>
  1743. </xsl:template>
  1744. <!-- the following named templates generate inline content for the delivery context -->
  1745. <!-- named templates for labels and titles related to topic structures -->
  1746. <!-- test processors for HTML title element -->
  1747. <xsl:template match="*|text()|processing-instruction()" mode="text-only">
  1748. <!-- Redirect to common dita-ot module -->
  1749. <xsl:apply-templates select="." mode="dita-ot:text-only"/>
  1750. </xsl:template>
  1751. <xsl:template match="*" mode="dita2html:section-heading">
  1752. <xsl:param name="defaulttitle"/> <!-- get param by reference -->
  1753. <xsl:variable name="heading">
  1754. <xsl:choose>
  1755. <xsl:when test="*[contains(@class, ' topic/title ')]">
  1756. <xsl:apply-templates select="*[contains(@class, ' topic/title ')][1]" mode="text-only"/>
  1757. <xsl:if test="*[contains(@class, ' topic/title ')][2]">
  1758. <xsl:apply-templates select="." mode="ditamsg:section-with-multiple-titles"/>
  1759. </xsl:if>
  1760. </xsl:when>
  1761. <xsl:when test="@spectitle">
  1762. <xsl:value-of select="@spectitle"/>
  1763. </xsl:when>
  1764. <xsl:otherwise/>
  1765. </xsl:choose>
  1766. </xsl:variable>
  1767. <xsl:variable name="headCount" select="count(ancestor::*[contains(@class, ' topic/topic ')]) + 1"/>
  1768. <xsl:variable name="headLevel">
  1769. <xsl:choose>
  1770. <xsl:when test="$headCount > 6">h6</xsl:when>
  1771. <xsl:otherwise>h<xsl:value-of select="$headCount"/></xsl:otherwise>
  1772. </xsl:choose>
  1773. </xsl:variable>
  1774. <!-- based on graceful defaults, build an appropriate section-level heading -->
  1775. <xsl:choose>
  1776. <xsl:when test="not($heading = '')">
  1777. <xsl:if test="normalize-space($heading) = ''">
  1778. <!-- hack: a title with whitespace ALWAYS overrides as null -->
  1779. <xsl:comment>no heading</xsl:comment>
  1780. </xsl:if>
  1781. <xsl:apply-templates select="*[contains(@class, ' topic/title ')][1]">
  1782. <xsl:with-param name="headLevel" select="$headLevel"/>
  1783. </xsl:apply-templates>
  1784. <xsl:if test="@spectitle and not(*[contains(@class, ' topic/title ')])">
  1785. <xsl:element name="{$headLevel}">
  1786. <xsl:attribute name="class">sectiontitle</xsl:attribute>
  1787. <xsl:value-of select="@spectitle"/>
  1788. </xsl:element>
  1789. </xsl:if>
  1790. </xsl:when>
  1791. <xsl:when test="$defaulttitle">
  1792. <xsl:element name="{$headLevel}">
  1793. <xsl:attribute name="class">sectiontitle</xsl:attribute>
  1794. <xsl:value-of select="$defaulttitle"/>
  1795. </xsl:element>
  1796. </xsl:when>
  1797. </xsl:choose>
  1798. </xsl:template>
  1799. <xsl:template match="*[contains(@class, ' topic/section ')]/*[contains(@class, ' topic/title ')] |
  1800. *[contains(@class, ' topic/example ')]/*[contains(@class, ' topic/title ')]" name="topic.section_title">
  1801. <xsl:param name="headLevel">
  1802. <xsl:variable name="headCount" select="count(ancestor::*[contains(@class, ' topic/topic ')])+1"/>
  1803. <xsl:choose>
  1804. <xsl:when test="$headCount > 6">h6</xsl:when>
  1805. <xsl:otherwise>h<xsl:value-of select="$headCount"/></xsl:otherwise>
  1806. </xsl:choose>
  1807. </xsl:param>
  1808. <xsl:element name="{$headLevel}">
  1809. <xsl:attribute name="class">sectiontitle</xsl:attribute>
  1810. <xsl:call-template name="commonattributes">
  1811. <xsl:with-param name="default-output-class" select="'sectiontitle'"/>
  1812. </xsl:call-template>
  1813. <xsl:apply-templates/>
  1814. </xsl:element>
  1815. </xsl:template>
  1816. <xsl:template name="bidi-area" as="xs:boolean">
  1817. <xsl:param name="parentlang">
  1818. <xsl:call-template name="getLowerCaseLang"/>
  1819. </xsl:param>
  1820. <xsl:variable name="direction">
  1821. <xsl:apply-templates select="." mode="get-render-direction">
  1822. <xsl:with-param name="lang" select="$parentlang"/>
  1823. </xsl:apply-templates>
  1824. </xsl:variable>
  1825. <xsl:sequence select="$direction = 'rtl'"/>
  1826. </xsl:template>
  1827. <!-- Test for URL: returns "url" when the content starts with a URL;
  1828. Otherwise, leave blank -->
  1829. <xsl:template name="url-string" as="xs:boolean">
  1830. <xsl:param name="urltext"/>
  1831. <xsl:sequence select="contains($urltext, 'http://') or contains($urltext, 'https://')"/>
  1832. </xsl:template>
  1833. <!-- For header file processing, pull out the wrapping DIV if one is there -->
  1834. <xsl:template match="/div" mode="add-HDF">
  1835. <xsl:apply-templates select="*|comment()|processing-instruction()|text()" mode="add-HDF"/>
  1836. </xsl:template>
  1837. <xsl:template match="*|@*|comment()|processing-instruction()|text()" mode="add-HDF">
  1838. <xsl:copy>
  1839. <xsl:apply-templates select="*|@*|comment()|processing-instruction()|text()" mode="add-HDF"/>
  1840. </xsl:copy>
  1841. </xsl:template>
  1842. <!-- ========== Section-like generated content =========== -->
  1843. <!-- render any contained footnotes as endnotes. Links back to reference point -->
  1844. <xsl:template name="gen-endnotes">
  1845. <!-- Skip any footnotes that are in draft elements when draft = no -->
  1846. <xsl:apply-templates select="//*[contains(@class, ' topic/fn ')][not( (ancestor::*[contains(@class, ' topic/draft-comment ')] or ancestor::*[contains(@class, ' topic/required-cleanup ')]) and $DRAFT = 'no')]" mode="genEndnote"/>
  1847. </xsl:template>
  1848. <!-- Catch footnotes that should appear at the end of the topic, and output them. -->
  1849. <xsl:template match="*[contains(@class, ' topic/fn ')]" mode="genEndnote">
  1850. <div class="p">
  1851. <xsl:variable name="fnid"><xsl:number from="/" level="any"/></xsl:variable>
  1852. <xsl:variable name="callout" select="@callout"/>
  1853. <xsl:variable name="convergedcallout" select="if (string-length($callout) > 0) then $callout else $fnid"/>
  1854. <xsl:call-template name="commonattributes"/>
  1855. <xsl:choose>
  1856. <xsl:when test="@id and not(@id = '')">
  1857. <xsl:variable name="topicid" select="ancestor::*[contains(@class, ' topic/topic ')][1]/@id"/>
  1858. <xsl:variable name="refid" select="concat($topicid, '/', @id)"/>
  1859. <xsl:choose>
  1860. <xsl:when test="key('xref', $refid)">
  1861. <a>
  1862. <xsl:call-template name="setid"/>
  1863. <sup>
  1864. <xsl:value-of select="$convergedcallout"/>
  1865. </sup>
  1866. </a>
  1867. <xsl:text> </xsl:text>
  1868. </xsl:when>
  1869. <xsl:otherwise>
  1870. <sup>
  1871. <xsl:value-of select="$convergedcallout"/>
  1872. </sup>
  1873. <xsl:text> </xsl:text>
  1874. </xsl:otherwise>
  1875. </xsl:choose>
  1876. </xsl:when>
  1877. <xsl:otherwise>
  1878. <a>
  1879. <xsl:attribute name="name" select="concat('fntarg_', $fnid)"/>
  1880. <xsl:attribute name="href" select="concat('#fnsrc_', $fnid)"/>
  1881. <sup>
  1882. <xsl:value-of select="$convergedcallout"/>
  1883. </sup>
  1884. </a>
  1885. <xsl:text> </xsl:text>
  1886. </xsl:otherwise>
  1887. </xsl:choose>
  1888. <xsl:apply-templates/>
  1889. </div>
  1890. </xsl:template>
  1891. <!-- set up keys based on xref's "type" attribute: %info-types;|hd|fig|table|li|fn -->
  1892. <xsl:key name="topic" match="*[contains(@class, ' topic/topic ')]" use="@id"/> <!-- uses "title" -->
  1893. <xsl:key name="fig" match="*[contains(@class, ' topic/fig ')]" use="@id"/> <!-- uses "title" -->
  1894. <xsl:key name="table" match="*[contains(@class, ' topic/table ')]" use="@id"/> <!-- uses "title" -->
  1895. <xsl:key name="li" match="*[contains(@class, ' topic/li ')]" use="@id"/> <!-- uses "?" -->
  1896. <xsl:key name="fn" match="*[contains(@class, ' topic/fn ')]" use="@id"/> <!-- uses "callout?" -->
  1897. <xsl:key name="xref" match="*[contains(@class, ' topic/xref ')]" use="substring-after(@href, '#')"/> <!-- find xref which refers to footnote. -->
  1898. <!-- ========== FORMATTER DECLARATIONS AND GLOBALS ========== -->
  1899. <!-- ========== "FORMAT" GLOBAL DECLARATIONS ========== -->
  1900. <xsl:variable name="link-top-section">no</xsl:variable><!-- values: yes, no (or any not "yes") -->
  1901. <!-- ========== "FORMAT" MACROS - Table title, figure title, InfoNavGraphic ========== -->
  1902. <!--
  1903. | These macros support globally-defined formatting constants for
  1904. | document content. Some elements have attributes that permit local
  1905. | control of formatting; such logic is part of the pertinent template rule.
  1906. +-->
  1907. <xsl:template match="*[contains(@class, ' topic/fig ')]/*[contains(@class, ' topic/title ')]" mode="figtitle">
  1908. <xsl:apply-templates/>
  1909. </xsl:template>
  1910. <xsl:template match="*[contains(@class, ' topic/fig ')]/*[contains(@class, ' topic/desc ')]" mode="figdesc">
  1911. <xsl:apply-templates/>
  1912. </xsl:template>
  1913. <xsl:template match="*[contains(@class, ' topic/fig ')]/*[contains(@class, ' topic/desc ')]" mode="get-output-class">figdesc</xsl:template>
  1914. <!-- These 2 rules are not actually used, but could be picked up by an override -->
  1915. <xsl:template match="*[contains(@class, ' topic/fig ')]/*[contains(@class, ' topic/title ')]" name="topic.fig_title">
  1916. <span><xsl:apply-templates/></span>
  1917. </xsl:template>
  1918. <!-- These rules are not actually used, but could be picked up by an override -->
  1919. <xsl:template match="*[contains(@class, ' topic/fig ')]/*[contains(@class, ' topic/desc ')]" name="topic.fig_desc">
  1920. <span><xsl:apply-templates/></span>
  1921. </xsl:template>
  1922. <xsl:template match="*[contains(@class, ' topic/figgroup ')]/*[contains(@class, ' topic/title ')]" name="topic.figgroup_title">
  1923. <xsl:apply-templates/>
  1924. </xsl:template>
  1925. <xsl:function name="dita-ot:is-block" as="xs:boolean">
  1926. <xsl:param name="element" as="node()"/>
  1927. <xsl:variable name="class" select="string($element/@class)"/>
  1928. <xsl:sequence select="contains($class, ' topic/body ') or
  1929. contains($class, ' topic/shortdesc ') or
  1930. contains($class, ' topic/abstract ') or
  1931. contains($class, ' topic/title ') or
  1932. contains($class, ' topic/section ') or
  1933. contains($class, ' task/info ') or
  1934. contains($class, ' topic/p ') or
  1935. (contains($class, ' topic/image ') and $element/@placement = 'break') or
  1936. contains($class, ' topic/pre ') or
  1937. contains($class, ' topic/note ') or
  1938. contains($class, ' topic/fig ') or
  1939. contains($class, ' topic/dl ') or
  1940. contains($class, ' topic/sl ') or
  1941. contains($class, ' topic/ol ') or
  1942. contains($class, ' topic/ul ') or
  1943. contains($class, ' topic/li ') or
  1944. contains($class, ' topic/sli ') or
  1945. contains($class, ' topic/itemgroup ') or
  1946. contains($class, ' topic/section ') or
  1947. contains($class, ' topic/table ') or
  1948. contains($class, ' topic/entry ') or
  1949. contains($class, ' topic/simpletable ') or
  1950. contains($class, ' topic/stentry ') or
  1951. contains($class, ' topic/example ')"/>
  1952. </xsl:function>
  1953. <!-- ===================================================================== -->
  1954. <!-- ========== STUBS FOR USER PROVIDED OVERRIDE EXTENSIONS ========== -->
  1955. <xsl:template name="gen-user-head">
  1956. <xsl:apply-templates select="." mode="gen-user-head"/>
  1957. </xsl:template>
  1958. <xsl:template match="/|node()|@*" mode="gen-user-head">
  1959. <!-- to customize: copy this to your override transform, add the content you want. -->
  1960. <!-- it will be placed in the HEAD section of the XHTML. -->
  1961. </xsl:template>
  1962. <xsl:template name="gen-user-header">
  1963. <xsl:apply-templates select="." mode="gen-user-header"/>
  1964. </xsl:template>
  1965. <xsl:template match="/|node()|@*" mode="gen-user-header">
  1966. <!-- to customize: copy this to your override transform, add the content you want. -->
  1967. <!-- it will be placed in the running heading section of the XHTML. -->
  1968. </xsl:template>
  1969. <xsl:template name="gen-user-footer">
  1970. <xsl:apply-templates select="." mode="gen-user-footer"/>
  1971. </xsl:template>
  1972. <xsl:template match="/|node()|@*" mode="gen-user-footer">
  1973. <!-- to customize: copy this to your override transform, add the content you want. -->
  1974. <!-- it will be placed in the running footing section of the XHTML. -->
  1975. </xsl:template>
  1976. <xsl:template name="gen-user-sidetoc">
  1977. <xsl:apply-templates select="." mode="gen-user-sidetoc"/>
  1978. </xsl:template>
  1979. <xsl:template match="/|node()|@*" mode="gen-user-sidetoc">
  1980. <!-- to customize: copy this to your override transform, add the content you want. -->
  1981. <!-- Uncomment the line below to have a "freebie" table of contents on the top-right -->
  1982. </xsl:template>
  1983. <xsl:template name="gen-user-scripts">
  1984. <xsl:apply-templates select="." mode="gen-user-scripts"/>
  1985. </xsl:template>
  1986. <xsl:template match="/|node()|@*" mode="gen-user-scripts">
  1987. <!-- to customize: copy this to your override transform, add the content you want. -->
  1988. <!-- It will be placed before the ending HEAD tag -->
  1989. </xsl:template>
  1990. <xsl:template name="gen-user-styles">
  1991. <xsl:apply-templates select="." mode="gen-user-styles"/>
  1992. </xsl:template>
  1993. <xsl:template match="/|node()|@*" mode="gen-user-styles">
  1994. <!-- to customize: copy this to your override transform, add the content you want. -->
  1995. <!-- It will be placed before the ending HEAD tag -->
  1996. </xsl:template>
  1997. <xsl:template name="gen-user-panel-title-pfx">
  1998. <xsl:apply-templates select="." mode="gen-user-panel-title-pfx"/>
  1999. </xsl:template>
  2000. <xsl:template match="/|node()|@*" mode="gen-user-panel-title-pfx">
  2001. <!-- to customize: copy this to your override transform, add the content you want. -->
  2002. <!-- It will be placed immediately after TITLE tag, in the title -->
  2003. </xsl:template>
  2004. <!-- ===================================================================== -->
  2005. <!-- ========== DEFAULT PAGE LAYOUT ========== -->
  2006. <xsl:template name="chapter-setup">
  2007. <html>
  2008. <xsl:call-template name="setTopicLanguage"/>
  2009. <xsl:call-template name="chapterHead"/>
  2010. <xsl:call-template name="chapterBody"/>
  2011. </html>
  2012. </xsl:template>
  2013. <xsl:template name="setTopicLanguage">
  2014. <xsl:variable name="childlang">
  2015. <xsl:apply-templates select="/*" mode="get-first-topic-lang"/>
  2016. </xsl:variable>
  2017. <xsl:variable name="direction" as="xs:boolean">
  2018. <xsl:call-template name="bidi-area">
  2019. <xsl:with-param name="parentlang" select="$childlang"/>
  2020. </xsl:call-template>
  2021. </xsl:variable>
  2022. <xsl:call-template name="generate-lang">
  2023. <xsl:with-param name="lang" select="$childlang"/>
  2024. </xsl:call-template>
  2025. <xsl:if test="$direction">
  2026. <xsl:attribute name="dir">rtl</xsl:attribute>
  2027. </xsl:if>
  2028. </xsl:template>
  2029. <xsl:template name="chapterHead">
  2030. <xsl:apply-templates select="." mode="chapterHead"/>
  2031. </xsl:template>
  2032. <xsl:template match="*" mode="chapterHead">
  2033. <head>
  2034. <!-- initial meta information -->
  2035. <xsl:call-template name="generateCharset"/> <!-- Set the character set to UTF-8 -->
  2036. <xsl:call-template name="generateDefaultCopyright"/> <!-- Generate a default copyright, if needed -->
  2037. <xsl:call-template name="generateDefaultMeta"/> <!-- Standard meta for security, robots, etc -->
  2038. <xsl:call-template name="getMeta"/> <!-- Process metadata from topic prolog -->
  2039. <xsl:call-template name="copyright"/> <!-- Generate copyright, if specified manually -->
  2040. <xsl:call-template name="generateCssLinks"/> <!-- Generate links to CSS files -->
  2041. <xsl:call-template name="generateChapterTitle"/> <!-- Generate the <title> element -->
  2042. <xsl:call-template name="gen-user-head" /> <!-- include user's XSL HEAD processing here -->
  2043. <xsl:call-template name="gen-user-scripts" /> <!-- include user's XSL javascripts here -->
  2044. <xsl:call-template name="gen-user-styles" /> <!-- include user's XSL style element and content here -->
  2045. <xsl:call-template name="processHDF"/> <!-- Add user HDF file, if specified -->
  2046. </head>
  2047. </xsl:template>
  2048. <!-- If there is no copyright in the document, make the standard one -->
  2049. <xsl:template name="generateDefaultCopyright">
  2050. <xsl:if test="not(//*[contains(@class, ' topic/copyright ')])">
  2051. <meta name="copyright">
  2052. <xsl:attribute name="content">
  2053. <xsl:text>(C) </xsl:text>
  2054. <xsl:call-template name="getVariable">
  2055. <xsl:with-param name="id" select="'Copyright'"/>
  2056. </xsl:call-template>
  2057. <xsl:text> </xsl:text>
  2058. <xsl:value-of select="$YEAR"/>
  2059. </xsl:attribute>
  2060. </meta>
  2061. <meta name="DC.rights.owner">
  2062. <xsl:attribute name="content">
  2063. <xsl:text>(C) </xsl:text>
  2064. <xsl:call-template name="getVariable">
  2065. <xsl:with-param name="id" select="'Copyright'"/>
  2066. </xsl:call-template>
  2067. <xsl:text> </xsl:text><xsl:value-of select="$YEAR"/>
  2068. </xsl:attribute>
  2069. </meta>
  2070. </xsl:if>
  2071. </xsl:template>
  2072. <!-- Output metadata that should appear in every XHTML topic -->
  2073. <xsl:template name="generateDefaultMeta">
  2074. <xsl:if test="$genDefMeta = 'yes'">
  2075. <meta name="security" content="public"/>
  2076. <meta name="Robots" content="index,follow" />
  2077. </xsl:if>
  2078. </xsl:template>
  2079. <!-- Generate links to CSS files -->
  2080. <xsl:template name="generateCssLinks">
  2081. <xsl:variable name="childlang">
  2082. <xsl:choose>
  2083. <!-- Update with DITA 1.2: /dita can have xml:lang -->
  2084. <xsl:when test="self::dita[not(@xml:lang)]">
  2085. <xsl:for-each select="*[1]"><xsl:call-template name="getLowerCaseLang"/></xsl:for-each>
  2086. </xsl:when>
  2087. <xsl:otherwise><xsl:call-template name="getLowerCaseLang"/></xsl:otherwise>
  2088. </xsl:choose>
  2089. </xsl:variable>
  2090. <xsl:variable name="direction">
  2091. <xsl:apply-templates select="." mode="get-render-direction">
  2092. <xsl:with-param name="lang" select="$childlang"/>
  2093. </xsl:apply-templates>
  2094. </xsl:variable>
  2095. <xsl:variable name="urltest" as="xs:boolean"> <!-- test for URL -->
  2096. <xsl:call-template name="url-string">
  2097. <xsl:with-param name="urltext" select="concat($CSSPATH, $CSS)"/>
  2098. </xsl:call-template>
  2099. </xsl:variable>
  2100. <xsl:choose>
  2101. <xsl:when test="$direction = 'rtl' and $urltest ">
  2102. <link rel="stylesheet" type="text/css" href="{$CSSPATH}{$bidi-dita-css}" />
  2103. </xsl:when>
  2104. <xsl:when test="$direction = 'rtl' and not($urltest)">
  2105. <link rel="stylesheet" type="text/css" href="{$PATH2PROJ}{$CSSPATH}{$bidi-dita-css}" />
  2106. </xsl:when>
  2107. <xsl:when test="$urltest">
  2108. <link rel="stylesheet" type="text/css" href="{$CSSPATH}{$dita-css}" />
  2109. </xsl:when>
  2110. <xsl:otherwise>
  2111. <link rel="stylesheet" type="text/css" href="{$PATH2PROJ}{$CSSPATH}{$dita-css}" />
  2112. </xsl:otherwise>
  2113. </xsl:choose>
  2114. <!-- Add user's style sheet if requested to -->
  2115. <xsl:if test="string-length($CSS) > 0">
  2116. <xsl:choose>
  2117. <xsl:when test="$urltest">
  2118. <link rel="stylesheet" type="text/css" href="{$CSSPATH}{$CSS}" />
  2119. </xsl:when>
  2120. <xsl:otherwise>
  2121. <link rel="stylesheet" type="text/css" href="{$PATH2PROJ}{$CSSPATH}{$CSS}" />
  2122. </xsl:otherwise>
  2123. </xsl:choose>
  2124. </xsl:if>
  2125. </xsl:template>
  2126. <xsl:template name="generateChapterTitle">
  2127. <!-- Title processing - special handling for short descriptions -->
  2128. <title>
  2129. <xsl:call-template name="gen-user-panel-title-pfx"/> <!-- hook for a user-XSL title prefix -->
  2130. <xsl:variable name="maintitle"><xsl:apply-templates select="/*[contains(@class, ' topic/topic ')]/*[contains(@class, ' topic/title ')]" mode="text-only"/></xsl:variable>
  2131. <xsl:variable name="ditamaintitle"><xsl:apply-templates select="/dita/*[contains(@class, ' topic/topic ')][1]/*[contains(@class, ' topic/title ')]" mode="text-only"/></xsl:variable>
  2132. <xsl:choose>
  2133. <xsl:when test="string-length($maintitle) > 0"><xsl:value-of select="normalize-space($maintitle)"/></xsl:when>
  2134. <xsl:when test="string-length($ditamaintitle) > 0"><xsl:value-of select="normalize-space($ditamaintitle)"/></xsl:when>
  2135. <xsl:otherwise><xsl:text>***</xsl:text>
  2136. <xsl:apply-templates select="." mode="ditamsg:no-title-for-topic"/>
  2137. </xsl:otherwise>
  2138. </xsl:choose>
  2139. </title>
  2140. </xsl:template>
  2141. <!-- Add user's head XHTML code snippet, if specified -->
  2142. <xsl:template name="processHDF">
  2143. <xsl:if test="string-length($HDFFILE) > 0">
  2144. <xsl:apply-templates select="document($HDFFILE, /)" mode="add-HDF"/>
  2145. </xsl:if>
  2146. </xsl:template>
  2147. <xsl:template name="chapterBody">
  2148. <xsl:apply-templates select="." mode="chapterBody"/>
  2149. </xsl:template>
  2150. <xsl:template match="*" mode="chapterBody">
  2151. <body>
  2152. <xsl:apply-templates select="." mode="addAttributesToHtmlBodyElement"/>
  2153. <xsl:call-template name="setaname"/> <!-- For HTML4 compatibility, if needed -->
  2154. <xsl:apply-templates select="." mode="addHeaderToHtmlBodyElement"/>
  2155. <!-- Include a user's XSL call here to generate a toc based on what's a child of topic -->
  2156. <xsl:call-template name="gen-user-sidetoc"/>
  2157. <xsl:apply-templates select="." mode="addContentToHtmlBodyElement"/>
  2158. <xsl:apply-templates select="." mode="addFooterToHtmlBodyElement"/>
  2159. </body>
  2160. </xsl:template>
  2161. <!-- Add all attributes. To add your own additional attributes, use mode="addAttributesToBody". -->
  2162. <xsl:template match="*" mode="addAttributesToHtmlBodyElement">
  2163. <!-- Already put xml:lang on <html>; do not copy to body with commonattributes -->
  2164. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]/@outputclass" mode="add-ditaval-style"/>
  2165. <!--output parent or first "topic" tag's outputclass as class -->
  2166. <xsl:if test="@outputclass">
  2167. <xsl:attribute name="class" select="@outputclass"/>
  2168. </xsl:if>
  2169. <xsl:if test="self::dita">
  2170. <xsl:if test="*[contains(@class, ' topic/topic ')][1]/@outputclass">
  2171. <xsl:attribute name="class" select="*[contains(@class, ' topic/topic ')][1]/@outputclass"/>
  2172. </xsl:if>
  2173. </xsl:if>
  2174. <xsl:call-template name="setid"/>
  2175. <xsl:apply-templates select="." mode="addAttributesToBody"/>
  2176. </xsl:template>
  2177. <!-- Override this template to add any standard attributes to
  2178. the HTML <body> element. Current context is the root
  2179. element of the doc. -->
  2180. <xsl:template match="*" mode="addAttributesToBody">
  2181. </xsl:template>
  2182. <xsl:attribute-set name="banner">
  2183. <xsl:attribute name="role">banner</xsl:attribute>
  2184. </xsl:attribute-set>
  2185. <!-- Process <body> content that is appropriate for HTML5 header section. -->
  2186. <xsl:template match="*" mode="addHeaderToHtmlBodyElement">
  2187. <xsl:variable name="header-content" as="node()*">
  2188. <xsl:call-template name="generateBreadcrumbs"/>
  2189. <xsl:call-template name="gen-user-header"/> <!-- include user's XSL running header here -->
  2190. <xsl:call-template name="processHDR"/>
  2191. <xsl:if test="$INDEXSHOW = 'yes'">
  2192. <xsl:apply-templates select="/*/*[contains(@class, ' topic/prolog ')]/*[contains(@class, ' topic/metadata ')]/*[contains(@class, ' topic/keywords ')]/*[contains(@class, ' topic/indexterm ')] |
  2193. /dita/*[1]/*[contains(@class, ' topic/prolog ')]/*[contains(@class, ' topic/metadata ')]/*[contains(@class, ' topic/keywords ')]/*[contains(@class, ' topic/indexterm ')]"/>
  2194. </xsl:if>
  2195. </xsl:variable>
  2196. <xsl:if test="exists($header-content)">
  2197. <header xsl:use-attribute-sets="banner">
  2198. <xsl:sequence select="$header-content"/>
  2199. </header>
  2200. </xsl:if>
  2201. </xsl:template>
  2202. <xsl:attribute-set name="main">
  2203. <xsl:attribute name="role">main</xsl:attribute>
  2204. </xsl:attribute-set>
  2205. <xsl:attribute-set name="article">
  2206. <xsl:attribute name="role">article</xsl:attribute>
  2207. </xsl:attribute-set>
  2208. <xsl:template match="*" mode="addContentToHtmlBodyElement">
  2209. <main xsl:use-attribute-sets="main">
  2210. <article xsl:use-attribute-sets="article">
  2211. <xsl:attribute name="aria-labelledby">
  2212. <xsl:apply-templates select="*[contains(@class,' topic/title ')] |
  2213. self::dita/*[1]/*[contains(@class,' topic/title ')]" mode="return-aria-label-id"/>
  2214. </xsl:attribute>
  2215. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
  2216. <xsl:apply-templates/> <!-- this will include all things within topic; therefore, -->
  2217. <!-- title content will appear here by fall-through -->
  2218. <!-- followed by prolog (but no fall-through is permitted for it) -->
  2219. <!-- followed by body content, again by fall-through in document order -->
  2220. <!-- followed by related links -->
  2221. <!-- followed by child topics by fall-through -->
  2222. <xsl:call-template name="gen-endnotes"/> <!-- include footnote-endnotes -->
  2223. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  2224. </article>
  2225. </main>
  2226. </xsl:template>
  2227. <xsl:attribute-set name="footer">
  2228. <xsl:attribute name="role">contentinfo</xsl:attribute>
  2229. </xsl:attribute-set>
  2230. <xsl:template match="*" mode="addFooterToHtmlBodyElement">
  2231. <xsl:variable name="footer-content" as="node()*">
  2232. <xsl:call-template name="gen-user-footer"/> <!-- include user's XSL running footer here -->
  2233. <xsl:call-template name="processFTR"/> <!-- Include XHTML footer, if specified -->
  2234. </xsl:variable>
  2235. <xsl:if test="exists($footer-content)">
  2236. <footer xsl:use-attribute-sets="footer">
  2237. <xsl:sequence select="$footer-content"/>
  2238. </footer>
  2239. </xsl:if>
  2240. </xsl:template>
  2241. <xsl:template name="generateBreadcrumbs">
  2242. <!-- Insert previous/next/ancestor breadcrumbs links at the top of the html5. -->
  2243. <xsl:apply-templates select="*[contains(@class, ' topic/related-links ')]" mode="breadcrumb"/>
  2244. </xsl:template>
  2245. <xsl:template name="processHDR">
  2246. <!-- Add user's running heading XHTML code snippet if requested to -->
  2247. <xsl:if test="string-length($HDRFILE) > 0">
  2248. <xsl:copy-of select="document($HDRFILE, /)"/>
  2249. </xsl:if>
  2250. </xsl:template>
  2251. <xsl:template name="processFTR">
  2252. <!-- Add user's running footing XHTML code snippet if requested to -->
  2253. <xsl:if test="string-length($FTRFILE) > 0">
  2254. <xsl:copy-of select="document($FTRFILE, /)"/>
  2255. </xsl:if>
  2256. </xsl:template>
  2257. <xsl:template name="get-file-name">
  2258. <xsl:param name="file-path"/>
  2259. <xsl:choose>
  2260. <xsl:when test="contains($file-path, '\')">
  2261. <xsl:call-template name="get-file-name">
  2262. <xsl:with-param name="file-path" select="substring-after($file-path, '\')"/>
  2263. </xsl:call-template>
  2264. </xsl:when>
  2265. <xsl:when test="contains($file-path, '/')">
  2266. <xsl:call-template name="get-file-name">
  2267. <xsl:with-param name="file-path" select="substring-after($file-path, '/')"/>
  2268. </xsl:call-template>
  2269. </xsl:when>
  2270. <xsl:otherwise>
  2271. <xsl:value-of select="$file-path"/>
  2272. </xsl:otherwise>
  2273. </xsl:choose>
  2274. </xsl:template>
  2275. <!-- Add for "New <data> element (#9)" in DITA 1.1 -->
  2276. <xsl:template match="*[contains(@class, ' topic/data ')] |
  2277. *[contains(@class, ' topic/data-about ')]" />
  2278. <!-- Add for "Support foreign content vocabularies such as
  2279. MathML and SVG with <unknown> (#35) " in DITA 1.1 -->
  2280. <xsl:template match="*[contains(@class, ' topic/foreign ') or contains(@class, ' topic/unknown ')]"/>
  2281. <!-- Add for index-base element. This template is used to prevent
  2282. any processing applied on index-base element -->
  2283. <xsl:template match="*[contains(@class, ' topic/index-base ')]"/>
  2284. <!-- Add for text element. -->
  2285. <xsl:template match="*[contains(@class, ' topic/text ')]">
  2286. <xsl:apply-templates/>
  2287. </xsl:template>
  2288. <!-- By default, ignore desc and force pull-processing -->
  2289. <xsl:template match="*[contains(@class, ' topic/desc ')]" name="topic.desc" priority="-10"/>
  2290. <!-- Add for bodydiv and sectiondiv-->
  2291. <xsl:template match="*[contains(@class, ' topic/bodydiv ') or contains(@class, ' topic/sectiondiv ')]">
  2292. <div>
  2293. <xsl:call-template name="commonattributes"/>
  2294. <xsl:call-template name="setid"/>
  2295. <xsl:apply-templates/>
  2296. </div>
  2297. </xsl:template>
  2298. <!-- Function to look up a target in the keyref file -->
  2299. <xsl:template match="*" mode="find-keyref-target">
  2300. <!-- Deprecated since 2.1 -->
  2301. <xsl:param name="keys" select="@keyref"/>
  2302. <!-- Deprecated since 2.1 -->
  2303. <xsl:param name="target" select="@href"/>
  2304. <xsl:choose>
  2305. <xsl:when test="contains($target, '://')">
  2306. <xsl:value-of select="$target"/>
  2307. </xsl:when>
  2308. <!-- edited on 2010-12-17 for keyref bug:3114411 start-->
  2309. <xsl:when test="contains($target, '#')">
  2310. <xsl:value-of select="concat($PATH2PROJ, substring-before(substring-before($target, '#'), '.'), $OUTEXT, '#', substring-after($target, '#'))"/>
  2311. </xsl:when>
  2312. <xsl:when test="$target = ''">
  2313. <xsl:value-of select="$OUTEXT"/>
  2314. </xsl:when>
  2315. <xsl:otherwise>
  2316. <xsl:value-of select="concat($PATH2PROJ, substring-before($target, '.'), $OUTEXT)"/>
  2317. </xsl:otherwise>
  2318. <!-- edited on 2010-12-17 for keyref bug:3114411 end-->
  2319. </xsl:choose>
  2320. </xsl:template>
  2321. <!-- This template converts phrase-like elements into links based on keyref. -->
  2322. <!-- 20090331: Update to ensure cite with keyref continues to use <cite>,
  2323. plus move common code to single template -->
  2324. <xsl:template match="*" mode="turning-to-link">
  2325. <xsl:param name="keys" select="@keyref" as="xs:string?"/>
  2326. <xsl:param name="type" select="name()" as="xs:string"/>
  2327. <xsl:variable name="elementName" as="xs:string">
  2328. <xsl:choose>
  2329. <xsl:when test="$type = 'cite'">cite</xsl:when>
  2330. <xsl:otherwise>span</xsl:otherwise>
  2331. </xsl:choose>
  2332. </xsl:variable>
  2333. <a>
  2334. <xsl:apply-templates select="." mode="add-linking-attributes"/>
  2335. <xsl:apply-templates select="." mode="add-desc-as-hoverhelp"/>
  2336. <xsl:element name="{$elementName}">
  2337. <xsl:call-template name="commonattributes">
  2338. <xsl:with-param name="default-output-class">
  2339. <xsl:if test="normalize-space($type) != name()">
  2340. <xsl:value-of select="$type"/>
  2341. </xsl:if>
  2342. </xsl:with-param>
  2343. </xsl:call-template>
  2344. <xsl:apply-templates/>
  2345. </xsl:element>
  2346. </a>
  2347. </xsl:template>
  2348. <!-- MESSAGES: Refactoring places each message in a moded template, so that users
  2349. may more easily override a message for one or all cases. -->
  2350. <xsl:template match="*" mode="ditamsg:no-glossentry-for-key">
  2351. <xsl:param name="matching-keys"/>
  2352. <xsl:call-template name="output-message">
  2353. <xsl:with-param name="id" select="'DOTX058W'"/>
  2354. <xsl:with-param name="msgparams">%1=<xsl:value-of select="$matching-keys"/>;%2=<xsl:value-of select="name()"/></xsl:with-param>
  2355. </xsl:call-template>
  2356. </xsl:template>
  2357. <xsl:template match="*" mode="ditamsg:no-title-for-topic">
  2358. <xsl:call-template name="output-message">
  2359. <xsl:with-param name="id" select="'DOTX037W'"/>
  2360. </xsl:call-template>
  2361. </xsl:template>
  2362. <xsl:template match="*" mode="ditamsg:longdescref-on-object">
  2363. <xsl:call-template name="output-message">
  2364. <xsl:with-param name="id" select="'DOTX038I'"/>
  2365. <xsl:with-param name="msgparams">%1=<xsl:value-of select="name(.)"/></xsl:with-param>
  2366. </xsl:call-template>
  2367. </xsl:template>
  2368. <xsl:template match="*" mode="ditamsg:required-cleanup-in-content">
  2369. <xsl:call-template name="output-message">
  2370. <xsl:with-param name="id" select="'DOTX039W'"/>
  2371. </xsl:call-template>
  2372. </xsl:template>
  2373. <xsl:template match="*" mode="ditamsg:draft-comment-in-content">
  2374. <xsl:call-template name="output-message">
  2375. <xsl:with-param name="id" select="'DOTX040I'"/>
  2376. </xsl:call-template>
  2377. </xsl:template>
  2378. <xsl:template match="*" mode="ditamsg:section-with-multiple-titles">
  2379. <xsl:param name="actual-element" select="name(.)"/>
  2380. <xsl:call-template name="output-message">
  2381. <xsl:with-param name="id" select="'DOTX041W'"/>
  2382. <xsl:with-param name="msgparams">%1=<xsl:value-of select="$actual-element"/></xsl:with-param>
  2383. </xsl:call-template>
  2384. </xsl:template>
  2385. <xsl:include href="plugin:org.dita.html5:xsl/tables.xsl"/>
  2386. <xsl:include href="plugin:org.dita.html5:xsl/simpletable.xsl"/>
  2387. <xsl:key name="enumerableByClass"
  2388. match="*[contains(@class, ' topic/fig ')][*[contains(@class, ' topic/title ')]] |
  2389. *[contains(@class, ' topic/table ')][*[contains(@class, ' topic/title ')]] |
  2390. *[contains(@class,' topic/fn ') and empty(@callout)]"
  2391. use="tokenize(@class, '\s+')"/>
  2392. <xsl:template name="generateCharset">
  2393. <meta charset="UTF-8"/>
  2394. </xsl:template>
  2395. <xsl:template match="*[contains(@class,' topic/title ')]" mode="gen-metadata"/>
  2396. <xsl:template match="*[contains(@class,' topic/shortdesc ')]" mode="gen-metadata">
  2397. <xsl:variable name="shortmeta">
  2398. <xsl:apply-templates select="*|text()" mode="text-only"/>
  2399. </xsl:variable>
  2400. <meta name="description">
  2401. <xsl:attribute name="content">
  2402. <xsl:value-of select="normalize-space($shortmeta)"/>
  2403. </xsl:attribute>
  2404. </meta>
  2405. </xsl:template>
  2406. <!-- Notes -->
  2407. <xsl:template match="*" mode="process.note.common-processing">
  2408. <xsl:param name="type" select="@type"/>
  2409. <xsl:param name="title">
  2410. <xsl:call-template name="getVariable">
  2411. <xsl:with-param name="id" select="concat(upper-case(substring($type, 1, 1)), substring($type, 2))"/>
  2412. </xsl:call-template>
  2413. </xsl:param>
  2414. <div>
  2415. <xsl:call-template name="commonattributes">
  2416. <xsl:with-param name="default-output-class" select="string-join(($type, concat('note_', $type)), ' ')"/>
  2417. </xsl:call-template>
  2418. <xsl:call-template name="setidaname"/>
  2419. <!-- Normal flags go before the generated title; revision flags only go on the content. -->
  2420. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]/prop" mode="ditaval-outputflag"/>
  2421. <span class="note__title">
  2422. <xsl:copy-of select="$title"/>
  2423. <xsl:call-template name="getVariable">
  2424. <xsl:with-param name="id" select="'ColonSymbol'"/>
  2425. </xsl:call-template>
  2426. </span>
  2427. <xsl:text> </xsl:text>
  2428. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]/revprop" mode="ditaval-outputflag"/>
  2429. <xsl:apply-templates/>
  2430. <!-- Normal end flags and revision end flags both go out after the content. -->
  2431. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  2432. </div>
  2433. </xsl:template>
  2434. <xsl:template match="*" mode="process.note.caution">
  2435. <xsl:apply-templates select="." mode="process.note.common-processing"/>
  2436. </xsl:template>
  2437. <xsl:template match="*" mode="process.note.danger">
  2438. <xsl:apply-templates select="." mode="process.note.common-processing"/>
  2439. </xsl:template>
  2440. <!-- Figure -->
  2441. <!-- Figure caption -->
  2442. <xsl:template name="place-fig-lbl">
  2443. <xsl:param name="stringName"/>
  2444. <!-- Number of fig/title's including this one -->
  2445. <xsl:variable name="fig-count-actual" select="count(preceding::*[contains(@class, ' topic/fig ')]/*[contains(@class, ' topic/title ')])+1"/>
  2446. <xsl:variable name="ancestorlang">
  2447. <xsl:call-template name="getLowerCaseLang"/>
  2448. </xsl:variable>
  2449. <xsl:choose>
  2450. <!-- title -or- title & desc -->
  2451. <xsl:when test="*[contains(@class, ' topic/title ')]">
  2452. <figcaption>
  2453. <span class="fig--title-label">
  2454. <xsl:choose> <!-- Hungarian: "1. Figure " -->
  2455. <xsl:when test="$ancestorlang = ('hu', 'hu-hu')">
  2456. <xsl:value-of select="$fig-count-actual"/>
  2457. <xsl:text>. </xsl:text>
  2458. <xsl:call-template name="getVariable">
  2459. <xsl:with-param name="id" select="'Figure'"/>
  2460. </xsl:call-template>
  2461. <xsl:text> </xsl:text>
  2462. </xsl:when>
  2463. <xsl:otherwise>
  2464. <xsl:call-template name="getVariable">
  2465. <xsl:with-param name="id" select="'Figure'"/>
  2466. </xsl:call-template>
  2467. <xsl:text> </xsl:text>
  2468. <xsl:value-of select="$fig-count-actual"/>
  2469. <xsl:text>. </xsl:text>
  2470. </xsl:otherwise>
  2471. </xsl:choose>
  2472. </span>
  2473. <xsl:apply-templates select="*[contains(@class, ' topic/title ')]" mode="figtitle"/>
  2474. <xsl:if test="*[contains(@class, ' topic/desc ')]">
  2475. <xsl:text>. </xsl:text>
  2476. </xsl:if>
  2477. <xsl:for-each select="*[contains(@class, ' topic/desc ')]">
  2478. <span class="figdesc">
  2479. <xsl:call-template name="commonattributes"/>
  2480. <xsl:apply-templates select="." mode="figdesc"/>
  2481. </span>
  2482. </xsl:for-each>
  2483. </figcaption>
  2484. </xsl:when>
  2485. <!-- desc -->
  2486. <xsl:when test="*[contains(@class, ' topic/desc ')]">
  2487. <xsl:for-each select="*[contains(@class, ' topic/desc ')]">
  2488. <figcaption>
  2489. <xsl:call-template name="commonattributes"/>
  2490. <xsl:apply-templates select="." mode="figdesc"/>
  2491. </figcaption>
  2492. </xsl:for-each>
  2493. </xsl:when>
  2494. </xsl:choose>
  2495. </xsl:template>
  2496. <xsl:include href="plugin:org.dita.html5:xsl/css-class.xsl"/>
  2497. <xsl:include href="plugin:org.dita.html5:xsl/functions.xsl"/>
  2498. </xsl:stylesheet>