dita2htmlImpl.xsl 128 KB

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