main_transform.xsl 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--***********************************************************************
  3. This is the main transformation style sheet for transforming.
  4. For use with LibreOffice 4.0+
  5. =========================================================================
  6. Changes Log
  7. May 24 2004 Created
  8. Aug 24 2004 Fixed for help2 CWS
  9. Aug 27 2004 Added css link, fixed missing embed-mode for variable
  10. Removed width/height for images
  11. Sep 03 2004 Modularized xsl, added some embedded modes
  12. Oct 08 2004 Fixed bug wrong mode "embedded" for links
  13. Added embedded modes for embed and embedvar (for cascaded embeds)
  14. Added <p> tags around falsely embedded pars and vars
  15. Dec 08 2004 #i38483#, fixed wrong handling of web links
  16. #i37377#, fixed missing usage of Database parameter for switching
  17. Jan 04 2005 #i38905#, fixed buggy branding replacement template
  18. Mar 17 2005 #i43972#, added language info to image URL, evaluate Language parameter
  19. evaluate new localize attribute in images
  20. May 10 2005 #i48785#, fixed wrong setting of distrib variable
  21. Aug 16 2005 workaround for #i53365#
  22. Aug 19 2005 fixed missing list processing in embedded sections
  23. Aug 19 2005 #i53535#, fixed wrong handling of Database parameter
  24. Oct 17 2006 #i70462#, disabled sorting to avoid output of error messages to console
  25. Jun 15 2009 #i101799#, fixed wrong handling of http URLs with anchors
  26. ***********************************************************************//-->
  27. <!--
  28. * This file is part of the LibreOffice project.
  29. *
  30. * This Source Code Form is subject to the terms of the Mozilla Public
  31. * License, v. 2.0. If a copy of the MPL was not distributed with this
  32. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  33. *
  34. * This file incorporates work covered by the following license notice:
  35. *
  36. * Licensed to the Apache Software Foundation (ASF) under one or more
  37. * contributor license agreements. See the NOTICE file distributed
  38. * with this work for additional information regarding copyright
  39. * ownership. The ASF licenses this file to you under the Apache
  40. * License, Version 2.0 (the "License"); you may not use this file
  41. * except in compliance with the License. You may obtain a copy of
  42. * the License at http://www.apache.org/licenses/LICENSE-2.0 .
  43. -->
  44. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  45. <xsl:output indent="yes" method="html"/>
  46. <!--
  47. ############################
  48. # Variables and Parameters #
  49. ############################
  50. //-->
  51. <!-- General Usage -->
  52. <xsl:variable name="am" select="'&amp;'"/>
  53. <xsl:variable name="sl" select="'/'"/>
  54. <xsl:variable name="qt" select="'&quot;'"/>
  55. <!-- generic Icon alt text -->
  56. <xsl:variable name="alttext" select="'text/shared/00/icon_alt.xhp'"/>
  57. <!-- For calculating pixel sizes -->
  58. <xsl:variable name="dpi" select="'96'"/>
  59. <xsl:variable name="dpcm" select="'38'"/>
  60. <!-- Product brand variables used in the help files -->
  61. <xsl:variable name="brand1" select="'$[officename]'"/>
  62. <xsl:variable name="brand2" select="'$[officeversion]'"/>
  63. <xsl:variable name="brand3" select="'%PRODUCTNAME'"/>
  64. <xsl:variable name="brand4" select="'%PRODUCTVERSION'"/>
  65. <!-- meta data variables from the help file -->
  66. <xsl:variable name="filename" select="/helpdocument/meta/topic/filename"/>
  67. <xsl:variable name="title" select="/helpdocument/meta/topic/title"/>
  68. <!-- Module and the corresponding switching values-->
  69. <xsl:param name="Database" select="'swriter'"/>
  70. <xsl:variable name="module" select="$Database"/>
  71. <xsl:variable name="appl">
  72. <xsl:choose>
  73. <xsl:when test="$module = 'swriter'"><xsl:value-of select="'WRITER'"/></xsl:when>
  74. <xsl:when test="$module = 'scalc'"><xsl:value-of select="'CALC'"/></xsl:when>
  75. <xsl:when test="$module = 'sdraw'"><xsl:value-of select="'DRAW'"/></xsl:when>
  76. <xsl:when test="$module = 'simpress'"><xsl:value-of select="'IMPRESS'"/></xsl:when>
  77. <xsl:when test="$module = 'schart'"><xsl:value-of select="'CHART'"/></xsl:when>
  78. <xsl:when test="$module = 'sbasic'"><xsl:value-of select="'BASIC'"/></xsl:when>
  79. <xsl:when test="$module = 'smath'"><xsl:value-of select="'MATH'"/></xsl:when>
  80. </xsl:choose>
  81. </xsl:variable>
  82. <!-- the other parameters given by the help caller -->
  83. <xsl:param name="System" select="'WIN'"/>
  84. <xsl:param name="productname" select="'Office'"/>
  85. <xsl:param name="productversion" select="''"/>
  86. <xsl:variable name="pversion">
  87. <xsl:value-of select="translate($productversion,' ','')"/>
  88. </xsl:variable>
  89. <!-- this is were the images are -->
  90. <xsl:param name="imgtheme" select="''"/>
  91. <xsl:param name="Id" />
  92. <xsl:param name="Language" select="'en-US'"/>
  93. <xsl:variable name="lang" select="$Language"/>
  94. <xsl:param name="ExtensionId" select="''"/>
  95. <xsl:param name="ExtensionPath" select="''"/>
  96. <!-- parts of help and image urls -->
  97. <xsl:variable name="help_url_prefix" select="'vnd.sun.star.help://'"/>
  98. <xsl:variable name="img_url_prefix" select="concat('vnd.libreoffice.image://',$imgtheme,'/')"/>
  99. <xsl:variable name="img_url_internal" select="'vnd.libreoffice.image://helpimg/'"/>
  100. <xsl:variable name="urlpost" select="concat('?Language=',$lang,$am,'System=',$System,$am,'UseDB=no')"/>
  101. <xsl:variable name="urlpre" select="$help_url_prefix" />
  102. <xsl:variable name="linkprefix" select="$urlpre"/>
  103. <xsl:variable name="linkpostfix" select="$urlpost"/>
  104. <xsl:variable name="css" select="'default.css'"/>
  105. <!-- images for notes, tips and warnings -->
  106. <xsl:variable name="note_img" select="concat($img_url_internal,'media/helpimg/note.png')"/>
  107. <xsl:variable name="tip_img" select="concat($img_url_internal,'media/helpimg/tip.png')"/>
  108. <xsl:variable name="warning_img" select="concat($img_url_internal,'media/helpimg/warning.png')"/>
  109. <!--
  110. #############
  111. # Templates #
  112. #############
  113. //-->
  114. <!-- Create the document skeleton -->
  115. <xsl:template match="/">
  116. <xsl:variable name="csslink" select="concat($urlpre,'/',$urlpost)"/>
  117. <html>
  118. <head>
  119. <title><xsl:value-of select="$title"/></title>
  120. <link href="{$csslink}" rel="Stylesheet" type="text/css" /> <!-- stylesheet link -->
  121. <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
  122. </head>
  123. <body lang="{$lang}">
  124. <xsl:apply-templates select="/helpdocument/body"/>
  125. </body>
  126. </html>
  127. </xsl:template>
  128. <!-- AHELP -->
  129. <xsl:template match="ahelp">
  130. <xsl:if test="not(@visibility='hidden')"><span class="avis"><xsl:apply-templates /></span></xsl:if>
  131. </xsl:template>
  132. <!-- ALT -->
  133. <xsl:template match="alt"/>
  134. <!-- BOOKMARK -->
  135. <xsl:template match="bookmark">
  136. <a name="{@id}"></a>
  137. <xsl:choose>
  138. <xsl:when test="starts-with(@branch,'hid')" />
  139. <xsl:otherwise><xsl:apply-templates /></xsl:otherwise>
  140. </xsl:choose>
  141. </xsl:template>
  142. <xsl:template match="bookmark" mode="embedded" />
  143. <!-- BOOKMARK_VALUE -->
  144. <xsl:template match="bookmark_value" />
  145. <!-- BR -->
  146. <xsl:template match="br"><br /></xsl:template>
  147. <!-- CAPTION -->
  148. <xsl:template match="caption" />
  149. <!-- CASE -->
  150. <xsl:template match="case"><xsl:call-template name="insertcase" /></xsl:template>
  151. <xsl:template match="case" mode="embedded">
  152. <xsl:call-template name="insertcase">
  153. <xsl:with-param name="embedded" select="'yes'"/>
  154. </xsl:call-template>
  155. </xsl:template>
  156. <!-- CASEINLINE -->
  157. <xsl:template match="caseinline"><xsl:call-template name="insertcase" /></xsl:template>
  158. <xsl:template match="caseinline" mode="embedded">
  159. <xsl:call-template name="insertcase">
  160. <xsl:with-param name="embedded" select="'yes'"/>
  161. </xsl:call-template>
  162. </xsl:template>
  163. <!-- COMMENT -->
  164. <xsl:template match="comment" />
  165. <xsl:template match="comment" mode="embedded"/>
  166. <!-- CREATED -->
  167. <xsl:template match="created" />
  168. <!-- DEFAULT -->
  169. <xsl:template match="default"><xsl:call-template name="insertdefault" /></xsl:template>
  170. <xsl:template match="default" mode="embedded">
  171. <xsl:call-template name="insertdefault">
  172. <xsl:with-param name="embedded" select="'yes'"/>
  173. </xsl:call-template>
  174. </xsl:template>
  175. <!-- DEFAULTINLINE -->
  176. <xsl:template match="defaultinline"><xsl:call-template name="insertdefault" /></xsl:template>
  177. <xsl:template match="defaultinline" mode="embedded">
  178. <xsl:call-template name="insertdefault">
  179. <xsl:with-param name="embedded" select="'yes'"/>
  180. </xsl:call-template>
  181. </xsl:template>
  182. <!-- EMBED -->
  183. <xsl:template match="embed"><xsl:call-template name="resolveembed"/></xsl:template>
  184. <xsl:template match="embed" mode="embedded"><xsl:call-template name="resolveembed"/></xsl:template>
  185. <!-- EMBEDVAR -->
  186. <xsl:template match="embedvar"><xsl:call-template name="resolveembedvar"/></xsl:template>
  187. <xsl:template match="embedvar" mode="embedded"><xsl:call-template name="resolveembedvar"/></xsl:template>
  188. <!-- EMPH -->
  189. <xsl:template match="emph">
  190. <span class="emph"><xsl:apply-templates /></span>
  191. </xsl:template>
  192. <xsl:template match="emph" mode="embedded">
  193. <span class="emph"><xsl:apply-templates /></span>
  194. </xsl:template>
  195. <!-- SUB -->
  196. <xsl:template match="sub">
  197. <sub><xsl:apply-templates /></sub>
  198. </xsl:template>
  199. <xsl:template match="sub" mode="embedded">
  200. <sub><xsl:apply-templates /></sub>
  201. </xsl:template>
  202. <!-- SUP -->
  203. <xsl:template match="sup">
  204. <sup><xsl:apply-templates /></sup>
  205. </xsl:template>
  206. <xsl:template match="sup" mode="embedded">
  207. <sup><xsl:apply-templates /></sup>
  208. </xsl:template>
  209. <!-- FILENAME -->
  210. <xsl:template match="filename" />
  211. <!-- HISTORY -->
  212. <xsl:template match="history" />
  213. <!-- IMAGE -->
  214. <xsl:template match="image"><xsl:call-template name="insertimage"/></xsl:template>
  215. <xsl:template match="image" mode="embedded"><xsl:call-template name="insertimage"/></xsl:template>
  216. <!-- ITEM -->
  217. <xsl:template match="item"><span class="{@type}"><xsl:apply-templates /></span></xsl:template>
  218. <xsl:template match="item" mode="embedded"><span class="{@type}"><xsl:apply-templates /></span></xsl:template>
  219. <!-- LINK -->
  220. <xsl:template match="link">
  221. <xsl:choose> <!-- don't insert the heading link to itself -->
  222. <xsl:when test="(concat('/',@href) = /helpdocument/meta/topic/filename) or (@href = /helpdocument/meta/topic/filename)">
  223. <xsl:apply-templates />
  224. </xsl:when>
  225. <xsl:when test="contains(child::embedvar/@href,'/00/00000004.xhp#wie')"> <!-- special treatment of howtoget links -->
  226. <xsl:call-template name="insert_howtoget">
  227. <xsl:with-param name="linkhref" select="@href"/>
  228. </xsl:call-template>
  229. </xsl:when>
  230. <xsl:otherwise>
  231. <xsl:call-template name="createlink" />
  232. </xsl:otherwise>
  233. </xsl:choose>
  234. </xsl:template>
  235. <xsl:template match="link" mode="embedded">
  236. <xsl:call-template name="createlink"/>
  237. </xsl:template>
  238. <!-- LIST -->
  239. <xsl:template match="list">
  240. <xsl:choose>
  241. <xsl:when test="@type='ordered'">
  242. <ol>
  243. <xsl:if test="@startwith">
  244. <xsl:attribute name="start"><xsl:value-of select="@startwith"/></xsl:attribute>
  245. </xsl:if>
  246. <xsl:apply-templates />
  247. </ol>
  248. </xsl:when>
  249. <xsl:otherwise>
  250. <ul><xsl:apply-templates /></ul>
  251. </xsl:otherwise>
  252. </xsl:choose>
  253. </xsl:template>
  254. <xsl:template match="list" mode="embedded">
  255. <xsl:choose>
  256. <xsl:when test="@type='ordered'">
  257. <ol>
  258. <xsl:if test="@startwith">
  259. <xsl:attribute name="start"><xsl:value-of select="@startwith"/></xsl:attribute>
  260. </xsl:if>
  261. <xsl:apply-templates mode="embedded"/>
  262. </ol>
  263. </xsl:when>
  264. <xsl:otherwise>
  265. <ul><xsl:apply-templates mode="embedded"/></ul>
  266. </xsl:otherwise>
  267. </xsl:choose>
  268. </xsl:template>
  269. <!-- LISTITEM -->
  270. <xsl:template match="listitem">
  271. <li><xsl:apply-templates /></li>
  272. </xsl:template>
  273. <xsl:template match="listitem" mode="embedded">
  274. <li><xsl:apply-templates mode="embedded"/></li>
  275. </xsl:template>
  276. <!-- META, SEE HEADER -->
  277. <xsl:template match="meta" />
  278. <!-- OBJECT (UNUSED) -->
  279. <xsl:template match="object" />
  280. <!-- PARAGRAPH -->
  281. <xsl:template match="paragraph">
  282. <xsl:choose>
  283. <xsl:when test="@role='heading'">
  284. <xsl:call-template name="insertheading">
  285. <xsl:with-param name="level" select="@level"/>
  286. </xsl:call-template>
  287. </xsl:when>
  288. <xsl:when test="contains(' note warning tip ',@role)">
  289. <xsl:call-template name="insertnote">
  290. <xsl:with-param name="type" select="@role" />
  291. </xsl:call-template>
  292. </xsl:when>
  293. <xsl:when test="contains(descendant::embedvar/@href,'/00/00000004.xhp#wie')"> <!-- special treatment of howtoget links -->
  294. <xsl:apply-templates />
  295. </xsl:when>
  296. <xsl:when test="@role='bascode'">
  297. <xsl:call-template name="insertbascode" />
  298. </xsl:when>
  299. <xsl:when test="@role='logocode'">
  300. <xsl:call-template name="insertlogocode" />
  301. </xsl:when>
  302. <xsl:otherwise>
  303. <xsl:call-template name="insertpara" />
  304. </xsl:otherwise>
  305. </xsl:choose>
  306. </xsl:template>
  307. <xsl:template match="paragraph" mode="embedded">
  308. <xsl:choose>
  309. <xsl:when test="@role='heading'"> <!-- increase the level of headings that are embedded -->
  310. <!--
  311. The internal sablotron processor does not seem to support the number function.
  312. Therefore, we need a workaround for
  313. <xsl:variable name="level"><xsl:value-of select="number(@level)+1"/></xsl:variable>
  314. -->
  315. <xsl:variable name="newlevel">
  316. <xsl:choose>
  317. <xsl:when test="@level='1'"><xsl:value-of select="'2'"/></xsl:when>
  318. <xsl:when test="@level='2'"><xsl:value-of select="'2'"/></xsl:when>
  319. <xsl:when test="@level='3'"><xsl:value-of select="'3'"/></xsl:when>
  320. <xsl:when test="@level='4'"><xsl:value-of select="'4'"/></xsl:when>
  321. <xsl:when test="@level='5'"><xsl:value-of select="'5'"/></xsl:when>
  322. </xsl:choose>
  323. </xsl:variable>
  324. <xsl:call-template name="insertheading">
  325. <xsl:with-param name="level" select="$newlevel"/>
  326. <xsl:with-param name="embedded" select="'yes'"/>
  327. </xsl:call-template>
  328. </xsl:when>
  329. <xsl:when test="contains(' note warning tip ',@role)">
  330. <xsl:call-template name="insertnote">
  331. <xsl:with-param name="type" select="@role" />
  332. </xsl:call-template>
  333. </xsl:when>
  334. <xsl:when test="contains(descendant::embedvar/@href,'/00/00000004.xhp#wie')"> <!-- special treatment of howtoget links -->
  335. <xsl:apply-templates />
  336. </xsl:when>
  337. <xsl:otherwise>
  338. <xsl:call-template name="insertpara" />
  339. </xsl:otherwise>
  340. </xsl:choose>
  341. </xsl:template>
  342. <!-- SECTION -->
  343. <xsl:template match="section">
  344. <a name="{@id}"></a>
  345. <xsl:choose>
  346. <xsl:when test="@id='relatedtopics'">
  347. <div class="relatedtopics">
  348. <xsl:variable name="href"><xsl:value-of select="concat($urlpre,'shared/text/shared/00/00000004.xhp',$urlpost)"/></xsl:variable>
  349. <xsl:variable name="anchor"><xsl:value-of select="'related'"/></xsl:variable>
  350. <xsl:variable name="doc" select="document($href)"/>
  351. <p class="related">
  352. <xsl:apply-templates select="$doc//variable[@id=$anchor]"/>
  353. </p>
  354. <div class="relatedbody">
  355. <xsl:apply-templates />
  356. </div>
  357. </div>
  358. </xsl:when>
  359. <xsl:when test="@id='howtoget'">
  360. <xsl:call-template name="insert_howtoget" />
  361. </xsl:when>
  362. <xsl:otherwise>
  363. <xsl:apply-templates/>
  364. </xsl:otherwise>
  365. </xsl:choose>
  366. </xsl:template>
  367. <!-- SECTION -->
  368. <xsl:template match="section" mode="embedded">
  369. <a name="{@id}"></a>
  370. <xsl:apply-templates mode="embedded"/>
  371. </xsl:template>
  372. <!-- SORT -->
  373. <xsl:template match="sort" >
  374. <xsl:apply-templates><xsl:sort select="descendant::paragraph"/></xsl:apply-templates>
  375. </xsl:template>
  376. <xsl:template match="sort" mode="embedded">
  377. <xsl:apply-templates><xsl:sort select="descendant::paragraph"/></xsl:apply-templates>
  378. </xsl:template>
  379. <!-- SWITCH -->
  380. <xsl:template match="switch"><xsl:apply-templates /></xsl:template>
  381. <xsl:template match="switch" mode="embedded"><xsl:apply-templates /></xsl:template>
  382. <!-- SWITCHINLINE -->
  383. <xsl:template match="switchinline"><xsl:apply-templates /></xsl:template>
  384. <xsl:template match="switchinline" mode="embedded"><xsl:apply-templates mode="embedded"/></xsl:template>
  385. <!-- TABLE -->
  386. <xsl:template match="table"><xsl:call-template name="inserttable"/></xsl:template>
  387. <xsl:template match="table" mode="embedded"><xsl:call-template name="inserttable"/></xsl:template>
  388. <!-- TABLECELL -->
  389. <xsl:template match="tablecell"><td valign="top"><xsl:apply-templates /></td></xsl:template>
  390. <xsl:template match="tablecell" mode="icontable"><td valign="top"><xsl:apply-templates/></td></xsl:template>
  391. <xsl:template match="tablecell" mode="embedded"><td valign="top"><xsl:apply-templates mode="embedded"/></td></xsl:template>
  392. <!-- TABLEROW -->
  393. <xsl:template match="tablerow"><tr><xsl:apply-templates /></tr></xsl:template>
  394. <xsl:template match="tablerow" mode="icontable"><tr><xsl:apply-templates mode="icontable"/></tr></xsl:template>
  395. <xsl:template match="tablerow" mode="embedded"><tr><xsl:apply-templates mode="embedded"/></tr></xsl:template>
  396. <!-- TITLE -->
  397. <xsl:template match="title"/>
  398. <!-- TOPIC -->
  399. <xsl:template match="topic"/>
  400. <!-- VARIABLE -->
  401. <xsl:template match="variable"><a name="{@id}"></a><xsl:apply-templates /></xsl:template>
  402. <xsl:template match="variable" mode="embedded"><a name="{@id}"></a><xsl:apply-templates mode="embedded"/></xsl:template>
  403. <xsl:template match="text()">
  404. <xsl:call-template name="brand">
  405. <xsl:with-param name="string"><xsl:value-of select="."/></xsl:with-param>
  406. </xsl:call-template>
  407. </xsl:template>
  408. <xsl:template match="text()" mode="embedded">
  409. <xsl:call-template name="brand">
  410. <xsl:with-param name="string"><xsl:value-of select="."/></xsl:with-param>
  411. </xsl:call-template>
  412. </xsl:template>
  413. <!-- In case of missing help files -->
  414. <xsl:template match="help-id-missing"><xsl:value-of select="$Id"/></xsl:template>
  415. <!--
  416. ###################
  417. # NAMED TEMPLATES #
  418. ###################
  419. //-->
  420. <!-- Branding -->
  421. <xsl:template name="brand" >
  422. <xsl:param name="string"/>
  423. <xsl:choose>
  424. <xsl:when test="contains($string,$brand1)">
  425. <xsl:variable name="newstr">
  426. <xsl:value-of select="substring-before($string,$brand1)"/>
  427. <xsl:value-of select="$productname"/>
  428. <xsl:value-of select="substring-after($string,$brand1)"/>
  429. </xsl:variable>
  430. <xsl:call-template name="brand">
  431. <xsl:with-param name="string" select="$newstr"/>
  432. </xsl:call-template>
  433. </xsl:when>
  434. <xsl:when test="contains($string,$brand2)">
  435. <xsl:variable name="newstr">
  436. <xsl:value-of select="substring-before($string,$brand2)"/>
  437. <xsl:value-of select="$pversion"/>
  438. <xsl:value-of select="substring-after($string,$brand2)"/>
  439. </xsl:variable>
  440. <xsl:call-template name="brand">
  441. <xsl:with-param name="string" select="$newstr"/>
  442. </xsl:call-template>
  443. </xsl:when>
  444. <xsl:when test="contains($string,$brand3)">
  445. <xsl:variable name="newstr">
  446. <xsl:value-of select="substring-before($string,$brand3)"/>
  447. <xsl:value-of select="$productname"/>
  448. <xsl:value-of select="substring-after($string,$brand3)"/>
  449. </xsl:variable>
  450. <xsl:call-template name="brand">
  451. <xsl:with-param name="string" select="$newstr"/>
  452. </xsl:call-template>
  453. </xsl:when>
  454. <xsl:when test="contains($string,$brand4)">
  455. <xsl:variable name="newstr">
  456. <xsl:value-of select="substring-before($string,$brand4)"/>
  457. <xsl:value-of select="$pversion"/>
  458. <xsl:value-of select="substring-after($string,$brand4)"/>
  459. </xsl:variable>
  460. <xsl:call-template name="brand">
  461. <xsl:with-param name="string" select="$newstr"/>
  462. </xsl:call-template>
  463. </xsl:when>
  464. <xsl:otherwise>
  465. <xsl:value-of select="$string"/>
  466. </xsl:otherwise>
  467. </xsl:choose>
  468. </xsl:template>
  469. <!-- Insert Paragraph -->
  470. <xsl:template name="insertpara">
  471. <xsl:variable name="role">
  472. <xsl:choose>
  473. <xsl:when test="ancestor::table">
  474. <xsl:value-of select="concat(@role,'intable')"/>
  475. </xsl:when>
  476. <xsl:otherwise>
  477. <xsl:value-of select="@role"/>
  478. </xsl:otherwise>
  479. </xsl:choose>
  480. </xsl:variable>
  481. <p class="{$role}"><xsl:apply-templates /></p>
  482. </xsl:template>
  483. <!-- Insert Basic code snippet -->
  484. <xsl:template name="insertbascode">
  485. <pre><xsl:apply-templates /></pre>
  486. </xsl:template>
  487. <!-- Insert Logo code snippet -->
  488. <xsl:template name="insertlogocode">
  489. <pre><xsl:apply-templates /></pre>
  490. </xsl:template>
  491. <!-- Insert "How to get Link" -->
  492. <xsl:template name="insert_howtoget">
  493. <xsl:param name="linkhref" />
  494. <xsl:variable name="archive" select="'shared'"/>
  495. <xsl:variable name="tmp_href"><xsl:value-of select="concat($urlpre,'shared/text/shared/00/00000004.xhp',$urlpost)"/></xsl:variable>
  496. <xsl:variable name="tmp_doc" select="document($tmp_href)"/>
  497. <table class="howtoget" width="100%" border="1" cellpadding="3" cellspacing="0">
  498. <tr>
  499. <td>
  500. <p class="howtogetheader"><xsl:apply-templates select="$tmp_doc//variable[@id='wie']"/></p>
  501. <div class="howtogetbody">
  502. <xsl:choose>
  503. <xsl:when test="$linkhref = ''"> <!-- new style -->
  504. <xsl:apply-templates/>
  505. </xsl:when>
  506. <xsl:otherwise> <!-- old style -->
  507. <xsl:variable name="archive1"><xsl:value-of select="concat(substring-before(substring-after($linkhref,'text/'),'/'),'/')"/></xsl:variable>
  508. <xsl:variable name="href"><xsl:value-of select="concat($urlpre,$archive1,substring-before($linkhref,'#'),$urlpost)"/></xsl:variable>
  509. <xsl:variable name="anc"><xsl:value-of select="substring-after($linkhref,'#')"/></xsl:variable>
  510. <xsl:variable name="docum" select="document($href)"/>
  511. <xsl:call-template name="insertembed">
  512. <xsl:with-param name="doc" select="$docum" />
  513. <xsl:with-param name="anchor" select="$anc" />
  514. </xsl:call-template>
  515. </xsl:otherwise>
  516. </xsl:choose>
  517. </div>
  518. </td>
  519. </tr>
  520. </table>
  521. <br/>
  522. </xsl:template>
  523. <!-- Create a link -->
  524. <xsl:template name="createlink">
  525. <xsl:variable name="archive"><xsl:value-of select="concat(substring-before(substring-after(@href,'text/'),'/'),'/')"/></xsl:variable>
  526. <xsl:variable name="dbpostfix"><xsl:call-template name="createDBpostfix"><xsl:with-param name="archive" select="$archive"/></xsl:call-template></xsl:variable>
  527. <xsl:choose>
  528. <xsl:when test="starts-with(@href,'http://') or starts-with(@href,'https://')"> <!-- web links -->
  529. <a href="{@href}"><xsl:apply-templates /></a>
  530. </xsl:when>
  531. <xsl:when test="contains(@href,'#')">
  532. <xsl:variable name="anchor"><xsl:value-of select="concat('#',substring-after(@href,'#'))"/></xsl:variable>
  533. <xsl:variable name="href"><xsl:value-of select="concat($linkprefix,$archive,substring-before(@href,'#'),$linkpostfix,$dbpostfix,$anchor)"/></xsl:variable>
  534. <a href="{$href}"><xsl:apply-templates /></a>
  535. </xsl:when>
  536. <xsl:otherwise>
  537. <xsl:variable name="href"><xsl:value-of select="concat($linkprefix,$archive,@href,$linkpostfix,$dbpostfix)"/></xsl:variable>
  538. <a href="{$href}"><xsl:apply-templates /></a>
  539. </xsl:otherwise>
  540. </xsl:choose>
  541. </xsl:template>
  542. <!-- Insert Note, Warning, or Tip -->
  543. <xsl:template name="insertnote">
  544. <xsl:param name="type" /> <!-- note, tip, or warning -->
  545. <xsl:variable name="imgsrc">
  546. <xsl:choose>
  547. <xsl:when test="$type='note'"><xsl:value-of select="$note_img"/></xsl:when>
  548. <xsl:when test="$type='tip'"><xsl:value-of select="$tip_img"/></xsl:when>
  549. <xsl:when test="$type='warning'"><xsl:value-of select="$warning_img"/></xsl:when>
  550. </xsl:choose>
  551. </xsl:variable>
  552. <xsl:variable name="dbpostfix"><xsl:call-template name="createDBpostfix"><xsl:with-param name="archive" select="'shared'"/></xsl:call-template></xsl:variable>
  553. <xsl:variable name="alt">
  554. <xsl:variable name="href"><xsl:value-of select="concat($urlpre,'shared/',$alttext,$urlpost,$dbpostfix)"/></xsl:variable>
  555. <xsl:variable name="anchor"><xsl:value-of select="concat('alt_',$type)"/></xsl:variable>
  556. <xsl:variable name="doc" select="document($href)"/>
  557. <xsl:apply-templates select="$doc//variable[@id=$anchor]" mode="embedded"/>
  558. </xsl:variable>
  559. <div class="{$type}">
  560. <table border="0" class="{$type}" cellspacing="0" cellpadding="5">
  561. <tr>
  562. <td><img src="{$imgsrc}" alt="{$alt}" title="{$alt}"/></td>
  563. <td><xsl:apply-templates /></td>
  564. </tr>
  565. </table>
  566. </div>
  567. <br/>
  568. </xsl:template>
  569. <!-- Insert a heading -->
  570. <xsl:template name="insertheading">
  571. <xsl:param name="level" />
  572. <xsl:param name="embedded" />
  573. <xsl:text disable-output-escaping="yes">&lt;h</xsl:text><xsl:value-of select="$level"/><xsl:text disable-output-escaping="yes">&gt;</xsl:text>
  574. <xsl:choose>
  575. <xsl:when test="$embedded = 'yes'">
  576. <xsl:apply-templates mode="embedded"/>
  577. </xsl:when>
  578. <xsl:otherwise>
  579. <xsl:apply-templates />
  580. </xsl:otherwise>
  581. </xsl:choose>
  582. <xsl:text disable-output-escaping="yes">&lt;/h</xsl:text><xsl:value-of select="$level"/><xsl:text disable-output-escaping="yes">&gt;</xsl:text>
  583. </xsl:template>
  584. <!-- Evaluate a case or caseinline switch -->
  585. <xsl:template name="insertcase">
  586. <xsl:param name="embedded" />
  587. <xsl:choose>
  588. <xsl:when test="parent::switch[@select='sys'] or parent::switchinline[@select='sys']">
  589. <xsl:if test="@select = $System">
  590. <xsl:choose>
  591. <xsl:when test="$embedded = 'yes'">
  592. <xsl:apply-templates mode="embedded"/>
  593. </xsl:when>
  594. <xsl:otherwise>
  595. <xsl:apply-templates />
  596. </xsl:otherwise>
  597. </xsl:choose>
  598. </xsl:if>
  599. </xsl:when>
  600. <xsl:when test="parent::switch[@select='appl'] or parent::switchinline[@select='appl']">
  601. <xsl:if test="@select = $appl">
  602. <xsl:choose>
  603. <xsl:when test="$embedded = 'yes'">
  604. <xsl:apply-templates mode="embedded"/>
  605. </xsl:when>
  606. <xsl:otherwise>
  607. <xsl:apply-templates />
  608. </xsl:otherwise>
  609. </xsl:choose>
  610. </xsl:if>
  611. </xsl:when>
  612. <xsl:when test="parent::switch[@select='distrib'] or parent::switchinline[@select='distrib']">
  613. <xsl:if test="@select = $distrib">
  614. <xsl:choose>
  615. <xsl:when test="$embedded = 'yes'">
  616. <xsl:apply-templates mode="embedded"/>
  617. </xsl:when>
  618. <xsl:otherwise>
  619. <xsl:apply-templates />
  620. </xsl:otherwise>
  621. </xsl:choose>
  622. </xsl:if>
  623. </xsl:when>
  624. </xsl:choose>
  625. </xsl:template>
  626. <!-- Evaluate a default or defaultinline switch -->
  627. <xsl:template name="insertdefault">
  628. <xsl:param name="embedded" />
  629. <xsl:choose>
  630. <xsl:when test="parent::switch[@select='sys'] or parent::switchinline[@select='sys']">
  631. <xsl:if test="not(../child::case[@select=$System]) and not(../child::caseinline[@select=$System])">
  632. <xsl:choose>
  633. <xsl:when test="$embedded = 'yes'">
  634. <xsl:apply-templates mode="embedded"/>
  635. </xsl:when>
  636. <xsl:otherwise>
  637. <xsl:apply-templates />
  638. </xsl:otherwise>
  639. </xsl:choose>
  640. </xsl:if>
  641. </xsl:when>
  642. <xsl:when test="parent::switch[@select='appl'] or parent::switchinline[@select='appl']">
  643. <xsl:if test="not(../child::case[@select=$appl]) and not(../child::caseinline[@select=$appl])">
  644. <xsl:choose>
  645. <xsl:when test="$embedded = 'yes'">
  646. <xsl:apply-templates mode="embedded"/>
  647. </xsl:when>
  648. <xsl:otherwise>
  649. <xsl:apply-templates />
  650. </xsl:otherwise>
  651. </xsl:choose>
  652. </xsl:if>
  653. </xsl:when>
  654. <xsl:when test="parent::switch[@select='distrib'] or parent::switchinline[@select='distrib']">
  655. <xsl:if test="not(../child::case[@select=$distrib]) and not(../child::caseinline[@select=$distrib])">
  656. <xsl:choose>
  657. <xsl:when test="$embedded = 'yes'">
  658. <xsl:apply-templates mode="embedded"/>
  659. </xsl:when>
  660. <xsl:otherwise>
  661. <xsl:apply-templates />
  662. </xsl:otherwise>
  663. </xsl:choose>
  664. </xsl:if>
  665. </xsl:when>
  666. </xsl:choose>
  667. </xsl:template>
  668. <!-- evaluate embeds -->
  669. <xsl:template name="insertembed">
  670. <xsl:param name="doc" />
  671. <xsl:param name="anchor" />
  672. <!-- different embed targets (also falsely used embed instead embedvar) -->
  673. <xsl:choose>
  674. <xsl:when test="$doc//section[@id=$anchor]"> <!-- first test for a section of that name -->
  675. <xsl:apply-templates select="$doc//section[@id=$anchor]" mode="embedded"/>
  676. </xsl:when>
  677. <xsl:when test="$doc//paragraph[@id=$anchor]"> <!-- then test for a para of that name -->
  678. <p class="embedded">
  679. <xsl:apply-templates select="$doc//paragraph[@id=$anchor]" mode="embedded"/>
  680. </p>
  681. </xsl:when>
  682. <xsl:when test="$doc//variable[@id=$anchor]"> <!-- then test for a variable of that name -->
  683. <p class="embedded">
  684. <xsl:apply-templates select="$doc//variable[@id=$anchor]" mode="embedded"/>
  685. </p>
  686. </xsl:when>
  687. <xsl:otherwise> <!-- then give up -->
  688. <p class="bug">D'oh! You found a bug (<xsl:value-of select="@href"/> not found).</p>
  689. </xsl:otherwise>
  690. </xsl:choose>
  691. </xsl:template>
  692. <!-- Insert an image -->
  693. <xsl:template name="insertimage">
  694. <xsl:variable name="src">
  695. <xsl:choose>
  696. <xsl:when test="starts-with(@src,'media/')">
  697. <xsl:value-of select="concat($img_url_internal,@src)"/>
  698. </xsl:when>
  699. <xsl:when test="not($ExtensionId='') and starts-with(@src,$ExtensionId)">
  700. <xsl:value-of select="concat($ExtensionPath,'/',@src)"/>
  701. </xsl:when>
  702. <xsl:otherwise>
  703. <xsl:choose>
  704. <xsl:when test="@localize='true'">
  705. <xsl:value-of select="concat($img_url_prefix,@src,'?lang=',$lang)"/>
  706. </xsl:when>
  707. <xsl:otherwise>
  708. <xsl:value-of select="concat($img_url_prefix,@src)"/>
  709. </xsl:otherwise>
  710. </xsl:choose>
  711. </xsl:otherwise>
  712. </xsl:choose>
  713. </xsl:variable>
  714. <!--<xsl:variable name="src"><xsl:value-of select="concat($img_url_prefix,@src)"/></xsl:variable>-->
  715. <xsl:variable name="alt"><xsl:value-of select="./alt"/></xsl:variable>
  716. <xsl:variable name="width" select="''"/> <!-- Images don't all have the correct size -->
  717. <xsl:variable name="height" select="''"/><!-- Image don't all have the correct size -->
  718. <img src="{$src}" alt="{$alt}" title="{$alt}">
  719. <xsl:if test="not($width='')"><xsl:attribute name="width"><xsl:value-of select="$width"/></xsl:attribute></xsl:if>
  720. <xsl:if test="not($height='')"><xsl:attribute name="height"><xsl:value-of select="$height"/></xsl:attribute></xsl:if>
  721. </img>
  722. </xsl:template>
  723. <!-- Insert a Table -->
  724. <xsl:template name="inserttable">
  725. <xsl:variable name="imgsrc"> <!-- see if we are in an image table -->
  726. <xsl:value-of select="tablerow/tablecell[1]/paragraph[1]/image/@src"/>
  727. </xsl:variable>
  728. <xsl:choose>
  729. <xsl:when test="count(descendant::tablecell)=1">
  730. <table border="0" class="onecell" cellpadding="0" cellspacing="0">
  731. <xsl:apply-templates />
  732. </table>
  733. </xsl:when>
  734. <xsl:when test="descendant::tablecell[1]/descendant::image">
  735. <table border="0" class="icontable" cellpadding="5" cellspacing="0">
  736. <xsl:apply-templates mode="icontable"/>
  737. </table>
  738. </xsl:when>
  739. <xsl:when test="@class='wide'">
  740. <table border="1" class="{@class}" cellpadding="0" cellspacing="0" width="100%" >
  741. <xsl:apply-templates />
  742. </table>
  743. </xsl:when>
  744. <xsl:when test="not(@class='')">
  745. <table border="1" class="{@class}" cellpadding="0" cellspacing="0" >
  746. <xsl:apply-templates />
  747. </table>
  748. </xsl:when>
  749. <xsl:otherwise>
  750. <table border="1" class="border" cellpadding="0" cellspacing="0" >
  751. <xsl:apply-templates />
  752. </table>
  753. </xsl:otherwise>
  754. </xsl:choose>
  755. <br/>
  756. </xsl:template>
  757. <xsl:template name="resolveembed">
  758. <div class="embedded">
  759. <xsl:variable name="archive"><xsl:value-of select="concat(substring-before(substring-after(@href,'text/'),'/'),'/')"/></xsl:variable>
  760. <xsl:variable name="dbpostfix"><xsl:call-template name="createDBpostfix"><xsl:with-param name="archive" select="$archive"/></xsl:call-template></xsl:variable>
  761. <xsl:variable name="href"><xsl:value-of select="concat($urlpre,$archive,substring-before(@href,'#'),$urlpost,$dbpostfix)"/></xsl:variable>
  762. <xsl:variable name="anc"><xsl:value-of select="substring-after(@href,'#')"/></xsl:variable>
  763. <xsl:variable name="docum" select="document($href)"/>
  764. <xsl:call-template name="insertembed">
  765. <xsl:with-param name="doc" select="$docum" />
  766. <xsl:with-param name="anchor" select="$anc" />
  767. </xsl:call-template>
  768. </div>
  769. </xsl:template>
  770. <xsl:template name="resolveembedvar">
  771. <xsl:if test="not(@href='text/shared/00/00000004.xhp#wie')"> <!-- special treatment if howtoget links -->
  772. <xsl:variable name="archive"><xsl:value-of select="concat(substring-before(substring-after(@href,'text/'),'/'),'/')"/></xsl:variable>
  773. <xsl:variable name="dbpostfix"><xsl:call-template name="createDBpostfix"><xsl:with-param name="archive" select="$archive"/></xsl:call-template></xsl:variable>
  774. <xsl:variable name="href"><xsl:value-of select="concat($urlpre,$archive,substring-before(@href,'#'),$urlpost,$dbpostfix)"/></xsl:variable>
  775. <xsl:variable name="anchor"><xsl:value-of select="substring-after(@href,'#')"/></xsl:variable>
  776. <xsl:variable name="doc" select="document($href)"/>
  777. <xsl:choose>
  778. <xsl:when test="$doc//variable[@id=$anchor]"> <!-- test for a variable of that name -->
  779. <xsl:apply-templates select="$doc//variable[@id=$anchor]" mode="embedded"/>
  780. </xsl:when>
  781. <xsl:otherwise> <!-- or give up -->
  782. <span class="bug">[<xsl:value-of select="@href"/> not found].</span>
  783. </xsl:otherwise>
  784. </xsl:choose>
  785. </xsl:if>
  786. </xsl:template>
  787. <!-- Apply -->
  788. <xsl:template name="apply">
  789. <xsl:param name="embedded" />
  790. <xsl:choose>
  791. <xsl:when test="$embedded = 'yes'">
  792. <xsl:apply-templates mode="embedded"/>
  793. </xsl:when>
  794. <xsl:otherwise>
  795. <xsl:apply-templates />
  796. </xsl:otherwise>
  797. </xsl:choose>
  798. </xsl:template>
  799. <xsl:template name="createDBpostfix">
  800. <xsl:param name="archive"/>
  801. <xsl:variable name="newDB">
  802. <xsl:choose>
  803. <xsl:when test="(substring($archive,1,6) = 'shared')"><xsl:value-of select="$Database"/></xsl:when>
  804. <xsl:otherwise><xsl:value-of select="substring-before($archive,'/')"/></xsl:otherwise>
  805. </xsl:choose>
  806. </xsl:variable>
  807. <xsl:value-of select="concat($am,'DbPAR=',$newDB)"/>
  808. </xsl:template>
  809. </xsl:stylesheet>