home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 June / PCpro_2005_06.ISO / files / opensource / openoffice / openofficeorg1.cab / main_transform.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2005-01-28  |  32.0 KB  |  913 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <!-- 
  4.          =========================
  5.                   DEBUG VERSION ONLY
  6.         =========================
  7.  
  8. //-->
  9.  
  10. <!--***********************************************************************
  11.   This is the main transformation style sheet for transforming.
  12.   Only use with OOo 2.0
  13.   Owner: fpe@openoffice.org
  14.   =========================================================================
  15.   Changes Log
  16.     May 24 2004 Created
  17.     Aug 24 2004 Fixed for help2 CWS
  18.     Aug 27 2004 Added css link, fixed missing embed-mode for variable
  19.                 Removed width/height for images
  20.     Sep 03 2004 Modularized xsl, added some embedded modes
  21.     Oct 08 2004 Fixed bug wrong mode "embedded" for links
  22.                 Added embedded modes for embed and embedvar (for cascaded embeds)
  23.                 Added <p> tags around falsely embedded pars and vars
  24.     Dec 08 2004 #i38483#, fixed wrong handling of web links
  25.                 #i37377#, fixed missing usage of Database parameter for switching
  26.     Jan 04 2005 #i38905#, fixed buggy branding replacement template
  27. ***********************************************************************//-->
  28.  
  29. <!--***********************************************************************
  30.  
  31.  *
  32.  *  The Contents of this file are made available subject to the terms of
  33.  *  either of the following licenses
  34.  *
  35.  *         - GNU Lesser General Public License Version 2.1
  36.  *         - Sun Industry Standards Source License Version 1.1
  37.  *
  38.  *  Sun Microsystems Inc., October, 2000
  39.  *
  40.  *  GNU Lesser General Public License Version 2.1
  41.  *  =============================================
  42.  *  Copyright 2000 by Sun Microsystems, Inc.
  43.  *  901 San Antonio Road, Palo Alto, CA 94303, USA
  44.  *
  45.  *  This library is free software; you can redistribute it and/or
  46.  *  modify it under the terms of the GNU Lesser General Public
  47.  *  License version 2.1, as published by the Free Software Foundation.
  48.  *
  49.  *  This library is distributed in the hope that it will be useful,
  50.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  51.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  52.  *  Lesser General Public License for more details.
  53.  *
  54.  *  You should have received a copy of the GNU Lesser General Public
  55.  *  License along with this library; if not, write to the Free Software
  56.  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  57.  *  MA  02111-1307  USA
  58.  *
  59.  *
  60.  *  Sun Industry Standards Source License Version 1.1
  61.  *  =================================================
  62.  *  The contents of this file are subject to the Sun Industry Standards
  63.  *  Source License Version 1.1 (the "License"); You may not use this file
  64.  *  except in compliance with the License. You may obtain a copy of the
  65.  *  License at http://www.openoffice.org/license.html.
  66.  *
  67.  *  Software provided under this License is provided on an "AS IS" basis,
  68.  *  WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
  69.  *  WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
  70.  *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
  71.  *  See the License for the specific provisions governing your rights and
  72.  *  obligations concerning the Software.
  73.  *
  74.  *  The Initial Developer of the Original Code is: Sun Microsystems, Inc..
  75.  *
  76.  *  Copyright: 2000 by Sun Microsystems, Inc.
  77.  *
  78.  *  All Rights Reserved.
  79.  *
  80.  *  Contributor(s): _______________________________________
  81.  *
  82.  *
  83.  ************************************************************************-->
  84.  
  85. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  86.  
  87. <xsl:output indent="yes" method="html"/>
  88.  
  89. <!--
  90. ############################
  91. # Variables and Parameters #
  92. ############################
  93. //-->
  94.  
  95. <!-- General Usage -->
  96. <xsl:variable name="am" select="'&'"/>
  97. <xsl:variable name="sl" select="'/'"/>
  98. <xsl:variable name="qt" select="'"'"/>
  99.  
  100. <!-- generic Icon alt text -->
  101. <xsl:variable name="alttext" select="'text/shared/00/icon_alt.xhp'"/>
  102.  
  103. <!-- For calculating pixel sizes -->
  104. <xsl:variable name="dpi" select="'96'"/>
  105. <xsl:variable name="dpcm" select="'38'"/>
  106.  
  107. <!-- Product brand variables used in the help files -->
  108. <xsl:variable name="brand1" select="'$[officename]'"/>
  109. <xsl:variable name="brand2" select="'$[officeversion]'"/>
  110. <xsl:variable name="brand3" select="'%PRODUCTNAME'"/>
  111. <xsl:variable name="brand4" select="'%PRODUCTVERSION'"/>
  112.  
  113. <!-- meta data variables from the help file -->
  114. <xsl:variable name="filename" select="/helpdocument/meta/topic/filename"/>
  115. <xsl:variable name="topic_id" select="/helpdocument/meta/topic/@id"/>
  116. <xsl:variable name="topic_status" select="/helpdocument/meta/topic/@status"/>
  117. <xsl:variable name="title" select="/helpdocument/meta/topic/title"/>
  118. <xsl:variable name="lang" select="/helpdocument/meta/topic/title/@xml-lang"/>
  119.  
  120. <!-- Module and the corresponding switching values-->
  121. <xsl:param name="Database" select="'swriter'"/>
  122. <xsl:variable name="module" select="$Database"/>
  123. <xsl:variable name="appl">
  124.     <xsl:choose>
  125.         <xsl:when test="$module = 'swriter'"><xsl:value-of select="'WRITER'"/></xsl:when>
  126.         <xsl:when test="$module = 'scalc'"><xsl:value-of select="'CALC'"/></xsl:when>
  127.         <xsl:when test="$module = 'sdraw'"><xsl:value-of select="'DRAW'"/></xsl:when>
  128.         <xsl:when test="$module = 'simpress'"><xsl:value-of select="'IMPRESS'"/></xsl:when>
  129.         <xsl:when test="$module = 'schart'"><xsl:value-of select="'CHART'"/></xsl:when>
  130.         <xsl:when test="$module = 'sbasic'"><xsl:value-of select="'BASIC'"/></xsl:when>
  131.         <xsl:when test="$module = 'smath'"><xsl:value-of select="'MATH'"/></xsl:when>
  132.     </xsl:choose>
  133. </xsl:variable>
  134.  
  135. <!-- the other parameters given by the help caller -->
  136. <xsl:param name="System" select="'WIN'"/>
  137. <xsl:param name="productname" select="'Office'"/>
  138. <xsl:param name="productversion" select="''"/>
  139. <!-- this is were the images are -->
  140. <xsl:param name="imgrepos" select="''"/>
  141. <xsl:param name="Id" />
  142. <!-- (lame) distinction between OS and Commercial -->
  143. <xsl:param name="distrib">
  144.     <xsl:choose>
  145.         <xsl:when test="starts-with($productname,'OpenOffice')">
  146.             <xsl:value-of select="'OPENSOURCE'"/>
  147.         </xsl:when>
  148.         <xsl:otherwise>
  149.             <xsl:value-of select="'COMMERCIAL'"/>
  150.         </xsl:otherwise>
  151.     </xsl:choose>
  152. </xsl:param>
  153.  
  154. <!-- parts of help and image urls -->
  155.  
  156.  
  157. <xsl:variable name="help_url_prefix" select="'vnd.sun.star.help://'"/>
  158. <xsl:variable name="img_url_prefix" select="concat('vnd.sun.star.pkg://',$imgrepos,'/')"/>
  159. <xsl:variable name="urlpost" select="concat('?Language=',$lang,$am,'System=',$System,$am,'UseDB=no')"/>
  160. <xsl:variable name="urlpre" select="$help_url_prefix" /> 
  161. <xsl:variable name="linkprefix" select="$urlpre"/>
  162. <xsl:variable name="linkpostfix" select="$urlpost"/>
  163.  
  164. <!-- DEBUG:
  165. <xsl:variable name="help_url_prefix" select="'file:///opt/staroffice8-cwshelp2/help/en'"/>
  166. <xsl:variable name="img_url_prefix" select="''"/>
  167. <xsl:variable name="urlpost" select="''"/>
  168. <xsl:variable name="urlpre" select="$help_url_prefix" /> 
  169. <xsl:variable name="linkprefix" select="$urlpre"/>
  170. <xsl:variable name="linkpostfix" select="$urlpost"/>
  171. //-->
  172.  
  173. <xsl:variable name="css" select="'default.css'"/>
  174.  
  175. <!-- images for notes, tips and warnings -->
  176. <xsl:variable name="note_img" select="concat($img_url_prefix,'res/helpimg/note.png')"/>
  177. <xsl:variable name="tip_img" select="concat($img_url_prefix,'res/helpimg/tip.png')"/>
  178. <xsl:variable name="warning_img" select="concat($img_url_prefix,'res/helpimg/warning.png')"/>
  179.  
  180. <!--
  181. #############
  182. # Templates #
  183. #############
  184. //-->
  185.  
  186. <!-- Create the document skeleton -->
  187. <xsl:template match="/">
  188.     <xsl:variable name="csslink" select="concat($urlpre,'/',$urlpost)"/>
  189.     <html>
  190.         <head>
  191.             <title><xsl:value-of select="$title"/></title>
  192.             <link href="{$csslink}" rel="Stylesheet" type="text/css" /> <!-- stylesheet link -->
  193.           <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
  194.         </head>
  195.         <body lang="{$lang}">
  196.             <!-- DEBUG ME START    
  197.             <xsl:variable name="srcname"><xsl:value-of select="concat('file:///k:/WORKBENCH/helpcontent2/source',$filename)"/></xsl:variable>
  198.             <div class="debug">
  199.                 <p class="{/helpdocument/meta/topic/@status}">
  200.                 <xsl:if test="/helpdocument/meta/topic[@indexer='exclude']">NOT INDEXED - </xsl:if>
  201.                 <a href="{$srcname}"><xsl:value-of select="$filename"/></a></p>
  202.                 <p><xsl:value-of select="count(//embed)"/> embedded sections<br/>
  203.                 <xsl:value-of select="count(//embedvar)"/> embedded variables<br/>
  204.                 <xsl:value-of select="count(//image)"/> images<br/>
  205.                 <xsl:value-of select="count(//link)"/> links</p>
  206.             </div>
  207.             DEBUG ME END    
  208.             //-->
  209.             <xsl:apply-templates select="/helpdocument/body"/>
  210.         </body>
  211.     </html>
  212. </xsl:template>
  213.  
  214. <!-- AHELP -->
  215. <xsl:template match="ahelp">
  216.     <xsl:if test="not(@visibility='hidden')"><span class="avis"><xsl:apply-templates /></span></xsl:if>
  217. </xsl:template>
  218.  
  219. <!-- ALT -->
  220. <xsl:template match="alt"/>
  221.  
  222. <!-- BOOKMARK -->
  223. <xsl:template match="bookmark">
  224.     <a name="{@id}"></a>
  225.     <xsl:choose>
  226.         <xsl:when test="starts-with(@branch,'hid')" />
  227.         <xsl:otherwise><xsl:apply-templates /></xsl:otherwise>
  228.     </xsl:choose>
  229. </xsl:template>
  230. <xsl:template match="bookmark" mode="embedded" />
  231.  
  232. <!-- BOOKMARK_VALUE -->
  233. <xsl:template match="bookmark_value" />
  234.  
  235. <!-- BR -->
  236. <xsl:template match="br"><br /></xsl:template>
  237.  
  238. <!-- CAPTION -->
  239. <xsl:template match="caption" />
  240.  
  241. <!-- CASE -->
  242. <xsl:template match="case"><xsl:call-template name="insertcase" /></xsl:template>
  243. <xsl:template match="case" mode="embedded">
  244.     <xsl:call-template name="insertcase">
  245.         <xsl:with-param name="embedded" select="'yes'"/>
  246.     </xsl:call-template>
  247. </xsl:template>
  248.  
  249. <!-- CASEINLINE -->
  250. <xsl:template match="caseinline"><xsl:call-template name="insertcase" /></xsl:template>
  251. <xsl:template match="caseinline" mode="embedded">
  252.     <xsl:call-template name="insertcase">
  253.         <xsl:with-param name="embedded" select="'yes'"/>
  254.     </xsl:call-template>
  255. </xsl:template>
  256.  
  257. <!-- COMMENT -->
  258. <xsl:template match="comment" />
  259. <xsl:template match="comment" mode="embedded"/>
  260.  
  261. <!-- CREATED -->
  262. <xsl:template match="created" />
  263.  
  264. <!-- DEFAULT -->
  265. <xsl:template match="default"><xsl:call-template name="insertdefault" /></xsl:template>
  266. <xsl:template match="default" mode="embedded">
  267.     <xsl:call-template name="insertdefault">
  268.         <xsl:with-param name="embedded" select="'yes'"/>
  269.     </xsl:call-template>
  270. </xsl:template>
  271.  
  272. <!-- DEFAULTINLINE -->
  273. <xsl:template match="defaultinline"><xsl:call-template name="insertdefault" /></xsl:template>
  274. <xsl:template match="defaultinline" mode="embedded">
  275.     <xsl:call-template name="insertdefault">
  276.         <xsl:with-param name="embedded" select="'yes'"/>
  277.     </xsl:call-template>
  278. </xsl:template>
  279.  
  280. <!-- EMBED -->
  281. <xsl:template match="embed"><xsl:call-template name="resolveembed"/></xsl:template>
  282. <xsl:template match="embed" mode="embedded"><xsl:call-template name="resolveembed"/></xsl:template>
  283.  
  284. <!-- EMBEDVAR -->
  285. <xsl:template match="embedvar"><xsl:call-template name="resolveembedvar"/></xsl:template>
  286. <xsl:template match="embedvar" mode="embedded"><xsl:call-template name="resolveembedvar"/></xsl:template>
  287.  
  288. <!-- EMPH -->
  289. <xsl:template match="emph">
  290.     <span class="emph"><xsl:apply-templates /></span>
  291. </xsl:template>
  292. <xsl:template match="emph" mode="embedded">
  293.     <span class="emph"><xsl:apply-templates /></span>
  294. </xsl:template>
  295.  
  296. <!-- FILENAME -->
  297. <xsl:template match="filename" />
  298.  
  299. <!-- HISTORY -->
  300. <xsl:template match="history" />
  301.  
  302. <!-- IMAGE -->
  303. <xsl:template match="image"><xsl:call-template name="insertimage"/></xsl:template>
  304. <xsl:template match="image" mode="embedded"><xsl:call-template name="insertimage"/></xsl:template>
  305.  
  306. <!-- ITEM -->
  307. <xsl:template match="item"><span class="{@type}"><xsl:apply-templates /></span></xsl:template>
  308. <xsl:template match="item" mode="embedded"><span class="{@type}"><xsl:apply-templates /></span></xsl:template>
  309.  
  310. <!-- LASTEDITED -->
  311. <xsl:template match="lastedited" />
  312.  
  313. <!-- LINK -->
  314. <xsl:template match="link">
  315.     <xsl:choose> <!-- don't insert the heading link to itself -->
  316.         <xsl:when test="(concat('/',@href) = /helpdocument/meta/topic/filename) or (@href = /helpdocument/meta/topic/filename)">
  317.             <xsl:apply-templates />
  318.         </xsl:when>
  319.         <xsl:when test="contains(child::embedvar/@href,'/00/00000004.xhp#wie')"> <!-- special treatment of howtoget links -->
  320.             <xsl:call-template name="insert_howtoget">
  321.                 <xsl:with-param name="linkhref" select="@href"/>
  322.             </xsl:call-template>
  323.         </xsl:when>
  324.         <xsl:otherwise>
  325.             <xsl:call-template name="createlink" /> 
  326.         </xsl:otherwise>
  327.     </xsl:choose>
  328. </xsl:template>
  329. <xsl:template match="link" mode="embedded">
  330.     <xsl:call-template name="createlink"/>
  331. </xsl:template>
  332.  
  333. <!-- LIST -->
  334. <xsl:template match="list">
  335.     <xsl:choose>
  336.         <xsl:when test="@type='ordered'">
  337.             <ol>
  338.                 <xsl:if test="@startwith">
  339.                     <xsl:attribute name="start"><xsl:value-of select="@startwith"/></xsl:attribute>
  340.                 </xsl:if>
  341.                 <xsl:apply-templates />
  342.             </ol>
  343.         </xsl:when>
  344.         <xsl:otherwise>
  345.             <ul><xsl:apply-templates /></ul>
  346.         </xsl:otherwise>
  347.     </xsl:choose>
  348. </xsl:template>
  349.  
  350. <!-- LISTITEM -->
  351. <xsl:template match="listitem">
  352.     <li><xsl:apply-templates /></li>
  353. </xsl:template>
  354.  
  355. <!-- META, SEE HEADER -->
  356. <xsl:template match="meta" />
  357.  
  358. <!-- OBJECT (UNUSED) -->
  359. <xsl:template match="object" />
  360.  
  361. <!-- PARAGRAPH -->
  362. <xsl:template match="paragraph">
  363.     <xsl:choose>
  364.         
  365.         <xsl:when test="@role='heading'">
  366.             <xsl:call-template name="insertheading">
  367.                 <xsl:with-param name="level" select="@level"/>
  368.             </xsl:call-template>
  369.         </xsl:when>
  370.         
  371.         <xsl:when test="contains(' note warning tip ',@role)">
  372.             <xsl:call-template name="insertnote">
  373.                 <xsl:with-param name="type" select="@role" />
  374.             </xsl:call-template>
  375.         </xsl:when>
  376.         
  377.         <xsl:when test="contains(descendant::embedvar/@href,'/00/00000004.xhp#wie')"> <!-- special treatment of howtoget links -->
  378.             <xsl:apply-templates />
  379.         </xsl:when>        
  380.         
  381.         <xsl:otherwise>
  382.             <xsl:call-template name="insertpara" />
  383.         </xsl:otherwise>
  384.     
  385.     </xsl:choose>
  386. </xsl:template>
  387.  
  388. <xsl:template match="paragraph" mode="embedded">
  389.         <xsl:choose>
  390.         
  391.         <xsl:when test="@role='heading'">    <!-- increase the level of headings that are embedded -->
  392.         <!-- 
  393.            The internal sablotron processor does not seem to support the number function.
  394.              Therefore, we need a workaround for
  395.              <xsl:variable name="level"><xsl:value-of select="number(@level)+1"/></xsl:variable>
  396.         -->
  397.             <xsl:variable name="newlevel">
  398.                 <xsl:choose>
  399.                     <xsl:when test="@level='1'"><xsl:value-of select="'2'"/></xsl:when>
  400.                     <xsl:when test="@level='2'"><xsl:value-of select="'2'"/></xsl:when>
  401.                     <xsl:when test="@level='3'"><xsl:value-of select="'3'"/></xsl:when>
  402.                     <xsl:when test="@level='4'"><xsl:value-of select="'4'"/></xsl:when>
  403.                     <xsl:when test="@level='5'"><xsl:value-of select="'5'"/></xsl:when>
  404.                 </xsl:choose>
  405.             </xsl:variable>
  406.             
  407.             <xsl:call-template name="insertheading">
  408.                 <xsl:with-param name="level" select="$newlevel"/>
  409.                 <xsl:with-param name="embedded" select="'yes'"/>
  410.             </xsl:call-template>
  411.         </xsl:when>
  412.         
  413.         <xsl:when test="contains(' note warning tip ',@role)">
  414.             <xsl:call-template name="insertnote">
  415.                 <xsl:with-param name="type" select="@role" />
  416.             </xsl:call-template>
  417.         </xsl:when>
  418.         
  419.         <xsl:when test="contains(descendant::embedvar/@href,'/00/00000004.xhp#wie')"> <!-- special treatment of howtoget links -->
  420.             <xsl:apply-templates />
  421.         </xsl:when>        
  422.         
  423.         <xsl:otherwise>
  424.             <xsl:call-template name="insertpara" />
  425.         </xsl:otherwise>
  426.         
  427.     </xsl:choose>
  428. </xsl:template>
  429.  
  430.  
  431. <!-- SECTION -->
  432. <xsl:template match="section">
  433.     <a name="{@id}"></a>
  434.  
  435.         <xsl:choose>
  436.             
  437.             <xsl:when test="@id='relatedtopics'">
  438.                 <div class="relatedtopics">
  439.                     <xsl:variable name="href"><xsl:value-of select="concat($urlpre,'shared/text/shared/00/00000004.xhp',$urlpost)"/></xsl:variable>
  440.                     <xsl:variable name="anchor"><xsl:value-of select="'related'"/></xsl:variable>
  441.                     <xsl:variable name="doc" select="document($href)"/>
  442.                     <p class="related">
  443.                         <xsl:apply-templates select="$doc//variable[@id=$anchor]"/>
  444.                     </p>
  445.                     <div class="relatedbody">
  446.                         <xsl:apply-templates />
  447.                     </div>
  448.                 </div>
  449.             </xsl:when>
  450.             
  451.             <xsl:when test="@id='howtoget'">
  452.                 <xsl:call-template name="insert_howtoget" />
  453.             </xsl:when>
  454.             
  455.             <xsl:otherwise>
  456.                         <xsl:apply-templates/>
  457.             </xsl:otherwise>
  458.         
  459.         </xsl:choose>
  460.  
  461. </xsl:template>
  462.  
  463.  
  464. <!-- SECTION -->
  465. <xsl:template match="section" mode="embedded">
  466.     <a name="{@id}"></a>
  467.     <xsl:apply-templates mode="embedded"/>
  468. </xsl:template>
  469.  
  470. <!-- SORT -->
  471. <xsl:template match="sort" >
  472.     <xsl:apply-templates><xsl:sort select="descendant::paragraph"/></xsl:apply-templates>
  473. </xsl:template>
  474. <xsl:template match="sort" mode="embedded">
  475.     <xsl:apply-templates><xsl:sort select="descendant::paragraph"/></xsl:apply-templates>
  476. </xsl:template>
  477.  
  478. <!-- SWITCH -->
  479. <xsl:template match="switch"><xsl:apply-templates /></xsl:template>
  480. <xsl:template match="switch" mode="embedded"><xsl:apply-templates /></xsl:template>
  481.  
  482. <!-- SWITCHINLINE -->
  483. <xsl:template match="switchinline"><xsl:apply-templates /></xsl:template>
  484. <xsl:template match="switchinline" mode="embedded"><xsl:apply-templates mode="embedded"/></xsl:template>
  485.  
  486. <!-- TABLE -->
  487. <xsl:template match="table"><xsl:call-template name="inserttable"/></xsl:template>
  488. <xsl:template match="table" mode="embedded"><xsl:call-template name="inserttable"/></xsl:template>
  489.  
  490. <!-- TABLECELL -->
  491. <xsl:template match="tablecell"><td valign="top"><xsl:apply-templates /></td></xsl:template>
  492. <xsl:template match="tablecell" mode="icontable"><td valign="top"><xsl:apply-templates/></td></xsl:template>
  493. <xsl:template match="tablecell" mode="embedded"><td valign="top"><xsl:apply-templates mode="embedded"/></td></xsl:template>
  494.  
  495. <!-- TABLEROW -->
  496. <xsl:template match="tablerow"><tr><xsl:apply-templates /></tr></xsl:template>
  497. <xsl:template match="tablerow" mode="icontable"><tr><xsl:apply-templates mode="icontable"/></tr></xsl:template>
  498. <xsl:template match="tablerow" mode="embedded"><tr><xsl:apply-templates mode="embedded"/></tr></xsl:template>
  499.  
  500. <!-- TITLE -->
  501. <xsl:template match="title"/>
  502.  
  503. <!-- TOPIC -->
  504. <xsl:template match="topic"/>
  505.  
  506. <!-- VARIABLE -->
  507. <xsl:template match="variable"><a name="{@id}"></a><xsl:apply-templates /></xsl:template>
  508. <xsl:template match="variable" mode="embedded"><a name="{@id}"></a><xsl:apply-templates mode="embedded"/></xsl:template>
  509.  
  510. <xsl:template match="text()">
  511.     <xsl:call-template name="brand">
  512.         <xsl:with-param name="string"><xsl:value-of select="."/></xsl:with-param>
  513.     </xsl:call-template>
  514. </xsl:template>
  515.  
  516. <xsl:template match="text()" mode="embedded">
  517.     <xsl:call-template name="brand">
  518.         <xsl:with-param name="string"><xsl:value-of select="."/></xsl:with-param>
  519.     </xsl:call-template>
  520. </xsl:template>
  521.  
  522. <!-- In case of missing help files -->
  523. <xsl:template match="help-id-missing"><xsl:value-of select="$Id"/></xsl:template>
  524.  
  525. <!-- 
  526. ###################
  527. # NAMED TEMPLATES #
  528. ###################
  529. //-->
  530.  
  531. <!-- Branding -->
  532. <xsl:template name="brand" >
  533.     <xsl:param name="string"/>
  534.     
  535.     <xsl:choose>
  536.         
  537.         <xsl:when test="contains($string,$brand1)">
  538.            <xsl:variable name="newstr">
  539.                 <xsl:value-of select="substring-before($string,$brand1)"/>
  540.                 <xsl:value-of select="$productname"/>
  541.                 <xsl:value-of select="substring-after($string,$brand1)"/>
  542.            </xsl:variable>
  543.             <xsl:call-template name="brand">
  544.                 <xsl:with-param name="string" select="$newstr"/>
  545.             </xsl:call-template>
  546.         </xsl:when>
  547.         
  548.         <xsl:when test="contains($string,$brand2)">
  549.             <xsl:variable name="newstr">
  550.                 <xsl:value-of select="substring-before($string,$brand2)"/>
  551.                 <xsl:value-of select="$productversion"/>
  552.                 <xsl:value-of select="substring-after($string,$brand2)"/>
  553.            </xsl:variable>
  554.             <xsl:call-template name="brand">
  555.                 <xsl:with-param name="string" select="$newstr"/>
  556.             </xsl:call-template>
  557.         </xsl:when>
  558.         
  559.         <xsl:when test="contains($string,$brand3)">
  560.             <xsl:variable name="newstr">
  561.                 <xsl:value-of select="substring-before($string,$brand3)"/>
  562.                 <xsl:value-of select="$productname"/>
  563.                 <xsl:value-of select="substring-after($string,$brand3)"/>
  564.            </xsl:variable>
  565.             <xsl:call-template name="brand">
  566.                 <xsl:with-param name="string" select="$newstr"/>
  567.             </xsl:call-template>
  568.         </xsl:when>
  569.         
  570.         <xsl:when test="contains($string,$brand4)">
  571.                 <xsl:variable name="newstr">
  572.                 <xsl:value-of select="substring-before($string,$brand4)"/>
  573.                 <xsl:value-of select="$productversion"/>
  574.                 <xsl:value-of select="substring-after($string,$brand4)"/>
  575.            </xsl:variable>
  576.             <xsl:call-template name="brand">
  577.                 <xsl:with-param name="string" select="$newstr"/>
  578.             </xsl:call-template>
  579.         </xsl:when>
  580.         
  581.         <xsl:otherwise>
  582.             <xsl:value-of select="$string"/>
  583.         </xsl:otherwise>
  584.     </xsl:choose> 
  585.     
  586. </xsl:template>
  587.  
  588.  
  589. <!-- Insert Paragraph -->
  590. <xsl:template name="insertpara">
  591.     <xsl:variable name="role">
  592.         <xsl:choose>
  593.             <xsl:when test="ancestor::table">
  594.                 <xsl:value-of select="concat(@role,'intable')"/>
  595.             </xsl:when>
  596.             <xsl:otherwise>
  597.                 <xsl:value-of select="@role"/>
  598.             </xsl:otherwise>
  599.         </xsl:choose>
  600.     </xsl:variable>
  601.     <p class="{$role}"><xsl:apply-templates /></p>
  602. </xsl:template>
  603.  
  604. <!-- Insert "How to get Link" -->
  605. <xsl:template name="insert_howtoget">
  606.     <xsl:param name="linkhref" />
  607.     <xsl:variable name="archive" select="'shared'"/>
  608.     <xsl:variable name="tmp_href"><xsl:value-of select="concat($urlpre,'shared/text/shared/00/00000004.xhp',$urlpost)"/></xsl:variable>    
  609.     <xsl:variable name="tmp_doc" select="document($tmp_href)"/>
  610.     <table class="howtoget" width="100%" border="1" cellpadding="3" cellspacing="0">
  611.         <tr>
  612.             <td>
  613.                 <p class="howtogetheader"><xsl:apply-templates select="$tmp_doc//variable[@id='wie']"/></p>
  614.                 <div class="howtogetbody">
  615.                 <xsl:choose>
  616.                     <xsl:when test="$linkhref = ''"> <!-- new style -->
  617.                         <xsl:apply-templates/>
  618.                     </xsl:when>
  619.                     <xsl:otherwise> <!-- old style -->
  620.                         <xsl:variable name="archive1"><xsl:value-of select="concat(substring-before(substring-after($linkhref,'text/'),'/'),'/')"/></xsl:variable>
  621.                         <xsl:variable name="href"><xsl:value-of select="concat($urlpre,$archive1,substring-before($linkhref,'#'),$urlpost)"/></xsl:variable>
  622.                         <xsl:variable name="anc"><xsl:value-of select="substring-after($linkhref,'#')"/></xsl:variable>
  623.                         <xsl:variable name="docum" select="document($href)"/>
  624.                         
  625.                         <xsl:call-template name="insertembed">
  626.                             <xsl:with-param name="doc" select="$docum" />
  627.                             <xsl:with-param name="anchor" select="$anc" />
  628.                         </xsl:call-template>
  629.  
  630.                     </xsl:otherwise>
  631.                 </xsl:choose>                
  632.                 </div>
  633.             </td>
  634.         </tr>
  635.     </table>
  636.     <br/>
  637. </xsl:template>
  638.  
  639. <!-- Create a link -->
  640. <xsl:template name="createlink">
  641. <xsl:variable name="archive"><xsl:value-of select="concat(substring-before(substring-after(@href,'text/'),'/'),'/')"/></xsl:variable>
  642.     <xsl:choose>
  643.         <xsl:when test="contains(@href,'#')">
  644.             <xsl:variable name="anchor"><xsl:value-of select="concat('#',substring-after(@href,'#'))"/></xsl:variable>
  645.             <xsl:variable name="href"><xsl:value-of select="concat($linkprefix,$archive,substring-before(@href,'#'),$linkpostfix,$anchor)"/></xsl:variable>
  646.             <a href="{$href}"><xsl:apply-templates /></a>
  647.         </xsl:when>
  648.         <xsl:when test="starts-with(@href,'http://')">  <!-- web links -->
  649.             <a href="{@href}"><xsl:apply-templates /></a>
  650.         </xsl:when>
  651.         <xsl:otherwise>
  652.             <xsl:variable name="href"><xsl:value-of select="concat($linkprefix,$archive,@href,$linkpostfix)"/></xsl:variable>
  653.             <a href="{$href}"><xsl:apply-templates /></a>
  654.         </xsl:otherwise>
  655.     </xsl:choose>
  656. </xsl:template>
  657.  
  658. <!-- Insert Note, Warning, or Tip -->
  659. <xsl:template name="insertnote">
  660.     <xsl:param name="type" /> <!-- note, tip, or warning -->
  661.     <xsl:variable name="imgsrc">
  662.         <xsl:choose>
  663.             <xsl:when test="$type='note'"><xsl:value-of select="$note_img"/></xsl:when>
  664.             <xsl:when test="$type='tip'"><xsl:value-of select="$tip_img"/></xsl:when>
  665.             <xsl:when test="$type='warning'"><xsl:value-of select="$warning_img"/></xsl:when>
  666.         </xsl:choose>
  667.     </xsl:variable>
  668.     <xsl:variable name="alt">
  669.         <xsl:variable name="href"><xsl:value-of select="concat($urlpre,'shared/',$alttext,$urlpost)"/></xsl:variable>
  670.         <xsl:variable name="anchor"><xsl:value-of select="concat('alt_',$type)"/></xsl:variable>
  671.         <xsl:variable name="doc" select="document($href)"/>
  672.         <xsl:apply-templates select="$doc//variable[@id=$anchor]" mode="embedded"/>
  673.     </xsl:variable>
  674.     <div class="{$type}">
  675.         <table border="0" class="{$type}" cellspacing="0" cellpadding="5">
  676.             <tr>
  677.                 <td><img src="{$imgsrc}" alt="{$alt}" title="{$alt}"/></td>
  678.                 <td><xsl:apply-templates /></td>
  679.             </tr>
  680.         </table>
  681.     </div>
  682.     <br/>
  683. </xsl:template>
  684.  
  685. <!-- Insert a heading -->
  686. <xsl:template name="insertheading">
  687.     <xsl:param name="level" />
  688.     <xsl:param name="embedded" />
  689.     <xsl:text disable-output-escaping="yes"><h</xsl:text><xsl:value-of select="$level"/><xsl:text disable-output-escaping="yes">></xsl:text>
  690.         <xsl:choose>
  691.             <xsl:when test="$embedded = 'yes'">
  692.                 <xsl:apply-templates mode="embedded"/>
  693.             </xsl:when>
  694.             <xsl:otherwise>
  695.                 <xsl:apply-templates />
  696.             </xsl:otherwise>
  697.         </xsl:choose>
  698.     <xsl:text disable-output-escaping="yes"></h</xsl:text><xsl:value-of select="$level"/><xsl:text disable-output-escaping="yes">></xsl:text>
  699. </xsl:template>
  700.  
  701. <!-- Evaluate a case or caseinline switch -->
  702. <xsl:template name="insertcase">
  703.     <xsl:param name="embedded" />
  704.     <xsl:choose>
  705.         <xsl:when test="parent::switch[@select='sys'] or parent::switchinline[@select='sys']">
  706.             <xsl:if test="@select = $System">
  707.                 <xsl:choose>
  708.                     <xsl:when test="$embedded = 'yes'">
  709.                         <xsl:apply-templates mode="embedded"/>
  710.                     </xsl:when>
  711.                     <xsl:otherwise>
  712.                         <xsl:apply-templates />
  713.                     </xsl:otherwise>
  714.                 </xsl:choose>
  715.             </xsl:if>
  716.         </xsl:when>
  717.         <xsl:when test="parent::switch[@select='appl'] or parent::switchinline[@select='appl']">
  718.             <xsl:if test="@select = $appl">
  719.                 <xsl:choose>
  720.                     <xsl:when test="$embedded = 'yes'">
  721.                         <xsl:apply-templates mode="embedded"/>
  722.                     </xsl:when>
  723.                     <xsl:otherwise>
  724.                         <xsl:apply-templates />
  725.                     </xsl:otherwise>
  726.                 </xsl:choose>
  727.             </xsl:if>
  728.         </xsl:when>
  729.         <xsl:when test="parent::switch[@select='distrib'] or parent::switchinline[@select='distrib']">
  730.             <xsl:if test="@select = $distrib">
  731.                 <xsl:choose>
  732.                     <xsl:when test="$embedded = 'yes'">
  733.                         <xsl:apply-templates mode="embedded"/>
  734.                     </xsl:when>
  735.                     <xsl:otherwise>
  736.                         <xsl:apply-templates />
  737.                     </xsl:otherwise>
  738.                 </xsl:choose>
  739.             </xsl:if>
  740.         </xsl:when>
  741.     </xsl:choose>
  742. </xsl:template>
  743.  
  744. <!-- Evaluate a default or defaultinline switch -->
  745. <xsl:template name="insertdefault">
  746.     <xsl:param name="embedded" />
  747.     
  748.     <xsl:choose>
  749.         <xsl:when test="parent::switch[@select='sys'] or parent::switchinline[@select='sys']">
  750.             <xsl:if test="not(../child::case[@select=$System]) and not(../child::caseinline[@select=$System])">
  751.                 <xsl:choose>
  752.                     <xsl:when test="$embedded = 'yes'">
  753.                         <xsl:apply-templates mode="embedded"/>
  754.                     </xsl:when>
  755.                     <xsl:otherwise>
  756.                         <xsl:apply-templates />
  757.                     </xsl:otherwise>
  758.                 </xsl:choose>
  759.             </xsl:if>
  760.         </xsl:when>
  761.         <xsl:when test="parent::switch[@select='appl'] or parent::switchinline[@select='appl']">
  762.             <xsl:if test="not(../child::case[@select=$appl]) and not(../child::caseinline[@select=$appl])">
  763.                 <xsl:choose>
  764.                     <xsl:when test="$embedded = 'yes'">
  765.                         <xsl:apply-templates mode="embedded"/>
  766.                     </xsl:when>
  767.                     <xsl:otherwise>
  768.                         <xsl:apply-templates />
  769.                     </xsl:otherwise>
  770.                 </xsl:choose>
  771.             </xsl:if>
  772.         </xsl:when>
  773.         <xsl:when test="parent::switch[@select='distrib'] or parent::switchinline[@select='distrib']">
  774.             <xsl:if test="not(../child::case[@select=$distrib]) and not(../child::caseinline[@select=$distrib])">
  775.                 <xsl:choose>
  776.                     <xsl:when test="$embedded = 'yes'">
  777.                         <xsl:apply-templates mode="embedded"/>
  778.                     </xsl:when>
  779.                     <xsl:otherwise>
  780.                         <xsl:apply-templates />
  781.                     </xsl:otherwise>
  782.                 </xsl:choose>
  783.             </xsl:if>
  784.         </xsl:when>
  785.     </xsl:choose>
  786. </xsl:template>
  787.  
  788. <!-- evaluate embeds -->
  789. <xsl:template name="insertembed">
  790.     <xsl:param name="doc" />
  791.     <xsl:param name="anchor" />
  792.     <!-- different embed targets (also falsely used embed instead embedvar) -->
  793.     <xsl:choose>
  794.         <xsl:when test="$doc//section[@id=$anchor]"> <!-- first test for a section of that name -->
  795.             <xsl:apply-templates select="$doc//section[@id=$anchor]" mode="embedded"/>
  796.         </xsl:when>
  797.         <xsl:when test="$doc//paragraph[@id=$anchor]"> <!-- then test for a para of that name -->
  798.             <p class="embedded">
  799.                 <xsl:apply-templates select="$doc//paragraph[@id=$anchor]" mode="embedded"/>
  800.             </p>
  801.         </xsl:when>
  802.         <xsl:when test="$doc//variable[@id=$anchor]"> <!-- then test for a variable of that name -->
  803.             <p class="embedded">
  804.                 <xsl:apply-templates select="$doc//variable[@id=$anchor]" mode="embedded"/>
  805.             </p>
  806.         </xsl:when>
  807.         <xsl:otherwise> <!-- then give up -->
  808.             <p class="bug">D'oh! You found a bug (<xsl:value-of select="@href"/> not found).</p> 
  809.         </xsl:otherwise>
  810.     </xsl:choose>
  811. </xsl:template>
  812.  
  813. <!-- Insert an image -->
  814. <xsl:template name="insertimage">
  815.     <xsl:variable name="src"><xsl:value-of select="concat($img_url_prefix,@src)"/></xsl:variable>
  816.     <xsl:variable name="alt"><xsl:value-of select="./alt"/></xsl:variable>
  817.     <xsl:variable name="width" select="''"/> <!-- Images don't all have the correct size -->
  818.     <xsl:variable name="height" select="''"/><!-- Image don't all have the correct size -->
  819.     <img src="{$src}" alt="{$alt}" title="{$alt}">
  820.         <xsl:if test="not($width='')"><xsl:attribute name="width"><xsl:value-of select="$width"/></xsl:attribute></xsl:if>
  821.         <xsl:if test="not($height='')"><xsl:attribute name="height"><xsl:value-of select="$height"/></xsl:attribute></xsl:if>
  822.     </img>  
  823. </xsl:template>
  824.  
  825. <!-- Insert a Table -->
  826. <xsl:template name="inserttable">
  827.     <xsl:variable name="imgsrc">    <!-- see if we are in an image table -->
  828.         <xsl:value-of select="tablerow/tablecell[1]/paragraph[1]/image/@src"/>
  829.     </xsl:variable>
  830.     
  831.     <xsl:choose>
  832.         
  833.         <xsl:when test="count(descendant::tablecell)=1">
  834.             <table border="0" class="onecell" cellpadding="0" cellspacing="0">
  835.                 <xsl:apply-templates />
  836.          </table>
  837.         </xsl:when>
  838.         
  839.         <xsl:when test="descendant::tablecell[1]/descendant::image">
  840.             <table border="0" class="icontable" cellpadding="5" cellspacing="0">
  841.                 <xsl:apply-templates mode="icontable"/>
  842.          </table>
  843.         </xsl:when>
  844.         
  845.         <xsl:when test="@class='wide'">
  846.             <table border="1" class="{@class}" cellpadding="0" cellspacing="0" width="100%" >
  847.                 <xsl:apply-templates />
  848.          </table>
  849.         </xsl:when>
  850.         
  851.         <xsl:when test="not(@class='')">
  852.             <table border="1" class="{@class}" cellpadding="0" cellspacing="0" >
  853.                 <xsl:apply-templates />
  854.          </table>
  855.         </xsl:when>
  856.         
  857.         <xsl:otherwise>
  858.             <table border="1" class="border" cellpadding="0" cellspacing="0" >
  859.                 <xsl:apply-templates />
  860.          </table>
  861.         </xsl:otherwise>
  862.     </xsl:choose>
  863.     
  864.     <br/>
  865. </xsl:template>
  866.  
  867. <xsl:template name="resolveembed">
  868.     <div class="embedded">
  869.         <xsl:variable name="archive"><xsl:value-of select="concat(substring-before(substring-after(@href,'text/'),'/'),'/')"/></xsl:variable>
  870.         <xsl:variable name="href"><xsl:value-of select="concat($urlpre,$archive,substring-before(@href,'#'),$urlpost)"/></xsl:variable>
  871.         <xsl:variable name="anc"><xsl:value-of select="substring-after(@href,'#')"/></xsl:variable>
  872.         <xsl:variable name="docum" select="document($href)"/>
  873.         
  874.         <xsl:call-template name="insertembed">
  875.             <xsl:with-param name="doc" select="$docum" />
  876.             <xsl:with-param name="anchor" select="$anc" />
  877.         </xsl:call-template>
  878.  
  879.     </div>
  880. </xsl:template>
  881.  
  882. <xsl:template name="resolveembedvar">
  883.     <xsl:if test="not(@href='text/shared/00/00000004.xhp#wie')"> <!-- special treatment if howtoget links -->
  884.         <xsl:variable name="archive"><xsl:value-of select="concat(substring-before(substring-after(@href,'text/'),'/'),'/')"/></xsl:variable>
  885.         <xsl:variable name="href"><xsl:value-of select="concat($urlpre,$archive,substring-before(@href,'#'),$urlpost)"/></xsl:variable>
  886.         <xsl:variable name="anchor"><xsl:value-of select="substring-after(@href,'#')"/></xsl:variable>
  887.         <xsl:variable name="doc" select="document($href)"/>
  888.         <xsl:choose>
  889.             <xsl:when test="$doc//variable[@id=$anchor]"> <!-- test for a variable of that name -->
  890.                 <xsl:apply-templates select="$doc//variable[@id=$anchor]" mode="embedded"/>
  891.             </xsl:when>
  892.             <xsl:otherwise> <!-- or give up -->
  893.                 <span class="bug">[<xsl:value-of select="@href"/> not found].</span> 
  894.             </xsl:otherwise>
  895.         </xsl:choose>
  896.     </xsl:if>
  897. </xsl:template>
  898.  
  899. <!-- Apply -->
  900. <xsl:template name="apply">
  901.     <xsl:param name="embedded" />
  902.     <xsl:choose>
  903.         <xsl:when test="$embedded = 'yes'">
  904.             <xsl:apply-templates mode="embedded"/>
  905.         </xsl:when>
  906.         <xsl:otherwise>
  907.             <xsl:apply-templates />
  908.         </xsl:otherwise>
  909.     </xsl:choose>
  910. </xsl:template>
  911.  
  912. </xsl:stylesheet>
  913.