step1.xsl 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881
  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, 2006 All Rights Reserved. -->
  6. <xsl:stylesheet version="2.0"
  7. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  8. xmlns:related-links="http:// dita-ot.sourceforge.net/ns/200709/related-links"
  9. exclude-result-prefixes="related-links"
  10. >
  11. <!--
  12. ALL ELEMENTS CAN TAKE @xtrf, @xtrc, @xml:lang
  13. Attributes on dita:
  14. Attributes on section:
  15. Attributes on sectiontitle:
  16. Attributes on block:
  17. @xml:space="preserve"
  18. @position="center"
  19. @expanse="column|page" - column is default, page means ignore any indent
  20. @indent="digit" - additional indent new for this element
  21. @compact="yes|no"
  22. @leadin="" - text that appears once at the start of the element. It does not get the
  23. extra indenting specified by @indent.
  24. Attributes on text:
  25. @style="bold|italics|underlined|tt|sup|sub"
  26. @href="" [target, if this is a link]
  27. @format="" copy through @format for a link
  28. @scope="" copy through @scope for a link
  29. -->
  30. <xsl:import href="plugin:org.dita.base:xsl/common/output-message.xsl"/>
  31. <xsl:import href="plugin:org.dita.base:xsl/common/dita-utilities.xsl"/>
  32. <xsl:import href="plugin:org.dita.base:xsl/common/related-links.xsl"/>
  33. <xsl:import href="rel-links.xsl"/>
  34. <xsl:output method="xml"
  35. encoding="UTF-8"
  36. indent="no"
  37. />
  38. <xsl:param name="FILENAME"></xsl:param> <!-- Needed by rel-links -->
  39. <xsl:param name="DRAFT">no</xsl:param> <!-- Include draft information? 'no' or 'yes' -->
  40. <!-- Deprecated since 2.3 -->
  41. <xsl:variable name="msgprefix">DOTX</xsl:variable> <!-- Prefix for messages -->
  42. <xsl:variable name="OUTEXT"></xsl:variable> <!-- extension will go at the end of links -->
  43. <xsl:variable name="newline"><xsl:text>
  44. </xsl:text></xsl:variable>
  45. <!-- Copy debug attributes to the elements we are creating -->
  46. <xsl:template name="debug"><xsl:apply-templates select="@xtrf|@xtrc"/></xsl:template>
  47. <xsl:template match="@xtrf|@xtrc">
  48. <xsl:copy/>
  49. </xsl:template>
  50. <!-- Copy attributes that can appear on any element in the intermediate syntax -->
  51. <xsl:template name="commonatts">
  52. <xsl:call-template name="debug"/>
  53. <xsl:apply-templates select="@xml:lang"/>
  54. </xsl:template>
  55. <xsl:template match="@xml:lang">
  56. <xsl:copy/>
  57. </xsl:template>
  58. <!-- Root rule. Intermediate format will always have a <dita> wrapper. -->
  59. <xsl:template match="/">
  60. <xsl:variable name="lowerLang">
  61. <xsl:for-each select="*[1]"><xsl:call-template name="getLowerCaseLang"/></xsl:for-each>
  62. </xsl:variable>
  63. <xsl:variable name="dir">
  64. <xsl:choose>
  65. <xsl:when test="$lowerLang='he' or $lowerLang='he-il' or $lowerLang='ar' or $lowerLang='ar-eg'">rtl</xsl:when>
  66. <xsl:otherwise>ltr</xsl:otherwise>
  67. </xsl:choose>
  68. </xsl:variable>
  69. <dita dir="{$dir}">
  70. <xsl:apply-templates/>
  71. <xsl:apply-templates select="//*[contains(@class,' topic/fn ')]" mode="endnotes"/>
  72. </dita>
  73. </xsl:template>
  74. <!-- Place the topic in a block. No indenting needed for topic. -->
  75. <xsl:template match="*[contains(@class,' topic/topic ')]">
  76. <xsl:choose>
  77. <xsl:when test="parent::*[contains(@class,' topic/topic ')]">
  78. <block><xsl:call-template name="commonatts"/><xsl:apply-templates/></block>
  79. </xsl:when>
  80. <xsl:when test="parent::dita and preceding-sibling::*">
  81. <block><xsl:call-template name="commonatts"/><xsl:apply-templates/></block>
  82. </xsl:when>
  83. <xsl:otherwise>
  84. <!-- First topic in the file. Call debug: attributes go on <dita>. -->
  85. <xsl:call-template name="commonatts"/>
  86. <xsl:apply-templates/>
  87. </xsl:otherwise>
  88. </xsl:choose>
  89. </xsl:template>
  90. <!-- Place the topic's title in a block for centering -->
  91. <xsl:template match="*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/title ')]">
  92. <block position="center"><xsl:call-template name="commonatts"/>
  93. <text style="bold"><xsl:call-template name="commonatts"/><xsl:apply-templates/></text>
  94. </block>
  95. <xsl:apply-templates select="." mode="check-for-prereq"/>
  96. </xsl:template>
  97. <!-- These block elements do not get special formatting (though the children may);
  98. drop them into a block element. -->
  99. <xsl:template match="*[contains(@class,' topic/p ')] |
  100. *[contains(@class,' topic/shortdesc ')] |
  101. *[contains(@class,' topic/fig ')]">
  102. <!-- save frame on figure? -->
  103. <block><xsl:call-template name="commonatts"/><xsl:apply-templates/></block>
  104. <xsl:if test="contains(@class,' topic/shortdesc ')">
  105. <xsl:apply-templates select="." mode="check-for-prereq"/>
  106. </xsl:if>
  107. </xsl:template>
  108. <!-- These titles should come out as bold -->
  109. <xsl:template match="*[contains(@class,' topic/fig ')]/*[contains(@class,' topic/title ')]">
  110. <xsl:variable name="fignum">
  111. <xsl:value-of select="count(preceding::*[contains(@class,' topic/fig ')])+1"/>
  112. </xsl:variable>
  113. <block><xsl:call-template name="commonatts"/>
  114. <text style="bold">
  115. <xsl:call-template name="getVariable"><xsl:with-param name="id" select="'Figure'"/></xsl:call-template>
  116. <xsl:text> </xsl:text><xsl:value-of select="$fignum"/>. <xsl:text/>
  117. <xsl:apply-templates/>
  118. </text>
  119. </block>
  120. </xsl:template>
  121. <xsl:template match="*[contains(@class,' topic/linklist ')]/*[contains(@class,' topic/title ')]">
  122. <block><xsl:call-template name="commonatts"/>
  123. <text style="bold"><xsl:apply-templates/></text>
  124. </block>
  125. </xsl:template>
  126. <!-- Sections and examples format the same today, so put them into a section element.
  127. This is used to distinguish sections, usually with titles, which can get special
  128. formatting as such in output formats like troff. -->
  129. <xsl:template match="*[contains(@class,' topic/section ')] | *[contains(@class,' topic/example ')]">
  130. <section><xsl:call-template name="commonatts"/>
  131. <!-- Ensure the title comes first -->
  132. <xsl:apply-templates select="*[contains(@class,' topic/title ')]"/>
  133. <xsl:apply-templates select="text()|*[not(contains(@class,' topic/title '))]"/>
  134. </section>
  135. </xsl:template>
  136. <!-- Match section or example titles -->
  137. <xsl:template match="*[contains(@class,' topic/section ') or contains(@class,' topic/example ')]/*[contains(@class,' topic/title ')]">
  138. <sectiontitle><xsl:call-template name="commonatts"/><xsl:apply-templates/></sectiontitle>
  139. </xsl:template>
  140. <!-- If needed, these can be broken apart to indicate that pre uses monospace. Could do this
  141. by adding @style to the block. -->
  142. <xsl:template match="*[contains(@class,' topic/pre ')] |
  143. *[contains(@class,' topic/lines ')]">
  144. <block xml:space="preserve"><xsl:call-template name="commonatts"/><xsl:apply-templates/></block>
  145. </xsl:template>
  146. <!-- Indent lq 6 spaces, and treat as any other block. -->
  147. <xsl:template match="*[contains(@class,' topic/lq ')]">
  148. <block indent="6">
  149. <xsl:call-template name="commonatts"/>
  150. <xsl:apply-templates/>
  151. <xsl:if test="@reftitle"><text style="italics"><xsl:text> </xsl:text><xsl:value-of select="@reftitle"/></text></xsl:if>
  152. <xsl:if test="@href"><text> [<xsl:value-of select="@href"/>]</text></xsl:if>
  153. </block>
  154. </xsl:template>
  155. <!-- Deterimne the title and place it in a bold text element. Currently all note types
  156. format the same. In some cases it may be desireable to place the contents into
  157. an additional <block> to set them apart from the note title. -->
  158. <xsl:template match="*[contains(@class,' topic/note ')]">
  159. <xsl:variable name="noteText">
  160. <xsl:choose>
  161. <xsl:when test="not(@type) or @type='note'">
  162. <xsl:call-template name="getVariable"><xsl:with-param name="id" select="'Note'"/></xsl:call-template>
  163. </xsl:when>
  164. <xsl:when test="@type='attention'">
  165. <xsl:call-template name="getVariable"><xsl:with-param name="id" select="'Attention'"/></xsl:call-template>
  166. </xsl:when>
  167. <xsl:when test="@type='caution'">
  168. <xsl:call-template name="getVariable"><xsl:with-param name="id" select="'Caution'"/></xsl:call-template>
  169. </xsl:when>
  170. <xsl:when test="@type='danger'">
  171. <xsl:call-template name="getVariable"><xsl:with-param name="id" select="'Danger'"/></xsl:call-template>
  172. </xsl:when>
  173. <xsl:when test="@type='fastpath'">
  174. <xsl:call-template name="getVariable"><xsl:with-param name="id" select="'Fastpath'"/></xsl:call-template>
  175. </xsl:when>
  176. <xsl:when test="@type='important'">
  177. <xsl:call-template name="getVariable"><xsl:with-param name="id" select="'Important'"/></xsl:call-template>
  178. </xsl:when>
  179. <xsl:when test="@type='remember'">
  180. <xsl:call-template name="getVariable"><xsl:with-param name="id" select="'Remember'"/></xsl:call-template>
  181. </xsl:when>
  182. <xsl:when test="@type='restriction'">
  183. <xsl:call-template name="getVariable"><xsl:with-param name="id" select="'Restriction'"/></xsl:call-template>
  184. </xsl:when>
  185. <xsl:when test="@type='tip'">
  186. <xsl:call-template name="getVariable"><xsl:with-param name="id" select="'Tip'"/></xsl:call-template>
  187. </xsl:when>
  188. <xsl:when test="@type='trouble'">
  189. <xsl:call-template name="getVariable"><xsl:with-param name="id" select="'Trouble'"/></xsl:call-template>
  190. </xsl:when>
  191. <xsl:when test="@type='other' and @othertype">
  192. <xsl:value-of select="@othertype"/>
  193. </xsl:when>
  194. <xsl:otherwise>
  195. <xsl:call-template name="getVariable"><xsl:with-param name="id" select="'Note'"/></xsl:call-template>
  196. </xsl:otherwise>
  197. </xsl:choose>
  198. <xsl:call-template name="getVariable"><xsl:with-param name="id" select="'ColonSymbol'"/></xsl:call-template>
  199. <xsl:text> </xsl:text>
  200. </xsl:variable>
  201. <block><xsl:call-template name="commonatts"/>
  202. <text style="bold"><xsl:call-template name="commonatts"/><xsl:value-of select="$noteText"/></text>
  203. <xsl:apply-templates/>
  204. </block>
  205. </xsl:template>
  206. <!-- All lists are block elements. Store @compact information on the children. -->
  207. <xsl:template match="*[contains(@class,' topic/ul ')] | *[contains(@class,' topic/ol ')] | *[contains(@class,' topic/sl ')]">
  208. <block>
  209. <xsl:call-template name="commonatts"/><xsl:apply-templates/>
  210. </block>
  211. </xsl:template>
  212. <!-- Simple list items do not get any lead-in text. Just indent 3 spaces for each one. -->
  213. <xsl:template match="*[contains(@class,' topic/sli ')]">
  214. <block compact="yes" indent="3"><xsl:call-template name="commonatts"/><xsl:apply-templates/></block>
  215. </xsl:template>
  216. <!-- Ul elements always have * for lead-in text. Add 3 to indent, and store @compact. -->
  217. <xsl:template match="*[contains(@class,' topic/ul ')]/*[contains(@class,' topic/li ')]">
  218. <block leadin="* " indent="3">
  219. <xsl:call-template name="commonatts"/>
  220. <xsl:if test="parent::*[@compact='yes']">
  221. <xsl:attribute name="compact">yes</xsl:attribute>
  222. </xsl:if>
  223. <xsl:apply-templates/>
  224. </block>
  225. </xsl:template>
  226. <xsl:template match="*[contains(@class,' topic/itemgroup ')]" name="topic.itemgroup">
  227. <xsl:if test="preceding-sibling::*"><text><xsl:text> </xsl:text></text></xsl:if>
  228. <xsl:apply-templates/>
  229. </xsl:template>
  230. <!-- Get the current list number. This is a recursive function that counts elements in the
  231. current list, and adds that after the number from each ancestor ordered list item.
  232. The list numbering uses 1.b.iii.4.e.vi formatting (decimal, alpha, Roman, ...) -->
  233. <xsl:template match="*" mode="get-list-number">
  234. <xsl:variable name="depth">
  235. <xsl:value-of select="count(ancestor-or-self::*[contains(@class,' topic/li ')][contains(parent::*/@class,' topic/ol ')])"/>
  236. </xsl:variable>
  237. <xsl:apply-templates select="ancestor::*[contains(@class,' topic/li ')][contains(parent::*/@class,' topic/ol ')][1]" mode="get-list-number"/>
  238. <xsl:choose>
  239. <xsl:when test="$depth mod 3 = 0"><xsl:number count="*" format="i"/>.<xsl:text/></xsl:when>
  240. <xsl:when test="$depth mod 3 = 1"><xsl:number count="*"/>.<xsl:text/></xsl:when>
  241. <xsl:when test="$depth mod 3 = 2"><xsl:number count="*" format="a"/>.<xsl:text/></xsl:when>
  242. </xsl:choose>
  243. </xsl:template>
  244. <!-- Match an ordered list item. Must find the current list number, and use that as lead-in text.
  245. The indent is set to go in as far as the lead-in text. -->
  246. <xsl:template match="*[contains(@class,' topic/ol ')]/*[contains(@class,' topic/li ')]">
  247. <xsl:variable name="listintro">
  248. <!--<xsl:number count="*"/>. <xsl:text/>-->
  249. <xsl:apply-templates select="." mode="get-list-number"/><xsl:text> </xsl:text>
  250. </xsl:variable>
  251. <block leadin="{$listintro}" indent="{string-length($listintro)}">
  252. <xsl:call-template name="commonatts"/>
  253. <xsl:if test="parent::*[@compact='yes']">
  254. <xsl:attribute name="compact">yes</xsl:attribute>
  255. </xsl:if>
  256. <xsl:apply-templates/>
  257. </block>
  258. </xsl:template>
  259. <!-- Drop dl into a block. Descendants will pick up the proper indenting/formatting. -->
  260. <xsl:template match="*[contains(@class,' topic/dl ')]">
  261. <block><xsl:call-template name="commonatts"/><xsl:apply-templates/></block>
  262. </xsl:template>
  263. <!-- Dlentry and dlhead do not need to create additional blocks; children will get blocks. -->
  264. <xsl:template match="*[contains(@class,' topic/dlentry ')]|*[contains(@class,' topic/dlhead ')]">
  265. <xsl:apply-templates/>
  266. </xsl:template>
  267. <!-- Terms and term headings should go into block elements. Bold the term contents -->
  268. <xsl:template match="*[contains(@class,' topic/dt ')]|*[contains(@class,' topic/dthd ')]">
  269. <block><xsl:call-template name="commonatts"/>
  270. <!-- When there are 2 terms, do not create an extra line between them. If this is the first term,
  271. keep the extra space between it and the previous dlentry. -->
  272. <xsl:if test="preceding-sibling::*[1][contains(@class,' topic/dt ')] or
  273. ../../@compact='yes'">
  274. <xsl:attribute name="compact">yes</xsl:attribute>
  275. </xsl:if>
  276. <text style="bold"><xsl:call-template name="commonatts"/>
  277. <xsl:apply-templates/>
  278. </text>
  279. </block>
  280. </xsl:template>
  281. <!-- Indent the definition 9 spaces. The compact=yes value ensures it will appear on the
  282. line after the term. May want to bold ddhd? -->
  283. <xsl:template match="*[contains(@class,' topic/dd ')]|*[contains(@class,' topic/ddhd ')]">
  284. <block indent="9" compact="yes"><xsl:call-template name="commonatts"/><xsl:apply-templates/></block>
  285. </xsl:template>
  286. <!-- Table formatting based off of DL formatting; first column aligns to start of 'page',
  287. second and following columns indent -->
  288. <xsl:template match="*[contains(@class,' topic/simpletable ') or contains(@class,' topic/table ')]">
  289. <block><xsl:call-template name="commonatts"/><xsl:apply-templates/></block>
  290. </xsl:template>
  291. <!-- strow and sthead do not need to create additional blocks; children will get blocks. -->
  292. <xsl:template match="*[contains(@class,' topic/strow ')]|*[contains(@class,' topic/sthead ')]">
  293. <xsl:apply-templates/>
  294. </xsl:template>
  295. <xsl:template match="*[contains(@class,' topic/tgroup ') or contains(@class,' topic/thead ') or contains(@class,' topic/tbody ') or
  296. contains(@class,' topic/row ')]">
  297. <xsl:apply-templates/>
  298. </xsl:template>
  299. <xsl:template match="*[contains(@class,' topic/stentry ')]">
  300. <xsl:choose>
  301. <xsl:when test="preceding-sibling::*[contains(@class,' topic/stentry ')]">
  302. <block indent="9" compact="no">
  303. <xsl:call-template name="commonatts"/>
  304. <xsl:choose>
  305. <xsl:when test="parent::*[contains(@class,' topic/sthead ')]">
  306. <text style="bold"><xsl:call-template name="commonatts"/><xsl:apply-templates/></text>
  307. </xsl:when>
  308. <xsl:otherwise>
  309. <xsl:apply-templates/>
  310. </xsl:otherwise>
  311. </xsl:choose>
  312. </block>
  313. </xsl:when>
  314. <xsl:otherwise>
  315. <block indent="3"><xsl:call-template name="commonatts"/>
  316. <text style="bold"><xsl:call-template name="commonatts"/>
  317. <xsl:apply-templates/>
  318. </text>
  319. </block>
  320. </xsl:otherwise>
  321. </xsl:choose>
  322. </xsl:template>
  323. <xsl:template match="*[contains(@class,' topic/entry ')]">
  324. <xsl:choose>
  325. <xsl:when test="preceding-sibling::*[contains(@class,' topic/entry ')]">
  326. <block indent="9" compact="no">
  327. <xsl:call-template name="commonatts"/>
  328. <xsl:choose>
  329. <xsl:when test="parent::*/parent::*[contains(@class,' topic/thead ')]">
  330. <text style="bold"><xsl:call-template name="commonatts"/><xsl:apply-templates/></text>
  331. </xsl:when>
  332. <xsl:otherwise>
  333. <xsl:apply-templates/>
  334. </xsl:otherwise>
  335. </xsl:choose>
  336. </block>
  337. </xsl:when>
  338. <xsl:otherwise>
  339. <block indent="3"><xsl:call-template name="commonatts"/>
  340. <text style="bold"><xsl:call-template name="commonatts"/>
  341. <xsl:apply-templates/>
  342. </text>
  343. </block>
  344. </xsl:otherwise>
  345. </xsl:choose>
  346. </xsl:template>
  347. <xsl:template name="output-alt-text">
  348. <xsl:choose>
  349. <xsl:when test="*"><xsl:apply-templates/></xsl:when>
  350. <xsl:when test="@alt"><xsl:value-of select="@alt"/></xsl:when>
  351. </xsl:choose>
  352. </xsl:template>
  353. <!-- Images do not appear in text, so use the alternate text -->
  354. <xsl:template match="*[contains(@class,' topic/image ')]">
  355. <xsl:choose>
  356. <xsl:when test="@placement='break'">
  357. <block>
  358. <xsl:call-template name="commonatts"/>
  359. <text><xsl:call-template name="commonatts"/><xsl:call-template name="output-alt-text"/></text>
  360. </block>
  361. </xsl:when>
  362. <xsl:otherwise>
  363. <text><xsl:call-template name="commonatts"/><xsl:call-template name="output-alt-text"/></text>
  364. </xsl:otherwise>
  365. </xsl:choose>
  366. <!-- standalone image in text, need to add newlines after -->
  367. </xsl:template>
  368. <!-- These are all phrase-like elements: drop them into text elements. -->
  369. <xsl:template match="*[contains(@class,' topic/ph ')] |
  370. *[contains(@class,' topic/keyword ')] |
  371. *[contains(@class,' topic/term ')]">
  372. <text><xsl:call-template name="commonatts"/><xsl:apply-templates/></text>
  373. </xsl:template>
  374. <xsl:template name="output-quote">
  375. <xsl:text/>"<xsl:apply-templates/>"<xsl:text/>
  376. </xsl:template>
  377. <xsl:template match="*[contains(@class,' topic/q ')]">
  378. <text><xsl:call-template name="commonatts"/><xsl:call-template name="output-quote"/></text>
  379. </xsl:template>
  380. <xsl:template name="default-state-contents">
  381. <xsl:if test="@name!=name()"><xsl:value-of select="name()"/>: </xsl:if>
  382. <xsl:value-of select="@name"/>=<xsl:value-of select="@value"/>
  383. </xsl:template>
  384. <xsl:template name="default-boolean-contents">
  385. <xsl:value-of select="name()"/>: <xsl:value-of select="@state"/>
  386. </xsl:template>
  387. <xsl:template match="*[contains(@class,' topic/state ')]" name="topic.state">
  388. <text><xsl:call-template name="commonatts"/><xsl:call-template name="default-state-contents"/></text>
  389. </xsl:template>
  390. <xsl:template match="*[contains(@class,' topic/boolean ')]" name="topic.boolean">
  391. <text><xsl:call-template name="commonatts"/><xsl:call-template name="default-boolean-contents"/></text>
  392. </xsl:template>
  393. <!-- TRADEMARK PROCESSING TAKEN FROM XHTML OUTPUT, MODIFIED TO INCLUDE <text> -->
  394. <!-- prepare a key for each trademark tag -->
  395. <xsl:key name="tm" match="*[contains(@class,' topic/tm ')]" use="."/>
  396. <!-- process the TM tag -->
  397. <!-- removed priority 1 : should not be needed -->
  398. <xsl:template match="*[contains(@class,' topic/tm ')]" name="topic.tm">
  399. <xsl:variable name="tmvalue">
  400. <xsl:call-template name="getTmValue"/>
  401. </xsl:variable>
  402. <xsl:apply-templates/> <!-- output the TM content -->
  403. <xsl:if test="normalize-space($tmvalue)!=''">
  404. <text style="sup"><xsl:value-of select="$tmvalue"/></text>
  405. </xsl:if>
  406. </xsl:template>
  407. <xsl:template name="getTmValue">
  408. <!-- Determine the tmclass value; IBM legal only wants some classes processed -->
  409. <xsl:variable name="Ltmclass" select="lower-case(@tmclass)"/>
  410. <!-- If this is a good class, continue... -->
  411. <xsl:if test="$Ltmclass='ibm' or $Ltmclass='ibmsub' or $Ltmclass='special'">
  412. <!-- Test for TM area's language -->
  413. <xsl:variable name="tmtest">
  414. <xsl:call-template name="tm-area"/>
  415. </xsl:variable>
  416. <!-- If this language should get trademark markers, continue... -->
  417. <xsl:if test="$tmtest='tm'">
  418. <xsl:variable name="tmvalue"><xsl:value-of select="@trademark"/></xsl:variable>
  419. <!-- Determine if this is in a title, and should be marked -->
  420. <xsl:variable name="usetitle">
  421. <xsl:if test="ancestor::*[contains(@class,' topic/title ')]/parent::*[contains(@class,' topic/topic ')]">
  422. <xsl:choose>
  423. <!-- Not the first one in a title -->
  424. <xsl:when test="generate-id(.)!=generate-id(key('tm',.)[1])">skip</xsl:when>
  425. <!-- First one in the topic, BUT it appears in a shortdesc or body; BUT NOT in an alt -->
  426. <xsl:when test="//*[contains(@class,' topic/shortdesc ') or contains(@class,' topic/body ') or contains(@class,' topic/related-links ')]//*[contains(@class,' topic/tm ')][@trademark=$tmvalue][not(ancestor::*[contains(@class,' topic/alt ')])]">skip</xsl:when>
  427. <xsl:otherwise>use</xsl:otherwise>
  428. </xsl:choose>
  429. </xsl:if>
  430. </xsl:variable>
  431. <!-- Determine if this is in a body, and should be marked -->
  432. <xsl:variable name="usebody">
  433. <xsl:choose>
  434. <!-- If in a title or prolog, skip -->
  435. <xsl:when test="ancestor::*[contains(@class,' topic/title ') or contains(@class,' topic/prolog ')]/parent::*[contains(@class,' topic/topic ')]">skip</xsl:when>
  436. <!-- If in a alt, skip -->
  437. <xsl:when test="ancestor::*[contains(@class,' topic/alt ')]">skip</xsl:when>
  438. <!-- If first in the document, use it -->
  439. <xsl:when test="generate-id(.)=generate-id(key('tm',.)[1])">use</xsl:when>
  440. <!-- If there is another before this that is in the body or shortdesc, skip -->
  441. <xsl:when test="preceding::*[contains(@class,' topic/tm ')][@trademark=$tmvalue][not(ancestor::*[contains(@class,' topic/alt ')])][ancestor::*[contains(@class,' topic/body ') or contains(@class,' topic/shortdesc ') or contains(@class,' topic/related-links ')]]">skip</xsl:when>
  442. <!-- Otherwise, any before this must be in a title or ignored section -->
  443. <xsl:otherwise>use</xsl:otherwise>
  444. </xsl:choose>
  445. </xsl:variable>
  446. <!-- If it should be used in a title or used in the body, output your favorite TM marker based on the attributes -->
  447. <xsl:if test="$usetitle='use' or $usebody='use'">
  448. <xsl:choose> <!-- ignore @tmtype=service or anything else -->
  449. <xsl:when test="@tmtype='tm'">(TM)</xsl:when>
  450. <xsl:when test="@tmtype='reg'">(R)</xsl:when>
  451. <xsl:otherwise/>
  452. </xsl:choose>
  453. </xsl:if>
  454. </xsl:if>
  455. </xsl:if>
  456. </xsl:template>
  457. <!-- Test for in TM area: returns "tm" when parent's @xml:lang needs a trademark language;
  458. Otherwise, leave blank.
  459. Use the TM for US English and the AP languages (Japanese, Korean, and both Chinese).
  460. Ignore the TM for all other languages. -->
  461. <xsl:template name="tm-area">
  462. <xsl:variable name="parentlang">
  463. <xsl:call-template name="getLowerCaseLang"/>
  464. </xsl:variable>
  465. <xsl:choose>
  466. <xsl:when test="$parentlang='en-us' or $parentlang='en'">tm</xsl:when>
  467. <xsl:when test="$parentlang='ja-jp' or $parentlang='ja'">tm</xsl:when>
  468. <xsl:when test="$parentlang='ko-kr' or $parentlang='ko'">tm</xsl:when>
  469. <xsl:when test="$parentlang='zh-cn' or $parentlang='zh'">tm</xsl:when>
  470. <xsl:when test="$parentlang='zh-tw' or $parentlang='zh'">tm</xsl:when>
  471. <xsl:otherwise/>
  472. </xsl:choose>
  473. </xsl:template>
  474. <!-- How to put object into text? Basic processing will just use <desc> -->
  475. <xsl:template match="*[contains(@class,' topic/object ')]">
  476. <block><xsl:call-template name="commonatts"/><xsl:apply-templates select="*[contains(@class,' topic/desc ')]"/></block>
  477. </xsl:template>
  478. <xsl:template match="*[contains(@class,' topic/prolog ')] | *[contains(@class,' topic/titlealts ')]"/>
  479. <xsl:template match="*[contains(@class,' topic/body ')]">
  480. <block>
  481. <xsl:call-template name="commonatts"/>
  482. <xsl:apply-templates select="." mode="check-for-prereq"/>
  483. <xsl:apply-templates/>
  484. </block>
  485. </xsl:template>
  486. <!-- Only use required cleanup when $DRAFT=yes. Output a heading before, and a marker
  487. at the end, so that it stands out. -->
  488. <xsl:template match="*[contains(@class,' topic/required-cleanup ')]">
  489. <xsl:if test="$DRAFT='yes'">
  490. <block>
  491. <xsl:call-template name="commonatts"/>
  492. <block><xsl:call-template name="commonatts"/>
  493. <text><xsl:call-template name="commonatts"/>
  494. <xsl:text>********* </xsl:text>
  495. <xsl:call-template name="getVariable"><xsl:with-param name="id" select="'Required cleanup'"/></xsl:call-template>
  496. <xsl:text> *********</xsl:text>
  497. </text>
  498. </block>
  499. <block><xsl:call-template name="commonatts"/><xsl:apply-templates/></block>
  500. <block><xsl:call-template name="commonatts"/><text>******************************</text></block>
  501. </block>
  502. </xsl:if>
  503. </xsl:template>
  504. <!-- Only use draft comment when $DRAFT=yes. Output a heading before, and a marker
  505. at the end, so that it stands out. -->
  506. <xsl:template match="*[contains(@class,' topic/draft-comment ')]">
  507. <xsl:if test="$DRAFT='yes'">
  508. <block>
  509. <xsl:call-template name="commonatts"/>
  510. <block><xsl:call-template name="commonatts"/>
  511. <text><xsl:call-template name="commonatts"/>
  512. <xsl:text>********* </xsl:text>
  513. <xsl:call-template name="getVariable"><xsl:with-param name="id" select="'Draft comment'"/></xsl:call-template>
  514. <xsl:text> *********</xsl:text>
  515. </text>
  516. </block>
  517. <block><xsl:call-template name="commonatts"/><xsl:apply-templates/></block>
  518. <block><xsl:call-template name="commonatts"/><text>******************************</text></block>
  519. </block>
  520. </xsl:if>
  521. </xsl:template>
  522. <!-- Footnotes will put out the number inline, and put them all out at the end -->
  523. <xsl:template match="*[contains(@class,' topic/fn ')]">
  524. <text style="sup"><xsl:call-template name="output-fn-reference"/></text>
  525. </xsl:template>
  526. <xsl:template name="output-fn-reference">
  527. <xsl:text>(</xsl:text>
  528. <xsl:choose>
  529. <xsl:when test="@callout"><xsl:value-of select="@callout"/></xsl:when>
  530. <xsl:otherwise><xsl:value-of select="count(preceding::*[contains(@class,' topic/fn ')]) + 1"/></xsl:otherwise>
  531. </xsl:choose>
  532. <xsl:text>)</xsl:text>
  533. </xsl:template>
  534. <xsl:template match="*[contains(@class,' topic/fn ')]" mode="endnotes">
  535. <block>
  536. <text>
  537. <xsl:choose>
  538. <xsl:when test="@callout"><xsl:value-of select="@callout"/></xsl:when>
  539. <xsl:otherwise><xsl:value-of select="count(preceding::*[contains(@class,' topic/fn ')]) + 1"/></xsl:otherwise>
  540. </xsl:choose>
  541. <xsl:text>. </xsl:text>
  542. </text>
  543. <xsl:apply-templates/>
  544. </block>
  545. </xsl:template>
  546. <xsl:template match="*[contains(@class,' topic/indexterm ')] | *[contains(@class,' topic/indextermref ')]"/>
  547. <xsl:template name="CheckForPhraseSibling">
  548. <xsl:choose>
  549. <xsl:when test="parent::*[contains(@class,' topic/body ') or contains(@class,' topic/topic ')]">no</xsl:when>
  550. <xsl:when test="string-length(normalize-space(../text()[1]))>0">yes</xsl:when>
  551. <xsl:when test="following-sibling::*[contains(@class,' topic/ph ') or contains(@class,' topic/keyword ') or
  552. contains(@class,' topic/q ') or contains(@class,' topic/term ') or
  553. contains(@class,' topic/itemgroup ') or contains(@class,' topic/state ') or
  554. contains(@class,' topic/xref ') or contains(@class,' topic/tm ')]">yes</xsl:when>
  555. <xsl:when test="preceding-sibling::*[contains(@class,' topic/ph ') or contains(@class,' topic/keyword ') or
  556. contains(@class,' topic/q ') or contains(@class,' topic/term ') or
  557. contains(@class,' topic/itemgroup ') or contains(@class,' topic/state ') or
  558. contains(@class,' topic/xref ') or contains(@class,' topic/tm ')]">yes</xsl:when>
  559. <xsl:when test="following-sibling::*[contains(@class,' topic/image ')][not(@placement) or @placement='inline']">yes</xsl:when>
  560. <xsl:when test="preceding-sibling::*[contains(@class,' topic/image ')][not(@placement) or @placement='inline']">yes</xsl:when>
  561. <xsl:otherwise>no</xsl:otherwise>
  562. </xsl:choose>
  563. </xsl:template>
  564. <!-- If the text node is empty, ignore it. Otherwise, put it in <text>. -->
  565. <xsl:template match="text()">
  566. <xsl:choose>
  567. <xsl:when test="ancestor::*[@xml:space='preserve']"><text><xsl:value-of select="."/></text></xsl:when>
  568. <!-- If this string is only white-space, AND it is not between phrases, then drop it. -->
  569. <xsl:when test="string-length(normalize-space(.))=0">
  570. <xsl:variable name="siblingPhrase"><xsl:call-template name="CheckForPhraseSibling"/></xsl:variable>
  571. <xsl:if test="$siblingPhrase='yes'">
  572. <text><xsl:value-of select="."/></text>
  573. </xsl:if>
  574. </xsl:when>
  575. <xsl:otherwise><text><xsl:value-of select="."/></text></xsl:otherwise>
  576. </xsl:choose>
  577. </xsl:template>
  578. <!-- ******************* LINK PROCESSING ********************** -->
  579. <!-- For XREF, just put it out as a text element. Save link info in case it can be used
  580. in the target format. -->
  581. <xsl:template match="*[contains(@class,' topic/xref ')]">
  582. <text>
  583. <xsl:if test="@href"><xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute></xsl:if>
  584. <xsl:if test="@scope"><xsl:attribute name="scope"><xsl:value-of select="@scope"/></xsl:attribute></xsl:if>
  585. <xsl:if test="@format"><xsl:attribute name="format"><xsl:value-of select="@format"/></xsl:attribute></xsl:if>
  586. <xsl:choose>
  587. <xsl:when test="*[not(contains(@class,' topic/desc '))]|text()"><xsl:apply-templates/></xsl:when>
  588. <xsl:otherwise><xsl:value-of select="@href"/></xsl:otherwise>
  589. </xsl:choose>
  590. </text>
  591. </xsl:template>
  592. <xsl:template match="*[contains(@class,' topic/xref ')]/*[contains(@class,' topic/desc ')]"/>
  593. <!-- This section re-uses the login in rel-links.xsl. Rel-links has all the needed
  594. logic for sorting, removing duplicates, etc. The downside is that it loses link
  595. attributes like scope and formatting.
  596. Related links is processed using rel-links. Each section is placed in a variable.
  597. The contents of the variable are then processed, and the XHTML coding is
  598. converted to the proper block or text intermediate format. -->
  599. <!-- Override this template to ensure that prereq links are grouped with other links. -->
  600. <!--<xsl:apply-templates select="." mode="related-links:group-unordered-links">
  601. <xsl:with-param name="nodes" select="descendant::*[contains(@class, ' topic/link ')]
  602. [count(. | key('omit-from-unordered-links', 1)) != count(key('omit-from-unordered-links', 1))]
  603. [generate-id(.)=generate-id((key('hideduplicates', concat(ancestor::*[contains(@class, ' topic/related-links ')]/parent::*[contains(@class, ' topic/topic ')]/@id, ' ',@href,@scope,@audience,@platform,@product,@otherprops,@rev,@type,normalize-space(child::*))))[1])]
  604. |
  605. descendant::*[contains(@class, ' topic/link ')]
  606. [@importance='required' and (not(@role) or @role='sibling' or @role='friend' or @role='cousin')]
  607. [generate-id(.)=generate-id((key('hideduplicates', concat(ancestor::*[contains(@class, ' topic/related-links ')]/parent::*[contains(@class, ' topic/topic ')]/@id, ' ',@href,@scope,@audience,@platform,@product,@otherprops,@rev,@type,normalize-space(child::*))))[1])]"/>
  608. </xsl:apply-templates> -->
  609. <xsl:template match="*" mode="check-for-prereq">
  610. <xsl:if test="following-sibling::*[1][contains(@class,' topic/related-links ')]">
  611. <xsl:variable name="prereqs">
  612. <xsl:apply-templates select="following-sibling::*[1][contains(@class,' topic/related-links ')]" mode="prereqs"/>
  613. </xsl:variable>
  614. <xsl:apply-templates select="$prereqs" mode="reformat-links"/>
  615. </xsl:if>
  616. </xsl:template>
  617. <xsl:template match="*[contains(@class,' topic/related-links ')]">
  618. <xsl:variable name="ul-children">
  619. <xsl:call-template name="ul-child-links"/><!--handle child/descendants outside of linklists in collection-type=unordered or choice-->
  620. </xsl:variable>
  621. <xsl:variable name="ol-children">
  622. <xsl:call-template name="ol-child-links"/><!--handle child/descendants outside of linklists in collection-type=ordered/sequence-->
  623. </xsl:variable>
  624. <xsl:variable name="next-previous-parent">
  625. <xsl:call-template name="next-prev-parent-links"/><!--handle next and previous links-->
  626. </xsl:variable>
  627. <xsl:variable name="relcon">
  628. <xsl:call-template name="concept-links"/><!--sort remaining concept links by type-->
  629. </xsl:variable>
  630. <xsl:variable name="reltask">
  631. <xsl:call-template name="task-links"/><!--sort remaining task links by type-->
  632. </xsl:variable>
  633. <xsl:variable name="relref">
  634. <xsl:call-template name="reference-links"/><!--sort remaining reference links by type-->
  635. </xsl:variable>
  636. <xsl:variable name="relinfo">
  637. <xsl:call-template name="relinfo-links"/><!--handle remaining untyped and unknown-type links-->
  638. </xsl:variable>
  639. <xsl:variable name="linklists">
  640. <xsl:apply-templates select="*[contains(@class,' topic/linklist ')]"/>
  641. </xsl:variable>
  642. <block>
  643. <xsl:call-template name="commonatts"/>
  644. <xsl:apply-templates select="$ul-children" mode="reformat-links"/>
  645. <xsl:apply-templates select="$ol-children" mode="reformat-links"/>
  646. <xsl:apply-templates select="$next-previous-parent" mode="reformat-links"/>
  647. <xsl:apply-templates select="$relcon" mode="reformat-links"/>
  648. <xsl:apply-templates select="$reltask" mode="reformat-links"/>
  649. <xsl:apply-templates select="$relref" mode="reformat-links"/>
  650. <xsl:apply-templates select="$relinfo" mode="reformat-links"/>
  651. <xsl:apply-templates select="$linklists" mode="reformat-links"/>
  652. </block>
  653. </xsl:template>
  654. <xsl:template match="ul[@class='ullinks']" mode="reformat-links">
  655. <xsl:apply-templates mode="reformat-links"/>
  656. </xsl:template>
  657. <!-- Unordered child links each come out as indented blocks -->
  658. <xsl:template match="li[@class='ulchildlink']|div[@class='ulchildlink']" mode="reformat-links">
  659. <block indent="3">
  660. <block compact="yes"><xsl:apply-templates select="strong/a/*" mode="reformat-links"/></block>
  661. <block compact="yes"><xsl:apply-templates select="strong/following-sibling::*" mode="reformat-links"/></block>
  662. </block>
  663. </xsl:template>
  664. <xsl:template match="ol" mode="reformat-links">
  665. <block><xsl:apply-templates mode="reformat-links"/></block>
  666. </xsl:template>
  667. <!-- Ordered child links must be numbered. The xsl:number test is fine because every item
  668. at this point is actually in an <li> element. -->
  669. <xsl:template match="li[@class='olchildlink']|div[@class='olchildlink']" mode="reformat-links">
  670. <xsl:variable name="listintro">
  671. <xsl:number count="*"/>. <xsl:text/>
  672. </xsl:variable>
  673. <block>
  674. <block compact="yes">
  675. <text><xsl:value-of select="$listintro"/></text>
  676. <xsl:apply-templates select="br/preceding-sibling::*" mode="reformat-links"/>
  677. </block>
  678. <block compact="yes" indent="3">
  679. <xsl:apply-templates select="br/following-sibling::*" mode="reformat-links"/>
  680. </block>
  681. </block>
  682. </xsl:template>
  683. <!-- If the related concepts/tasks/ref/info sections exist, put them in blocks -->
  684. <xsl:template match="div[@class='relconcepts' or @class='reltasks' or @class='relref' or @class='relinfo']" mode="reformat-links">
  685. <xsl:if test="div">
  686. <block>
  687. <block compact="yes"><xsl:apply-templates select="strong" mode="reformat-links"/></block>
  688. <xsl:apply-templates select="div" mode="reformat-links"/>
  689. </block>
  690. </xsl:if>
  691. </xsl:template>
  692. <!-- If there is anything in the familylinks div, put it in a block -->
  693. <xsl:template match="div[@class='familylinks']" mode="reformat-links">
  694. <xsl:if test="div">
  695. <block><xsl:apply-templates mode="reformat-links"/></block>
  696. </xsl:if>
  697. </xsl:template>
  698. <!-- Parent/next/previous links get the bold intro text, and go in a block. Use
  699. compact=yes so that there is not extra space between these links. -->
  700. <xsl:template match="div[@class='parentlink' or @class='previouslink' or @class='nextlink']" mode="reformat-links">
  701. <block compact="yes">
  702. <text>
  703. <xsl:value-of select="strong"/>
  704. <xsl:text> </xsl:text>
  705. <xsl:apply-templates select="strong/following-sibling::*" mode="reformat-links"/>
  706. </text>
  707. </block>
  708. </xsl:template>
  709. <!-- linklist still needs work -->
  710. <xsl:template match="div[@class='linklist' or @class='linklistwithchild']" mode="reformat-links">
  711. <block><xsl:apply-templates mode="reformat-links"/></block>
  712. </xsl:template>
  713. <xsl:template match="div[@class='sublinklist']" mode="reformat-links">
  714. <block indent="3"><xsl:apply-templates mode="reformat-links"/></block>
  715. </xsl:template>
  716. <xsl:template match="div[@class='linklist' or @class='linklistwithchild' or @class='sublinklist']/strong" mode="reformat-links">
  717. <block compact="yes"><text style="bold"><xsl:apply-templates mode="reformat-links"/></text></block>
  718. </xsl:template>
  719. <xsl:template match="div" mode="reformat-links">
  720. <block compact="yes"><xsl:apply-templates mode="reformat-links"/></block>
  721. </xsl:template>
  722. <xsl:template match="dl[contains(@class,'prereqlinks')]" mode="reformat-links">
  723. <block compact="yes"><xsl:apply-templates mode="reformat-links"/></block>
  724. </xsl:template>
  725. <xsl:template match="dt[contains(@class,'prereq')]" mode="reformat-links">
  726. <block compact="yes">
  727. <text style="bold">
  728. <xsl:apply-templates mode="reformat-links"/>
  729. </text>
  730. </block>
  731. </xsl:template>
  732. <xsl:template match="dl[contains(@class,'prereqlinks')]/dd" mode="reformat-links">
  733. <block indent="9" compact="yes"><xsl:apply-templates mode="reformat-links"/></block>
  734. </xsl:template>
  735. <!-- If something already fell through to the ordinary processor, copy it as-is -->
  736. <xsl:template match="text|block" mode="reformat-links">
  737. <xsl:copy><xsl:copy-of select="@*|*|text()"/></xsl:copy>
  738. </xsl:template>
  739. <xsl:template match="*" mode="reformat-links">
  740. <xsl:apply-templates mode="reformat-links"/>
  741. </xsl:template>
  742. <xsl:template match="@*" mode="reformat-links">
  743. <xsl:copy><xsl:value-of select="."/></xsl:copy>
  744. </xsl:template>
  745. <xsl:template match="strong" mode="reformat-links">
  746. <text style="bold"><xsl:apply-templates mode="reformat-links"/></text>
  747. </xsl:template>
  748. <xsl:template match="em" mode="reformat-links">
  749. <text style="italics"><xsl:apply-templates mode="reformat-links"/></text>
  750. </xsl:template>
  751. <xsl:template match="text()" mode="reformat-links">
  752. <xsl:choose>
  753. <xsl:when test="string-length(normalize-space(.))=0"/>
  754. <xsl:otherwise><text><xsl:value-of select="."/></text></xsl:otherwise>
  755. </xsl:choose>
  756. </xsl:template>
  757. <!--<xsl:template match="*[contains(@class,' topic/linklist ')]">
  758. <block><xsl:apply-templates/></block>
  759. </xsl:template>-->
  760. <!--<xsl:template match="*[contains(@class,' topic/desc ')]">
  761. <block compact="yes"><xsl:apply-templates/></block>
  762. </xsl:template>-->
  763. <!--<xsl:template match="*[contains(@class,' topic/linkinfo ')]">
  764. <block compact="yes"><xsl:apply-templates/></block>
  765. </xsl:template>-->
  766. <!--<xsl:template match="*[contains(@class,' topic/link ')]">
  767. <xsl:choose>
  768. <xsl:when test="*[contains(@class,' topic/linktext ')]">
  769. <block compact="yes"><xsl:apply-templates/></block>
  770. </xsl:when>
  771. <xsl:when test="@href">
  772. <block compact="yes"><text><xsl:value-of select="@href"/></text><xsl:apply-templates/></block>
  773. </xsl:when>
  774. <xsl:otherwise>
  775. <block compact="yes"><xsl:apply-templates/></block>
  776. </xsl:otherwise>
  777. </xsl:choose>
  778. </xsl:template>
  779. <xsl:template match="*[contains(@class,' topic/linktext ')]">
  780. <block compact="yes"><xsl:apply-templates/></block>
  781. </xsl:template>-->
  782. <!-- Add for "New <data> element (#9)" in DITA 1.1 -->
  783. <xsl:template match="*[contains(@class,' topic/data ')]"/>
  784. <!-- Add for "Support foreign content vocabularies such as
  785. MathML and SVG with <unknown> (#35) " in DITA 1.1 -->
  786. <xsl:template match="*[contains(@class,' topic/foreign ') or contains(@class,' topic/unknown ')]"/>
  787. </xsl:stylesheet>