home *** CD-ROM | disk | FTP | other *** search
/ Kompuutteri Kaikille K-CD 2002 #3 / K-CD_2002-03.iso / OpenOffice / f_0157 / main_transform.xsl < prev   
Extensible Markup Language  |  2001-09-10  |  27KB  |  802 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <!--
  4.    ++++++++++++++++++++++++++++++++++++++++++++++++++++++
  5.    This is the transformation style sheet for Help files.
  6.    (c) 2001 by Sun Microsystems, Inc. All Rights Reserved
  7.    ++++++++++++++++++++++++++++++++++++++++++++++++++++++
  8.    You should not edit this file unless you know what 
  9.    you're doing.
  10.  
  11.    Version: 30-AUG-01 FPE
  12.      27-Jul-01: Evaluation of $Program does not work.  Talk to ABI
  13.             about that. In the meantime, declare $Prog for the same
  14.             purposes (PRELIMINARY!!!)
  15.      09-Aug-01: Added evaluation of th in "How to get"-popups.
  16.         Changed evaluation of icon/name tables within that.
  17.      09-Aug-01: Added special formatting of "Related" header (styleclass "reltop")
  18.      09-Aug-01: Added variable for column width of first columns of tables with icons
  19.      14-Aug-01: Fixed Bug: Switches were not evaluated in document title h1
  20.      14-Aug-01: Fixed Bug: System switches were falsely evaluated. Changed the way of switch
  21.         evaluation, now using modes.
  22.      17-AUG-01: Fixed Bug: switch as direct child of embedded were not evaluated
  23.      22-Aug-01: Fixed: Axis PRECEDING no longer used (wasn't supported by processor)
  24.      22-Aug-01: Now empty Howtoget links are ignored
  25.      27-Aug-01: Now the image size is evaluated (from cm to pixels) and included in the img tags.
  26.      28-Aug-01: Embedded Paras now check for a <p> ancestor instead of a parent.
  27.      30-Aug-01: Added recursive evaluation of embedded text
  28.  
  29. //-->
  30.  
  31. <xsl:stylesheet version="1.0" 
  32.     xmlns:nu="http://www.jclark.com/xt/java/com.sun.xmlsearch.tree.NodeUtils"
  33.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  34.     xmlns:office="http://openoffice.org/2000/office"
  35.     xmlns:style="http://openoffice.org/2000/style"
  36.     xmlns:text="http://openoffice.org/2000/text"
  37.     xmlns:table="http://openoffice.org/2000/table"
  38.     xmlns:draw="http://openoffice.org/2000/drawing"
  39.     xmlns:fo="http://www.w3.org/1999/XSL/Format"
  40.     xmlns:xlink="http://www.w3.org/1999/xlink"
  41.     xmlns:dc="http://purl.org/dc/elements/1.1/"
  42.     xmlns:meta="http://openoffice.org/2000/meta"
  43.     xmlns:number="http://openoffice.org/2000/datastyle"
  44.     xmlns:svg="http://www.w3.org/2000/svg"
  45.     xmlns:chart="http://openoffice.org/2000/chart"
  46.     xmlns:help="http://openoffice.org/2000/help">
  47.  
  48.     <!-- Generate html code -->
  49.     <xsl:output method="html"/>
  50.  
  51.         <!-- These are the parameters for the help URL prefix -->
  52.         <xsl:param name="hp" select="''"/>
  53.         <xsl:param name="sm" select="'vnd.sun.star.help://'"/>
  54.         <xsl:param name="qm" select="'?'"/>
  55.         <xsl:param name="es" select="'='"/>
  56.         <xsl:param name="am" select="'&'"/>
  57.         <xsl:param name="cl" select="':'"/>
  58.         <xsl:param name="sl" select="'/'"/>
  59.         <xsl:param name="hm" select="'#'"/>
  60.  
  61.  
  62.         <!-- Possible values are OFFICE, swriter, scalc, sbasic, schart, sdraw, simpress, smath, portal -->
  63.         <xsl:param name="Database" select="'swriter'"/>
  64.  
  65.         <!-- 
  66.             Die Auswertung von $Program erfolgt scheinbar nicht richtig. R├╝cksprache mit ABI n├╢tig 
  67.         
  68.             <xsl:param name="Program" select="$Database"/>
  69.  
  70.             daher vorl├ñufig mit einer neuen Var arbeiten 
  71.         -->
  72.         
  73.         <xsl:variable name="Program">
  74.             <xsl:choose>
  75.                 <xsl:when test="$Database='swriter'">WRITER</xsl:when>
  76.                 <xsl:when test="$Database='scalc'">CALC</xsl:when>
  77.                 <xsl:when test="$Database='sdraw'">DRAW</xsl:when>
  78.                 <xsl:when test="$Database='simpress'">IMPRESS</xsl:when>
  79.                 <xsl:when test="$Database='sbasic'">BASIC</xsl:when>
  80.                 <xsl:when test="$Database='smath'">MATH</xsl:when>
  81.                 <xsl:when test="$Database='schart'">CHART</xsl:when>
  82.                 <xsl:when test="$Database='portal'">PORTAL</xsl:when>
  83.                 <xsl:otherwise>NONE</xsl:otherwise>
  84.             </xsl:choose>
  85.         </xsl:variable>        
  86.  
  87.         <!-- Fixed width of first column of tables containing icons in the first column -->
  88.         <xsl:variable name="colwidth_1">25</xsl:variable>
  89.  
  90.         <!-- Possible values for Language: see language codes The XML companion s.438 -->
  91.         <xsl:param name="Language" select="'de'"/>
  92.     
  93.         <!-- Possible values for System are WIN, OS2, MAC, and UNIX -->
  94.         <xsl:param name="System" select="'WIN'"/>
  95.  
  96.         <xsl:param name="Device" select="'WARP'"/>
  97.         
  98.         <xsl:param name="Id" select="'0000'"/>
  99.         <xsl:param name="Path" select="'Path'"/>
  100.  
  101.     <!-- Temporarily disabled by SUS
  102.     <xsl:param name="deviceType" select="'HTML4'"/>
  103.     -->
  104.  
  105.     <!-- Copy trough of elements with attributes -->
  106.     <xsl:template match="*|@*|comment()|processing-instruction()|text()">
  107.         <xsl:copy>
  108.             <xsl:apply-templates select="*|@*|comment()|processing-instruction()|text()"/>
  109.         </xsl:copy>
  110.     </xsl:template>
  111.  
  112.     <xsl:template match="help:*">
  113.         <xsl:element name="{name()}">
  114.             <xsl:apply-templates select="*|@*|comment()|processing-instruction()|text()"/>
  115.         </xsl:element>
  116.     </xsl:template>
  117.  
  118.     <!--Normal processing of elements starts here -->
  119.     
  120.     <xsl:template match="help:help-id|help:to-be-embedded">
  121.         <xsl:apply-templates/>
  122.     </xsl:template>
  123.     
  124.     <xsl:template match="help:to-popup">
  125.         <xsl:apply-templates/>
  126.     </xsl:template>
  127.  
  128.     <!-- Show visible active help AVIS, hide hidden active help AHID -->
  129.     <xsl:template match="help:help-text">
  130.         <xsl:if test="@value='visible'">
  131.             <xsl:apply-templates/>
  132.         </xsl:if>
  133.     </xsl:template>
  134.  
  135.     <!-- Evaluate switch statements -->
  136.     <xsl:template match="help:switch">
  137.         <xsl:choose>
  138.             <xsl:when test="@select='Program'">
  139.                 <xsl:apply-templates mode="switch_prog"/>
  140.             </xsl:when>
  141.             <xsl:when test="@select='System'">
  142.                 <xsl:apply-templates mode="switch_sys"/>
  143.             </xsl:when>
  144.         </xsl:choose>
  145.     </xsl:template>
  146.  
  147.     <xsl:template match="help:switch" mode="embedded">
  148.         <xsl:choose>
  149.             <xsl:when test="@select='Program'">
  150.                 <xsl:apply-templates mode="switch_prog"/>
  151.             </xsl:when>
  152.             <xsl:when test="@select='System'">
  153.                 <xsl:apply-templates mode="switch_sys"/>
  154.             </xsl:when>
  155.         </xsl:choose>
  156.     </xsl:template>
  157.  
  158.  
  159.  
  160.  
  161.     <xsl:template match="help:case" mode="switch_prog">
  162.         <xsl:if test="@select=$Program">
  163.             <xsl:apply-templates/>
  164.         </xsl:if>
  165.     </xsl:template>
  166.     
  167.     <xsl:template match="help:case" mode="switch_sys">
  168.         <xsl:if test="@select=$System">
  169.             <xsl:apply-templates/>
  170.         </xsl:if>
  171.     </xsl:template>
  172.  
  173.     <xsl:template match="help:default" mode="switch_prog">
  174.         <xsl:if test="not(../help:case[@select=$Program])">
  175.             <xsl:apply-templates/>
  176.         </xsl:if>
  177.     </xsl:template>
  178.     
  179.     <xsl:template match="help:default" mode="switch_sys">
  180.         <xsl:if test="not(../help:case[@select=$System])">
  181.             <xsl:apply-templates/>
  182.         </xsl:if>
  183.     </xsl:template>
  184.  
  185. <!-- //\\ -->
  186.  
  187.     <xsl:template match="help:switch" mode="doctitle">
  188.         <xsl:if test="@select='Program' or @select='System'">
  189.             <xsl:apply-templates mode="doctitle"/>
  190.         </xsl:if>
  191.     </xsl:template>
  192.  
  193.     <xsl:template match="help:case" mode="doctitle">
  194.         <xsl:if test="@select=$Program or @select=$System">
  195.             <xsl:apply-templates mode="doctitle"/>
  196.         </xsl:if>
  197.     </xsl:template>
  198.  
  199.     <xsl:template match="help:default" mode="doctitle">
  200.         <xsl:if test="../../help:switch[@select='System'] and not(../help:case[@select=$System])">
  201.             <xsl:apply-templates mode="doctitle"/>
  202.         </xsl:if>
  203.  
  204.         <xsl:if test="../../help:switch[@select='Program'] and not(../help:case[@select=$Program])">
  205.             <xsl:apply-templates mode="doctitle"/>
  206.         </xsl:if>
  207.     </xsl:template>
  208.  
  209.     
  210.     <xsl:template match="p" mode="embedded">
  211.         <xsl:choose>
  212.             <xsl:when test="@class='Head1'">
  213.             <xsl:element name="hr">
  214.                     <xsl:attribute name="width">50%</xsl:attribute>
  215.                     <xsl:attribute name="align">center</xsl:attribute>
  216.                     <xsl:attribute name="size">1</xsl:attribute>
  217.                 </xsl:element>
  218.                 <xsl:element name="p">
  219.                     <xsl:attribute name="class">Head2</xsl:attribute>
  220.                     <xsl:apply-templates/>
  221.                 </xsl:element>
  222.             </xsl:when>
  223.             <xsl:when test="@class='Head2'">
  224.                 <xsl:element name="p">
  225.                     <xsl:attribute name="class">Head2</xsl:attribute>
  226.                     <xsl:apply-templates/>
  227.                 </xsl:element>
  228.             </xsl:when>
  229.             <xsl:when test="@class='Head3'">
  230.                 <xsl:element name="p">
  231.                     <xsl:attribute name="class">Head3</xsl:attribute>
  232.                     <xsl:apply-templates/>
  233.                 </xsl:element>
  234.             </xsl:when>
  235.             <xsl:when test="@class='Paragraph' or @class='ParaList' or @class='TextInTable' or @class='TableHead' or @class='PropText'">
  236.                 <xsl:element name="p">
  237.                     <xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute>
  238.                     <xsl:apply-templates/>
  239.                 </xsl:element>
  240.             </xsl:when>
  241.             <xsl:otherwise>
  242.                 <xsl:element name="p">
  243.                     <xsl:attribute name="class">Paragraph</xsl:attribute>
  244.                     <xsl:apply-templates/>
  245.                 </xsl:element>
  246.             </xsl:otherwise>
  247.         </xsl:choose>
  248.     </xsl:template>
  249.  
  250.     <xsl:template match="p" mode="popup">
  251.         <xsl:if test="(. != '') or (count(child::*)>0)">
  252.             <xsl:element name="p">
  253.                 <xsl:attribute name="class">howtogetpara</xsl:attribute>
  254.                 <xsl:apply-templates/>
  255.             </xsl:element>
  256.         </xsl:if>
  257.     </xsl:template>
  258.  
  259.     <!-- Process Paragraphs and Headers -->
  260.   <xsl:template match="p">
  261.         <!-- Disregard empty paragraphs -->
  262.         <xsl:choose>
  263.             <xsl:when test=".='' and count(child::*)=0">
  264.             </xsl:when>
  265.             <xsl:otherwise>
  266.  
  267.                 <!-- Process all headings -->
  268.                 <xsl:choose>
  269.                      <xsl:when test="substring(@class,1,4)='Head'">
  270.  
  271.                         <xsl:choose>
  272.                         <xsl:when test="@class='Head1'">
  273.  
  274. <!-- 
  275.  
  276.                             <xsl:choose>
  277.                             <xsl:when test="preceding::p[@class='Head1']"> There may only be 1 H1 (at the top)
  278.                             <xsl:element name="hr">
  279.                                     <xsl:attribute name="width">50%</xsl:attribute>
  280.                                     <xsl:attribute name="align">center</xsl:attribute>
  281.                                     <xsl:attribute name="size">1</xsl:attribute>
  282.                                 </xsl:element>
  283.                                 <xsl:element name="p">
  284.                                     <xsl:attribute name="class">Head2</xsl:attribute>
  285.                                     <xsl:apply-templates/>
  286.                                 </xsl:element>
  287.                             </xsl:when>
  288.  
  289.                             <xsl:otherwise>
  290. //-->
  291.  
  292.                                 <!-- this is the document title at the top (hopefully...) -->
  293.                                 <xsl:element name="table">
  294.                                     <xsl:attribute name="width">100%</xsl:attribute>
  295.                                     <xsl:attribute name="border">0</xsl:attribute>
  296.                                     <xsl:attribute name="cellspacing">1</xsl:attribute>
  297.                                     <xsl:attribute name="cellpadding">3</xsl:attribute>
  298.                                     <xsl:attribute name="class">doctablebg</xsl:attribute>
  299.                                     <xsl:element name="tr">
  300.                                         <xsl:attribute name="class">doctitlebg</xsl:attribute>
  301.                                         <xsl:element name="td">
  302.                                             <xsl:attribute name="class">Head1</xsl:attribute>
  303.                                             <xsl:apply-templates mode="doctitle"/>
  304.                                         </xsl:element>
  305.                                     </xsl:element>
  306.                                 </xsl:element>
  307.                                 <xsl:element name="br"/>
  308. <!--
  309.                             </xsl:otherwise>
  310.                             </xsl:choose>
  311. //-->
  312.                         </xsl:when>
  313.             
  314.                         <xsl:when test="@class='Head2'">
  315.                         <xsl:element name="hr">
  316.                                 <xsl:attribute name="width">50%</xsl:attribute>
  317.                                 <xsl:attribute name="align">center</xsl:attribute>
  318.                                 <xsl:attribute name="size">1</xsl:attribute>
  319.                             </xsl:element>
  320.                             <xsl:element name="p">
  321.                                 <xsl:attribute name="class">Head2</xsl:attribute>
  322.                                 <xsl:apply-templates/>
  323.                             </xsl:element>
  324.                         </xsl:when>
  325.                         
  326.                         <xsl:otherwise>
  327.                             <xsl:element name="p">
  328.                                 <xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute>
  329.                                 <xsl:apply-templates/>
  330.                             </xsl:element>
  331.                         </xsl:otherwise>
  332.                         </xsl:choose>            
  333.  
  334.                     </xsl:when>
  335.                     <!-- 
  336.                         Process all paragraphs and adjust automatic style information 
  337.                         Valid style classes are Paragraph, ParaList, TextInTable, TableHead, PropText
  338.                     -->
  339.                     <xsl:when test="@class='Paragraph' or @class='ParaList' or @class='TextInTable' or @class='TableHead' or @class='PropText'">
  340.                         <xsl:element name="p">
  341.                     
  342.                             <xsl:choose>
  343.                                 <!-- By special request, turn the "Related Topics" header into an own style class -->
  344.                                 <xsl:when test="child::help:embedded[@Eid='related']">
  345.                                     <xsl:attribute name="class">reltop</xsl:attribute>
  346.                                 </xsl:when>
  347.                                 <xsl:otherwise>
  348.                                     <xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute>
  349.                                 </xsl:otherwise>
  350.                             </xsl:choose>
  351.                             
  352.                                 <xsl:apply-templates/>
  353.                             </xsl:element>
  354.                     </xsl:when>
  355.                     <xsl:otherwise>
  356.                         <xsl:element name="p">
  357.                             <xsl:attribute name="class">Paragraph</xsl:attribute>
  358.                             <xsl:apply-templates/>
  359.                         </xsl:element>
  360.                     </xsl:otherwise>
  361.                 </xsl:choose>
  362.             
  363.             </xsl:otherwise>        
  364.         </xsl:choose>
  365.   </xsl:template>
  366.  
  367.     <!-- process all kinds of lists -->
  368.     <xsl:template match="ol">
  369.         <xsl:element name="ol">
  370.             <xsl:apply-templates/>
  371.         </xsl:element>
  372.     </xsl:template>
  373.  
  374.     <xsl:template match="ul">
  375.         <xsl:element name="ul">
  376.             <xsl:apply-templates/>
  377.         </xsl:element>
  378.     </xsl:template>
  379.  
  380.     <xsl:template match="li">
  381.         <xsl:element name="li">
  382.             <xsl:apply-templates/>
  383.         </xsl:element>
  384.     </xsl:template>
  385.     
  386.     <xsl:template match="ol" mode="Embedded">
  387.         <xsl:element name="ol">
  388.             <xsl:apply-templates/>
  389.         </xsl:element>
  390.     </xsl:template>
  391.  
  392.     <xsl:template match="ul" mode="Embedded">
  393.         <xsl:element name="ul">
  394.             <xsl:apply-templates/>
  395.         </xsl:element>
  396.     </xsl:template>
  397.  
  398.     <!-- Process character formatting -->
  399.     <xsl:template match="span">
  400.         <!-- Disregard spans with table automatic formats, starting with "Tabelle" -->
  401.         <xsl:choose>
  402.             <xsl:when test="substring(@class,1,7)='Tabelle'">
  403.                 <xsl:apply-templates/>
  404.             </xsl:when>
  405.             <xsl:otherwise>
  406.                 <!-- insert emphasized span -->
  407.                 <xsl:element name="span">
  408.                     <xsl:attribute name="class">emph</xsl:attribute>
  409.                     <xsl:apply-templates/>
  410.                 </xsl:element>
  411.             </xsl:otherwise>
  412.         </xsl:choose>
  413.     </xsl:template>
  414.  
  415.     <xsl:template match="span" mode="embedded">
  416.         <!-- Disregard spans with table automatic formats, starting with "Tabelle" -->
  417.         <xsl:choose>
  418.             <xsl:when test="substring(@class,1,7)='Tabelle'">
  419.                 <xsl:apply-templates/>
  420.             </xsl:when>
  421.             <xsl:otherwise>
  422.                 <!-- insert emphasized span -->
  423.                 <xsl:element name="span">
  424.                     <xsl:attribute name="class">emph</xsl:attribute>
  425.                     <xsl:apply-templates/>
  426.                 </xsl:element>
  427.             </xsl:otherwise>
  428.         </xsl:choose>
  429.     </xsl:template>
  430.  
  431.     <xsl:template match="span" mode="popup">
  432.         <!-- Disregard spans with table automatic formats, starting with "Tabelle" -->
  433.         <xsl:choose>
  434.             <xsl:when test="substring(@class,1,7)='Tabelle'">
  435.                 <xsl:apply-templates/>
  436.             </xsl:when>
  437.             <xsl:otherwise>
  438.                 <!-- insert emphasized span -->
  439.                 <xsl:element name="span">
  440.                     <xsl:attribute name="class">emph</xsl:attribute>
  441.                     <xsl:apply-templates/>
  442.                 </xsl:element>
  443.             </xsl:otherwise>
  444.         </xsl:choose>
  445.     </xsl:template>
  446.  
  447.     <!-- Tables should be preceded and followed by a line break -->
  448.   <xsl:template match="table">
  449.       <xsl:element name="br"/>
  450.     <xsl:element name="table"> 
  451.             <xsl:if test="@border>0">
  452.                 <xsl:attribute name="border">1</xsl:attribute>
  453.                 <xsl:attribute name="class">tablebg</xsl:attribute>
  454.             </xsl:if>
  455.             <xsl:attribute name="cellspacing">0</xsl:attribute>
  456.             <xsl:attribute name="cellpadding">2</xsl:attribute>
  457.       <xsl:apply-templates />
  458.     </xsl:element>
  459.     <xsl:element name="br"/>
  460.   </xsl:template>
  461.     
  462.   <xsl:template match="table" mode="embedded">
  463.       <xsl:element name="br"/>
  464.     <xsl:element name="table"> 
  465.             <xsl:if test="@border>0">
  466.                 <xsl:attribute name="border">1</xsl:attribute>
  467.                 <xsl:attribute name="class">tablebg</xsl:attribute>
  468.             </xsl:if>
  469.             <xsl:attribute name="cellspacing">0</xsl:attribute>
  470.             <xsl:attribute name="cellpadding">2</xsl:attribute>
  471.       <xsl:apply-templates />
  472.     </xsl:element>
  473.     <xsl:element name="br"/>
  474.   </xsl:template>
  475.  
  476.   <xsl:template match="table" mode="popup">
  477.  
  478.     <xsl:element name="table"> 
  479.             <xsl:attribute name="border">0</xsl:attribute>
  480.             <xsl:attribute name="cellspacing">0</xsl:attribute>
  481.             <xsl:attribute name="cellpadding">2</xsl:attribute>
  482.       <xsl:apply-templates mode="popup"/>
  483.     </xsl:element>
  484.  
  485. <!--        <xsl:for-each select="child::tr">
  486.             <xsl:element name="p">
  487.                 <xsl:attribute name="class">howtogetpara</xsl:attribute>
  488.                     <xsl:if test="(child::td) or (child::th)">
  489.                         <xsl:apply-templates mode="popup"/>
  490.                     </xsl:if>
  491.                 </xsl:element>
  492.         </xsl:for-each>
  493. //-->
  494.   </xsl:template>
  495.     
  496.     <xsl:template match="tr">
  497.         <xsl:element name="tr">
  498.             <xsl:apply-templates/>
  499.         </xsl:element>
  500.     </xsl:template>
  501.  
  502.     <xsl:template match="tr" mode="popup">
  503.         <xsl:element name="tr">
  504.             <xsl:apply-templates mode="popup"/>
  505.         </xsl:element>
  506.     </xsl:template>
  507.  
  508.     <xsl:template match="th">
  509.         <!-- no th for borderless tables - 24/07/01-->
  510.         <xsl:choose>
  511.             <xsl:when test="../../table[@border>0]">
  512.                 <xsl:element name="th">
  513.                     <xsl:attribute name="align">left</xsl:attribute>
  514.                     <xsl:attribute name="valign">top</xsl:attribute>
  515.                     <xsl:attribute name="class">tableheadbg</xsl:attribute>
  516.                     <xsl:apply-templates/>
  517.                 </xsl:element>
  518.             </xsl:when>
  519.             <xsl:otherwise>
  520.                 <xsl:element name="td">
  521.                     <xsl:attribute name="align">left</xsl:attribute>
  522.                     <xsl:attribute name="valign">top</xsl:attribute>
  523.                     <xsl:attribute name="class">tabledatabg</xsl:attribute>
  524.                     <xsl:apply-templates/>
  525.                 </xsl:element>
  526.             </xsl:otherwise>
  527.         </xsl:choose>
  528.     </xsl:template>
  529.  
  530.     <xsl:template match="td" mode="popup">
  531.         <xsl:element name="td">
  532.             <xsl:if test="descendant::draw:image">
  533.                 <xsl:attribute name="width"><xsl:value-of select="$colwidth_1"/></xsl:attribute>
  534.             </xsl:if>
  535.             <xsl:apply-templates mode="popup"/>
  536.         </xsl:element>
  537.     </xsl:template>
  538.  
  539.     <xsl:template match="th" mode="popup">
  540.         <xsl:element name="td">
  541.             <xsl:if test="descendant::draw:image">
  542.                 <xsl:attribute name="width"><xsl:value-of select="$colwidth_1"/></xsl:attribute>
  543.             </xsl:if>
  544.             <xsl:apply-templates mode="popup"/>
  545.         </xsl:element>
  546.     </xsl:template>
  547.  
  548.       <xsl:template match="td">
  549.         <xsl:element name="td">
  550.             <xsl:attribute name="align">left</xsl:attribute>
  551.             <xsl:attribute name="valign">top</xsl:attribute>
  552.             <xsl:attribute name="class">tabledatabg</xsl:attribute>
  553.             <xsl:apply-templates/>
  554.         </xsl:element>
  555.     </xsl:template>
  556.  
  557.  
  558.     <!-- Process embedded help text -->
  559.     <xsl:template match="help:embedded">
  560.         <xsl:variable name="Link" select="concat($sm,$Database,'/',@Id,'?Language=',$Language,'&System=',$System)"/>
  561.         <xsl:variable name="EmbeddedDoc" select="document($Link)"/>
  562.         <xsl:variable name="Docpart" select="@Eid"/>
  563.  
  564.         <xsl:choose>
  565.             <!-- prevent embedded paragraphs without p tag -->
  566.             <xsl:when test="not(ancestor::p)">
  567.                 <xsl:element name="p">
  568.                     <xsl:attribute name="class">Paragraph</xsl:attribute>
  569.                     <xsl:apply-templates select="$EmbeddedDoc//help:to-be-embedded[@Eid=$Docpart]" mode="embedded"/>
  570.                 </xsl:element>
  571.             </xsl:when>
  572.  
  573.             <xsl:otherwise>
  574.                 <xsl:apply-templates select="$EmbeddedDoc//help:to-be-embedded[@Eid=$Docpart]" mode="embedded"/>
  575.             </xsl:otherwise>
  576.         </xsl:choose>
  577.  
  578.     </xsl:template>
  579.     
  580.     
  581.         <!-- Process embedded help text -->
  582.     <xsl:template match="help:embedded" mode="embedded">
  583.         <xsl:variable name="Link" select="concat($sm,$Database,'/',@Id,'?Language=',$Language,'&System=',$System)"/>
  584.         <xsl:variable name="EmbeddedDoc" select="document($Link)"/>
  585.         <xsl:variable name="Docpart" select="@Eid"/>
  586.  
  587.         <xsl:choose>
  588.             <!-- prevent embedded paragraphs without p tag -->
  589.             <xsl:when test="not(ancestor::p)">
  590.                 <xsl:element name="p">
  591.                     <xsl:attribute name="class">Paragraph</xsl:attribute>
  592.                     <xsl:apply-templates select="$EmbeddedDoc//help:to-be-embedded[@Eid=$Docpart]" mode="embedded"/>
  593.                 </xsl:element>
  594.             </xsl:when>
  595.  
  596.             <xsl:otherwise>
  597.                 <xsl:apply-templates select="$EmbeddedDoc//help:to-be-embedded[@Eid=$Docpart]" mode="embedded"/>
  598.             </xsl:otherwise>
  599.         </xsl:choose>
  600.  
  601.     </xsl:template>
  602.  
  603.  
  604.     <!-- Process Popup help text -->
  605.     <xsl:template match="help:popup-cut">
  606.         <xsl:variable name="ref" select="concat($sm,$Database,'/',@Id,'?Language=',$Language,'&System=',$System)"/>
  607.         <xsl:variable name="popupdoc" select="document($ref)"/>
  608.         <xsl:variable name="part" select="@Eid"/>
  609.         <xsl:apply-templates select="$popupdoc//help:to-popup[@Eid=$part]"/>
  610.             <xsl:element name="hr">
  611.                     <xsl:attribute name="width">50%</xsl:attribute>
  612.                     <xsl:attribute name="align">center</xsl:attribute>
  613.                     <xsl:attribute name="size">1</xsl:attribute>
  614.                 </xsl:element>
  615.     </xsl:template>
  616.  
  617.     <!-- Process anchor names (help index keywords) -->
  618.     <xsl:template match="help:key-word">
  619.         <xsl:element name="a">
  620.             <xsl:attribute name="name">
  621.                 <xsl:value-of select="@tag"/>
  622.             </xsl:attribute>
  623.         </xsl:element>
  624.     </xsl:template>
  625.  
  626.     <xsl:template match="help:key-word" mode="doctitle">
  627.         <xsl:element name="a">
  628.             <xsl:attribute name="name">
  629.                 <xsl:value-of select="@tag"/>
  630.             </xsl:attribute>
  631.         </xsl:element>
  632.     </xsl:template>
  633.  
  634.     <!-- Process anchor names (help ids) -->
  635.     <xsl:template match="help:help-id">
  636.         <xsl:element name="a">
  637.             <xsl:attribute name="name">
  638.                 <xsl:value-of select="@value"/>
  639.             </xsl:attribute>
  640.         </xsl:element>
  641.     </xsl:template>
  642.  
  643.     <xsl:template match="help:help-id" mode="doctitle">
  644.         <xsl:element name="a">
  645.             <xsl:attribute name="name">
  646.                 <xsl:value-of select="@value"/>
  647.             </xsl:attribute>
  648.         </xsl:element>
  649.     </xsl:template>
  650.  
  651.  
  652.     <!-- Process help links -->
  653.     <xsl:template match="help:link">
  654.         <xsl:choose>
  655.             <xsl:when test="@Eid">
  656.                 <xsl:variable name="Link" select="concat($hp,$sm,$Database,$sl,@Id,$qm,'Language',$es,$Language,$am,'System',$es,$System,'#',@Eid)"/>
  657.                 <xsl:element name="a">
  658.                     <xsl:attribute name="class">ContentLink</xsl:attribute>
  659.                     <xsl:attribute name="href"><xsl:value-of select="$Link"/></xsl:attribute>
  660.                     <xsl:apply-templates/>
  661.                 </xsl:element>                
  662.             </xsl:when>
  663.             <xsl:otherwise>
  664.                 <xsl:variable name="Link" select="concat($hp,$sm,$Database,$sl,@Id,$qm,'Language',$es,$Language,$am,'System',$es,$System)"/>
  665.                 <xsl:element name="a">
  666.                     <xsl:attribute name="class">ContentLink</xsl:attribute>
  667.                     <xsl:attribute name="href"><xsl:value-of select="$Link"/></xsl:attribute>
  668.                     <xsl:apply-templates/>
  669.                 </xsl:element>                
  670.             </xsl:otherwise>
  671.         </xsl:choose>
  672.     </xsl:template>
  673.  
  674.     <xsl:template match="help:link" mode="embedded">
  675.         <xsl:choose>
  676.             <xsl:when test="@Eid">
  677.                 <xsl:variable name="Link" select="concat($hp,$sm,$Database,$sl,@Id,$qm,'Language',$es,$Language,$am,'System',$es,$System,'#',@Eid)"/>
  678.                 <xsl:element name="a">
  679.                     <xsl:attribute name="class">ContentLink</xsl:attribute>
  680.                     <xsl:attribute name="href"><xsl:value-of select="$Link"/></xsl:attribute>
  681.                     <xsl:apply-templates/>
  682.                 </xsl:element>                
  683.             </xsl:when>
  684.             <xsl:otherwise>
  685.                 <xsl:variable name="Link" select="concat($hp,$sm,$Database,$sl,@Id,$qm,'Language',$es,$Language,$am,'System',$es,$System)"/>
  686.                 <xsl:element name="a">
  687.                     <xsl:attribute name="class">ContentLink</xsl:attribute>
  688.                     <xsl:attribute name="href"><xsl:value-of select="$Link"/></xsl:attribute>
  689.                     <xsl:apply-templates/>
  690.                 </xsl:element>                
  691.             </xsl:otherwise>
  692.         </xsl:choose>
  693.     </xsl:template>
  694.  
  695.     <xsl:template match="help:link" mode="doctitle">
  696.         <xsl:apply-templates/>
  697.     </xsl:template>
  698.  
  699.     <!-- Process help popups -->
  700.     <!-- Workaround for "How to get this function" popup is to load it in a small table into the document -->
  701.     <xsl:template match="help:popup">
  702.         <xsl:choose>
  703.  
  704.             <xsl:when test="child::help:embedded[@Eid='wie']">
  705.                 <xsl:variable name="Link" select="concat($sm,$Database,'/',@Id,'?Language=',$Language,'&System=',$System)"/>
  706.                 <xsl:variable name="EmbeddedDoc" select="document($Link)"/>
  707.                 <xsl:variable name="Docpart" select="@Eid"/>
  708.                 
  709.                 <xsl:if test="$EmbeddedDoc//help:to-popup[@Eid=$Docpart]!=''">
  710.               
  711.                 <xsl:element name="table">
  712.                     <xsl:attribute name="width">100%</xsl:attribute>
  713.                     <xsl:attribute name="border">1</xsl:attribute>
  714.                     <xsl:attribute name="cellspacing">0</xsl:attribute>
  715.                     <xsl:attribute name="cellpadding">4</xsl:attribute>
  716.                     <xsl:element name="tr">
  717.                         <xsl:element name="td">
  718.                             <xsl:attribute name="class">howtogetheader</xsl:attribute>
  719.                                 <xsl:apply-templates/>
  720.                         </xsl:element>
  721.                     </xsl:element>
  722.                     <xsl:element name="tr">
  723.                         <xsl:element name="td">
  724.                             <xsl:attribute name="class">howtogetbody</xsl:attribute>
  725.                                 <xsl:apply-templates select="$EmbeddedDoc//help:to-popup[@Eid=$Docpart]" mode="popup"/>
  726.                         </xsl:element>
  727.                     </xsl:element>
  728.                 </xsl:element>
  729.                 </xsl:if>
  730.                 
  731.                 <xsl:element name="br"/>
  732.             </xsl:when>
  733.  
  734.             <xsl:otherwise>
  735.                 <xsl:variable name="Link" select="concat($hp,$sm,$Database,$sl,@Id,$qm,'Language',$es,$Language,$am,'System',$es,$System,$am,'Eid',$es,@Eid)"/>
  736.                     <xsl:element name="a">
  737.                     <xsl:attribute name="class">ContentLink</xsl:attribute>
  738.                     <xsl:attribute name="href"><xsl:value-of select="$Link"/></xsl:attribute>
  739.                     <xsl:apply-templates/>
  740.                 </xsl:element>
  741.             </xsl:otherwise>
  742.  
  743.         </xsl:choose>
  744.  
  745.     </xsl:template>
  746.  
  747.     <!-- Process images -->
  748.     <xsl:template match="draw:image | office:image">
  749.         <xsl:element name="img">
  750.                 <xsl:variable name="pictureLink" select="concat($hp,$sm,'picture',$sl,@xlink:href,$qm,'Language',$es,$Language,$am,'System',$es,$System)"/>
  751.                 <xsl:attribute name="src"><xsl:value-of select="$pictureLink"/></xsl:attribute>
  752.                 <xsl:attribute name="width"><xsl:value-of select="round(substring-before(@svg:width,'cm')*37.8)"/></xsl:attribute>
  753.                 <xsl:attribute name="height"><xsl:value-of select="round(substring-before(@svg:height,'cm')*37.8)"/></xsl:attribute>
  754.         </xsl:element>
  755.     </xsl:template>
  756.  
  757.     <!-- temporarily disabled 
  758.     <xsl:template match="img">
  759.         <xsl:if test="$deviceType = 'CSS' or $deviceType = 'HTML4'">
  760.       <xsl:variable name="pictureLink" select="concat($hp,$sm,'picture',$sl,@src,$qm,'Language',$es,$Language,$am,'System',$es,$System)"/>
  761.       <img src="{$pictureLink}"/>
  762.         </xsl:if>
  763.   </xsl:template>
  764.     -->
  765.  
  766.     <!-- Remove residues of formatting information -->
  767.     <xsl:template match="style">
  768.     </xsl:template>
  769.     
  770.     <!-- Add CSS link to custom.css -->
  771.     <xsl:template match="help:css-file-link">
  772.  
  773.         <xsl:variable name="CssStylesheet" select="concat($hp,$sm,$sl,$qm,'Language',$es,$Language,$am,'System',$es,$System)"/>
  774.         <xsl:element name="link">
  775.             <xsl:attribute name="rel">STYLESHEET</xsl:attribute>
  776.             <xsl:attribute name="href"><xsl:value-of select="$CssStylesheet"/></xsl:attribute>
  777.             <xsl:attribute name="type">text/css</xsl:attribute>
  778.         </xsl:element>
  779.  
  780.   <!-- Add Encoding meta tag for correct display of asian text -->
  781.         <xsl:element name="meta">
  782.             <xsl:attribute name="http-equiv">Content-type</xsl:attribute>
  783.             <xsl:attribute name="content">text/html; charset=utf-8</xsl:attribute>
  784.         </xsl:element>
  785.  
  786.     </xsl:template>
  787.  
  788.     <!-- error handling -->
  789.  
  790.     <xsl:template match="help:error-id">
  791.         <xsl:value-of select="$Id"/>    
  792.     </xsl:template>
  793.  
  794.     <xsl:template match="help:error-module">
  795.         <xsl:value-of select="$Database"/>    
  796.     </xsl:template>
  797.  
  798.     <xsl:template match="help:error-path">
  799.         <xsl:value-of select="$Path"/>
  800.     </xsl:template>
  801.  
  802. </xsl:stylesheet>