hv1-common.xsl 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:d="http://docbook.org/ns/docbook"
  4. xmlns="http://www.w3.org/1999/xhtml"
  5. exclude-result-prefixes="d"
  6. version="1.0">
  7. <!-- no separate HTML page with index as this is binary in hv1 -->
  8. <xsl:param name="generate.index" select="0"/>
  9. <!-- Generate help tags in header -->
  10. <xsl:template name="user.head.content">
  11. <xsl:param name="node" select="''" />
  12. <xsl:variable name="up" select="parent::*"/>
  13. <!-- Locale should be first Help tag-->
  14. <meta name="Microsoft.Help.Locale">
  15. <xsl:attribute name="content">
  16. <xsl:choose>
  17. <xsl:when test="$product.locale and product.locale != ''">
  18. <xsl:value-of select="$product.locale"/>
  19. </xsl:when>
  20. <xsl:otherwise>
  21. <xsl:text>en-US</xsl:text>
  22. </xsl:otherwise>
  23. </xsl:choose>
  24. </xsl:attribute>
  25. </meta>
  26. <!-- Specify locale for this chunk. Should probably query xml:lang -->
  27. <meta name="Microsoft.Help.TopicLocale">
  28. <xsl:attribute name="content">
  29. <xsl:choose>
  30. <xsl:when test="@xml:lang">
  31. <xsl:value-of select="@xml:lang"/>
  32. </xsl:when>
  33. <xsl:when test="$product.locale and product.locale != ''">
  34. <xsl:value-of select="$product.locale"/>
  35. </xsl:when>
  36. <xsl:otherwise>
  37. <xsl:text>en-US</xsl:text>
  38. </xsl:otherwise>
  39. </xsl:choose>
  40. </xsl:attribute>
  41. </meta>
  42. <!-- This is the unique ID for this page -->
  43. <meta name="Microsoft.Help.Id">
  44. <xsl:attribute name="content">
  45. <xsl:call-template name="hv1.toc.id"/>
  46. </xsl:attribute>
  47. </meta>
  48. <!-- The ID of the parent TOC node (-1 is root) -->
  49. <meta name="Microsoft.Help.TocParent">
  50. <xsl:attribute name="content">
  51. <xsl:call-template name="hv1.toc.parent.id">
  52. <xsl:with-param name="up" select="$up"/>
  53. </xsl:call-template>
  54. </xsl:attribute>
  55. </meta>
  56. <!-- For all pages with the same parent, the order is set by TocOrder -->
  57. <meta name="Microsoft.Help.TocOrder">
  58. <xsl:attribute name="content">
  59. <xsl:value-of select="1+count(preceding-sibling::chapter|preceding-sibling::section)"/>
  60. </xsl:attribute>
  61. </meta>
  62. <!-- boolean to indicate if this page is allowed to load custom branding -->
  63. <meta name="Microsoft.Help.SelfBranded">
  64. <xsl:attribute name="content">
  65. <xsl:choose>
  66. <xsl:when test="$topic.selfbrand">
  67. <xsl:text>true</xsl:text>
  68. </xsl:when>
  69. <xsl:otherwise>
  70. <xsl:text>false</xsl:text>
  71. </xsl:otherwise>
  72. </xsl:choose>
  73. </xsl:attribute>
  74. </meta>
  75. <!--
  76. Insert description meta element. This is shown in searches and indexes
  77. -->
  78. <xsl:variable name="description">
  79. <xsl:call-template name="hv1.description"/>
  80. </xsl:variable>
  81. <xsl:if test="$description != ''">
  82. <meta name="Description">
  83. <xsl:attribute name="content">
  84. <xsl:call-template name="hv1.description"/>
  85. </xsl:attribute>
  86. </meta>
  87. </xsl:if>
  88. <!-- Display version of page -->
  89. <xsl:variable name="display.version">
  90. <xsl:call-template name="hv1.display.version"/>
  91. </xsl:variable>
  92. <xsl:if test="$display.version != ''">
  93. <meta name="Microsoft.Help.DisplayVersion">
  94. <xsl:attribute name="content">
  95. <xsl:value-of select="$display.version"/>
  96. </xsl:attribute>
  97. </meta>
  98. </xsl:if>
  99. <!--
  100. Content type is used to distinguish between multiple topics with same id.
  101. Usualy to have multiple versions available
  102. -->
  103. <!--
  104. <meta name="Microsoft.Help.ContentType">
  105. <xsl:attribute name="content">
  106. TODO: implement
  107. </xsl:attribute>
  108. </meta>
  109. -->
  110. <!-- If a product name is given, then mark each header with this name-->
  111. <xsl:if test="$product.name and $product.name != ''">
  112. <meta name="Microsoft.Help.Product">
  113. <xsl:attribute name="content">
  114. <xsl:value-of select="$product.name"/>
  115. </xsl:attribute>
  116. </meta>
  117. </xsl:if>
  118. <!-- If a version is given, then mark each header with version-->
  119. <xsl:if test="$product.version and $product.version != ''">
  120. <meta name="Microsoft.Help.ProductVersion">
  121. <xsl:attribute name="content">
  122. <xsl:value-of select="$product.version"/>
  123. </xsl:attribute>
  124. </meta>
  125. </xsl:if>
  126. <!--
  127. Insert all keywords for this chunk. These are used
  128. by the help runtime to generate indexes and refine search
  129. -->
  130. <xsl:call-template name="hv1.keywords" />
  131. <!--
  132. Insert all F1 ids for this chunk. This is used
  133. by the help runtime to resolve F1 queries
  134. -->
  135. <xsl:call-template name="hv1.f1" />
  136. </xsl:template>
  137. <!-- There are links from ToC pane to bibliodivs, so there must be anchor -->
  138. <xsl:template match="bibliodiv/title">
  139. <h3 class="{name(.)}">
  140. <xsl:call-template name="anchor">
  141. <xsl:with-param name="node" select=".."/>
  142. <xsl:with-param name="conditional" select="0"/>
  143. </xsl:call-template>
  144. <xsl:apply-templates/>
  145. </h3>
  146. </xsl:template>
  147. <!--
  148. Template to get a page id.
  149. Needs to be unique in the target help system; microsoft uses UUIDs for this.
  150. To avoid UUIDs and generate-id (only unique in current xml fragment),
  151. we do
  152. <root.filename> +
  153. <last ancestor title> +
  154. <second last ancestor title> +
  155. ....
  156. <self title>, where different types of sections/fragments
  157. may be prefixed with a type identifier.
  158. This should generate a fairly specific/unique ID.
  159. -->
  160. <xsl:template name="get.id.from.pagename">
  161. <xsl:param name="target" />
  162. <xsl:value-of select="$root.filename"/>
  163. <xsl:variable name="id.of.document">
  164. <xsl:apply-templates select="$target" mode="recursive-chunk-id"/>
  165. </xsl:variable>
  166. <xsl:variable name="titleWithSpace">
  167. <xsl:value-of select="key('id',$id.of.document)/title"/>
  168. </xsl:variable>
  169. <xsl:value-of select="translate($id.of.document,' ','')" />
  170. </xsl:template>
  171. <!-- template that returns the page id used above -->
  172. <xsl:template match="*" mode="recursive-chunk-id">
  173. <xsl:param name="recursive" select="false()"/>
  174. <!-- returns the filename of a chunk -->
  175. <xsl:variable name="ischunk">
  176. <xsl:call-template name="chunk"/>
  177. </xsl:variable>
  178. <xsl:variable name="dbhtml-filename">
  179. <xsl:call-template name="pi.dbhtml_filename"/>
  180. </xsl:variable>
  181. <xsl:variable name="filename">
  182. <xsl:choose>
  183. <xsl:when test="$dbhtml-filename != ''">
  184. <xsl:value-of select="$dbhtml-filename"/>
  185. </xsl:when>
  186. <!-- if this is the root element, use the root.filename -->
  187. <xsl:when test="not(parent::*) and $root.filename != ''">
  188. <xsl:value-of select="$root.filename"/>
  189. <!-- <xsl:value-of select="$html.ext"/> -->
  190. </xsl:when>
  191. <!-- Special case -->
  192. <xsl:when test="self::legalnotice and not($generate.legalnotice.link = 0)">
  193. <xsl:choose>
  194. <xsl:when test="(@id or @xml:id) and not($use.id.as.filename = 0)">
  195. <!-- * if this legalnotice has an ID, then go ahead and use -->
  196. <!-- * just the value of that ID as the basename for the file -->
  197. <!-- * (that is, without prepending an "ln-" too it) -->
  198. <xsl:value-of select="(@id|@xml:id)[1]"/>
  199. <!-- <xsl:value-of select="$html.ext"/>-->
  200. </xsl:when>
  201. <xsl:otherwise>
  202. <!-- * otherwise, if this legalnotice does not have an ID, -->
  203. <!-- * then we generate an ID... -->
  204. <xsl:variable name="id">
  205. <xsl:call-template name="object.id"/>
  206. </xsl:variable>
  207. <!-- * ...and then we take that generated ID, prepend an -->
  208. <!-- * "ln-" to it, and use that as the basename for the file -->
  209. <!-- <xsl:value-of select="concat('ln-',$id,$html.ext)"/>-->
  210. </xsl:otherwise>
  211. </xsl:choose>
  212. </xsl:when>
  213. <!-- if there's no dbhtml filename, and if we're to use IDs as -->
  214. <!-- filenames, then use the ID to generate the filename. -->
  215. <xsl:when test="(@id or @xml:id) and $use.id.as.filename != 0">
  216. <xsl:value-of select="(@id|@xml:id)[1]"/>
  217. <!-- <xsl:value-of select="$html.ext"/>-->
  218. </xsl:when>
  219. <xsl:otherwise/>
  220. </xsl:choose>
  221. </xsl:variable>
  222. <xsl:choose>
  223. <xsl:when test="$ischunk='0'">
  224. <!-- if called on something that isn't a chunk, walk up... -->
  225. <xsl:choose>
  226. <xsl:when test="count(parent::*)&gt;0">
  227. <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
  228. <xsl:with-param name="recursive" select="$recursive"/>
  229. </xsl:apply-templates>
  230. </xsl:when>
  231. <!-- unless there is no up, in which case return "" -->
  232. <xsl:otherwise/>
  233. </xsl:choose>
  234. </xsl:when>
  235. <xsl:when test="not($recursive) and $filename != ''">
  236. <!-- if this chunk has an explicit name, use it -->
  237. <xsl:value-of select="$filename"/>
  238. </xsl:when>
  239. <xsl:when test="self::set">
  240. <xsl:value-of select="$root.filename"/>
  241. </xsl:when>
  242. <xsl:when test="self::book">
  243. <xsl:text>bk</xsl:text>
  244. <xsl:number level="any" format="01"/>
  245. </xsl:when>
  246. <xsl:when test="self::article">
  247. <xsl:if test="/set">
  248. <!-- in a set, make sure we inherit the right book info... -->
  249. <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
  250. <xsl:with-param name="recursive" select="true()"/>
  251. </xsl:apply-templates>
  252. </xsl:if>
  253. <xsl:text>ar</xsl:text>
  254. <xsl:number level="any" format="01" from="book"/>
  255. </xsl:when>
  256. <xsl:when test="self::preface">
  257. <xsl:if test="/set">
  258. <!-- in a set, make sure we inherit the right book info... -->
  259. <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
  260. <xsl:with-param name="recursive" select="true()"/>
  261. </xsl:apply-templates>
  262. </xsl:if>
  263. <xsl:text>pr</xsl:text>
  264. <xsl:number level="any" format="01" from="book"/>
  265. </xsl:when>
  266. <xsl:when test="self::chapter">
  267. <xsl:if test="/set">
  268. <!-- in a set, make sure we inherit the right book info... -->
  269. <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
  270. <xsl:with-param name="recursive" select="true()"/>
  271. </xsl:apply-templates>
  272. </xsl:if>
  273. <xsl:text>ch</xsl:text>
  274. <xsl:number level="any" format="01" from="book"/>
  275. </xsl:when>
  276. <xsl:when test="self::appendix">
  277. <xsl:if test="/set">
  278. <!-- in a set, make sure we inherit the right book info... -->
  279. <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
  280. <xsl:with-param name="recursive" select="true()"/>
  281. </xsl:apply-templates>
  282. </xsl:if>
  283. <xsl:text>ap</xsl:text>
  284. <xsl:number level="any" format="a" from="book"/>
  285. </xsl:when>
  286. <xsl:when test="self::part">
  287. <xsl:choose>
  288. <xsl:when test="/set">
  289. <!-- in a set, make sure we inherit the right book info... -->
  290. <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
  291. <xsl:with-param name="recursive" select="true()"/>
  292. </xsl:apply-templates>
  293. </xsl:when>
  294. <xsl:otherwise>
  295. </xsl:otherwise>
  296. </xsl:choose>
  297. <xsl:text>pt</xsl:text>
  298. <xsl:number level="any" format="01" from="book"/>
  299. </xsl:when>
  300. <xsl:when test="self::reference">
  301. <xsl:choose>
  302. <xsl:when test="/set">
  303. <!-- in a set, make sure we inherit the right book info... -->
  304. <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
  305. <xsl:with-param name="recursive" select="true()"/>
  306. </xsl:apply-templates>
  307. </xsl:when>
  308. <xsl:otherwise>
  309. </xsl:otherwise>
  310. </xsl:choose>
  311. <xsl:text>rn</xsl:text>
  312. <xsl:number level="any" format="01" from="book"/>
  313. </xsl:when>
  314. <xsl:when test="self::refentry">
  315. <xsl:choose>
  316. <xsl:when test="parent::reference">
  317. <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
  318. <xsl:with-param name="recursive" select="true()"/>
  319. </xsl:apply-templates>
  320. </xsl:when>
  321. <xsl:otherwise>
  322. </xsl:otherwise>
  323. </xsl:choose>
  324. <xsl:text>re</xsl:text>
  325. <xsl:number level="any" format="01" from="book"/>
  326. </xsl:when>
  327. <xsl:when test="self::colophon">
  328. <xsl:choose>
  329. <xsl:when test="/set">
  330. <!-- in a set, make sure we inherit the right book info... -->
  331. <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
  332. <xsl:with-param name="recursive" select="true()"/>
  333. </xsl:apply-templates>
  334. </xsl:when>
  335. <xsl:otherwise>
  336. </xsl:otherwise>
  337. </xsl:choose>
  338. <xsl:text>co</xsl:text>
  339. <xsl:number level="any" format="01" from="book"/>
  340. </xsl:when>
  341. <xsl:when test="self::sect1
  342. or self::sect2
  343. or self::sect3
  344. or self::sect4
  345. or self::sect5
  346. or self::section">
  347. <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
  348. <xsl:with-param name="recursive" select="true()"/>
  349. </xsl:apply-templates>
  350. <xsl:text>s</xsl:text>
  351. <xsl:number format="01"/>
  352. </xsl:when>
  353. <xsl:when test="self::bibliography">
  354. <xsl:choose>
  355. <xsl:when test="/set">
  356. <!-- in a set, make sure we inherit the right book info... -->
  357. <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
  358. <xsl:with-param name="recursive" select="true()"/>
  359. </xsl:apply-templates>
  360. </xsl:when>
  361. <xsl:otherwise>
  362. </xsl:otherwise>
  363. </xsl:choose>
  364. <xsl:text>bi</xsl:text>
  365. <xsl:number level="any" format="01" from="book"/>
  366. </xsl:when>
  367. <xsl:when test="self::glossary">
  368. <xsl:choose>
  369. <xsl:when test="/set">
  370. <!-- in a set, make sure we inherit the right book info... -->
  371. <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
  372. <xsl:with-param name="recursive" select="true()"/>
  373. </xsl:apply-templates>
  374. </xsl:when>
  375. <xsl:otherwise>
  376. </xsl:otherwise>
  377. </xsl:choose>
  378. <xsl:text>go</xsl:text>
  379. <xsl:number level="any" format="01" from="book"/>
  380. </xsl:when>
  381. <xsl:when test="self::index">
  382. <xsl:choose>
  383. <xsl:when test="/set">
  384. <!-- in a set, make sure we inherit the right book info... -->
  385. <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
  386. <xsl:with-param name="recursive" select="true()"/>
  387. </xsl:apply-templates>
  388. </xsl:when>
  389. <xsl:otherwise>
  390. </xsl:otherwise>
  391. </xsl:choose>
  392. <xsl:text>ix</xsl:text>
  393. <xsl:number level="any" format="01" from="book"/>
  394. </xsl:when>
  395. <xsl:when test="self::setindex">
  396. <xsl:text>si</xsl:text>
  397. <xsl:number level="any" format="01" from="set"/>
  398. </xsl:when>
  399. <xsl:otherwise>
  400. <xsl:text>chunk-filename-error-</xsl:text>
  401. <xsl:value-of select="name(.)"/>
  402. <xsl:number level="any" format="01" from="set"/>
  403. </xsl:otherwise>
  404. </xsl:choose>
  405. </xsl:template>
  406. <!-- Main template that generates internal links -->
  407. <xsl:template name="href.target">
  408. <xsl:param name="context" select="."/>
  409. <xsl:param name="object" select="."/>
  410. <xsl:param name="toc-context" select="."/>
  411. <xsl:variable name="id">
  412. <xsl:call-template name="get.id.from.pagename">
  413. <xsl:with-param name="target" select="$object"/>
  414. </xsl:call-template>
  415. </xsl:variable>
  416. <xsl:variable name="href">
  417. <xsl:choose>
  418. <xsl:when test="$use.mshelp.links">
  419. <!-- Generate a ms.help type link-->
  420. <xsl:if test="$product.name = ''">
  421. <xsl:message terminate="yes">
  422. $product.name needs to be set to generate ms.help style links
  423. </xsl:message>
  424. </xsl:if>
  425. <xsl:if test="$product.version = ''">
  426. <xsl:message terminate="yes">
  427. $product.version needs to be set to generate ms.help style links
  428. </xsl:message>
  429. </xsl:if>
  430. <xsl:if test="$product.locale = ''">
  431. <xsl:message terminate="yes">
  432. $product.locale needs to be set to generate ms.help style links
  433. </xsl:message>
  434. </xsl:if>
  435. <xsl:text>ms.help?method=page&amp;id=</xsl:text>
  436. <xsl:value-of select="$id"/>
  437. <xsl:text>&amp;product=</xsl:text>
  438. <xsl:value-of select="$product.name"/>
  439. <xsl:text>&amp;productVersion=</xsl:text>
  440. <xsl:value-of select="$product.version"/>
  441. <xsl:text>&amp;locale=</xsl:text>
  442. <xsl:value-of select="$product.locale"/>
  443. <!-- Append the jump id if the current object has an id-->
  444. <xsl:if test="$object[@id or @xml:id]">
  445. <xsl:text>#</xsl:text>
  446. <xsl:value-of select="$object/@id|$object/@xml:id"/>
  447. </xsl:if>
  448. </xsl:when>
  449. <xsl:otherwise>
  450. <!-- Generate ms-xhelp type links. Default-->
  451. <xsl:text>ms-xhelp:///?Id=</xsl:text>
  452. <xsl:value-of select="$id"/>
  453. </xsl:otherwise>
  454. </xsl:choose>
  455. </xsl:variable>
  456. <xsl:value-of select="$href"/>
  457. </xsl:template>
  458. <xsl:template match="*" mode="common.html.attributes">
  459. <xsl:param name="class" select="local-name(.)"/>
  460. <xsl:param name="inherit" select="0"/>
  461. <!--
  462. Workaround for known issue with HelpLibAgent
  463. Comment from Bruce Belson:
  464. <pre> tags get their whitespace mangled by the Help Library Agent,
  465. unless the non-standard attribute xml:space="preserve" is added to the pre element.
  466. -->
  467. <xsl:if test="$class = 'programlisting' or $class = 'verbatim' or $class = 'litterallayout' or $class = 'screen'">
  468. <xsl:attribute name="xml:space">preserve</xsl:attribute>
  469. </xsl:if>
  470. <xsl:call-template name="generate.html.lang"/>
  471. <xsl:call-template name="dir">
  472. <xsl:with-param name="inherit" select="$inherit"/>
  473. </xsl:call-template>
  474. <xsl:apply-templates select="." mode="class.attribute">
  475. <xsl:with-param name="class" select="$class"/>
  476. </xsl:apply-templates>
  477. </xsl:template>
  478. <xsl:template name="hv1.display.version">
  479. <xsl:apply-templates mode="title.markup" select="ancestor-or-self::book"/>
  480. <xsl:if test="ancestor-or-self::chapter">
  481. <xsl:text> - </xsl:text>
  482. <xsl:apply-templates mode="title.markup" select="ancestor-or-self::chapter"/>
  483. </xsl:if>
  484. </xsl:template>
  485. <!-- Generate a meta element for each keyword in chunk -->
  486. <xsl:template name="hv1.keywords">
  487. <xsl:variable name="is.chunk">
  488. <xsl:call-template name="chunk">
  489. <xsl:with-param name="node" select="."/>
  490. </xsl:call-template>
  491. </xsl:variable>
  492. <xsl:for-each select=".//indexterm[$is.chunk = '0'] |
  493. (./indexterm | *[not(self::section or self::preface or self::book or self::chapter)]//indexterm)[$is.chunk = '1']">
  494. <xsl:choose>
  495. <xsl:when test="primary != ''">
  496. <meta name="Microsoft.Help.Keywords">
  497. <xsl:attribute name="content">
  498. <xsl:choose>
  499. <!-- This concats the primary and secondary togheter, separated by colon if there exists
  500. a tertiary element -->
  501. <xsl:when test="tertiary">
  502. <xsl:value-of select="primary/text()" />
  503. <xsl:text>: </xsl:text>
  504. <xsl:value-of select="secondary/text()" />
  505. <xsl:text>, </xsl:text>
  506. <xsl:value-of select="tertiary/text()" />
  507. </xsl:when>
  508. <xsl:otherwise>
  509. <xsl:for-each select="primary/text() | secondary/text()">
  510. <xsl:value-of select="." />
  511. <xsl:if test="not(position() = last())">, </xsl:if>
  512. </xsl:for-each>
  513. </xsl:otherwise>
  514. </xsl:choose>
  515. </xsl:attribute>
  516. </meta>
  517. </xsl:when>
  518. <xsl:otherwise/>
  519. </xsl:choose>
  520. </xsl:for-each>
  521. </xsl:template>
  522. <!-- Generate a F1 meta element for each indexterm with an ID (used as F1 id) -->
  523. <xsl:template name="hv1.f1">
  524. <xsl:variable name="is.chunk">
  525. <xsl:call-template name="chunk">
  526. <xsl:with-param name="node" select="."/>
  527. </xsl:call-template>
  528. </xsl:variable>
  529. <xsl:variable name="id">
  530. <xsl:call-template name="hv1.toc.id"/>
  531. </xsl:variable>
  532. <xsl:for-each select=".//indexterm[$is.chunk = '0'] |
  533. (./indexterm | *[not(self::section or self::preface or self::book or self::chapter)]//indexterm)[$is.chunk = '1']">
  534. <xsl:if test="@id|@xml:id">
  535. <meta name="Microsoft.Help.F1">
  536. <xsl:attribute name="content">
  537. <xsl:value-of select="(@id|@xml:id)[1]" />
  538. </xsl:attribute>
  539. </meta>
  540. </xsl:if>
  541. </xsl:for-each>
  542. </xsl:template>
  543. <!-- ID used for to resolution. Using default ID -->
  544. <xsl:template name="hv1.toc.id">
  545. <xsl:variable name="href">
  546. <xsl:call-template name="get.id.from.pagename">
  547. <xsl:with-param name="target" select="."/>
  548. </xsl:call-template>
  549. </xsl:variable>
  550. <xsl:value-of select="$href"/>
  551. </xsl:template>
  552. <!-- Determine parent id (if top level -> -1) -->
  553. <xsl:template name="hv1.toc.parent.id">
  554. <xsl:param name="up" select="''"/>
  555. <xsl:variable name="href">
  556. <xsl:choose>
  557. <xsl:when test="$up">
  558. <!-- I have a parent -->
  559. <xsl:call-template name="get.id.from.pagename">
  560. <xsl:with-param name="target" select="$up"/>
  561. </xsl:call-template>
  562. </xsl:when>
  563. <xsl:otherwise>
  564. <xsl:text>-1</xsl:text>
  565. </xsl:otherwise>
  566. </xsl:choose>
  567. </xsl:variable>
  568. <xsl:value-of select="$href"/>
  569. </xsl:template>
  570. <xsl:template name="hv1.description">
  571. <xsl:variable name="content">
  572. <xsl:choose>
  573. <xsl:when test="abstract|d:abstract|d:info/d:abstract|bookinfo/abstract|sectioninfo/abstract|articleinfo/abstract|partinfo/abstract">
  574. <xsl:value-of select="(abstract|d:abstract|d:info/d:abstract|bookinfo/abstract|sectioninfo/abstract|articleinfo/abstract|partinfo/abstract)[1]"/>
  575. </xsl:when>
  576. <xsl:when test="child::para">
  577. <xsl:value-of select="substring(normalize-space(child::para[1]), 0, 150)"/>
  578. </xsl:when>
  579. <xsl:otherwise/>
  580. </xsl:choose>
  581. </xsl:variable>
  582. <xsl:if test="$content != ''">
  583. <xsl:value-of select="concat($content, '...')"/>
  584. </xsl:if>
  585. </xsl:template>
  586. </xsl:stylesheet>