dita2htmlImpl.xsl 128 KB

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