home *** CD-ROM | disk | FTP | other *** search
/ Freelog 52 / Freelog052.iso / Dossier / OpenOffice / f_0371 / sofftodocbookheadings.xsl
Extensible Markup Language  |  2003-07-22  |  29KB  |  855 lines

  1. <?xml version='1.0' encoding="UTF-8"?>
  2. <!-- #  The Contents of this file are made available subject to the terms of
  3.  #  either of the following licenses
  4.  #
  5.  #         - GNU Lesser General Public License Version 2.1
  6.  #         - Sun Industry Standards Source License Version 1.1
  7.  #
  8.  #  Sun Microsystems Inc., October, 2000
  9.  #
  10.  #  GNU Lesser General Public License Version 2.1
  11.  #  =============================================
  12.  #  Copyright 2000 by Sun Microsystems, Inc.
  13.  #  901 San Antonio Road, Palo Alto, CA 94303, USA
  14.  #
  15.  #  This library is free software; you can redistribute it and/or
  16.  #  modify it under the terms of the GNU Lesser General Public
  17.  #  License version 2.1, as published by the Free Software Foundation.
  18.  #
  19.  #  This library is distributed in the hope that it will be useful,
  20.  #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.  #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  22.  #  Lesser General Public License for more details.
  23.  #
  24.  #  You should have received a copy of the GNU Lesser General Public
  25.  #  License along with this library; if not, write to the Free Software
  26.  #  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  27.  #  MA  02111-1307  USA
  28.  #
  29.  #
  30.  #  Sun Industry Standards Source License Version 1.1
  31.  #  =================================================
  32.  #  The contents of this file are subject to the Sun Industry Standards
  33.  #  Source License Version 1.1 (the "License"); You may not use this file
  34.  #  except in compliance with the License. You may obtain a copy of the
  35.  #  License at http://www.openoffice.org/license.html.
  36.  #
  37.  #  Software provided under this License is provided on an "AS IS" basis,
  38.  #  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  39.  #  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
  40.  #  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
  41.  #  See the License for the specific provisions governing your rights and
  42.  #  obligations concerning the Software.
  43.  #
  44.  #  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
  45.  #
  46.  #  Copyright: 2000 by Sun Microsystems, Inc.
  47.  #
  48.  #  All Rights Reserved.
  49.  #
  50.  #  Contributor(s): _______________________________________
  51.  #
  52.  #-->
  53. <xsl:stylesheet version="1.0" xmlns:style="http://openoffice.org/2000/style" xmlns:text="http://openoffice.org/2000/text" xmlns:office="http://openoffice.org/2000/office" xmlns:table="http://openoffice.org/2000/table" xmlns:draw="http://openoffice.org/2000/drawing" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="http://openoffice.org/2000/meta" xmlns:number="http://openoffice.org/2000/datastyle" xmlns:svg="http://www.w3.org/2000/svg" xmlns:chart="http://openoffice.org/2000/chart" xmlns:dr3d="http://openoffice.org/2000/dr3d" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="http://openoffice.org/2000/form" xmlns:script="http://openoffice.org/2000/script" xmlns:config="http://openoffice.org/2001/config" office:class="text" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="office meta  table number dc fo xlink chart math script xsl draw svg dr3d form config text style">
  54. <xsl:output method="xml" indent="yes" omit-xml-declaration="no"  />
  55. <xsl:output method="xml" version="1.0" encoding="UTF-8" doctype-public="-//OASIS//DTD DocBook XML V4.1.2//EN" doctype-system="http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" />
  56.  
  57.  
  58.  
  59. <xsl:key name='headchildren' match="text:p |table:table | text:span | text:ordered-list | office:annotation | text:unordered-list | text:footnote | text:a | text:list-item | draw:plugin | draw:text-box | text:footnote-body | text:section"
  60.    use="generate-id((..|preceding-sibling::text:h[@text:level='1']|preceding-sibling::text:h[@text:level='2']|preceding-sibling::text:h[@text:level='3']|preceding-sibling::text:h[@text:level='4']|preceding-sibling::text:h[@text:level='5'])[last()])"/>
  61.  
  62. <xsl:key name="children" match="text:h[@text:level > '1' and @text:level < '6']"
  63.   use="generate-id(preceding-sibling::text:h[@text:level < current()/@text:level][1])"/>
  64.  
  65.  
  66. <xsl:template match="text:h[@text:level='1']">
  67. <xsl:choose>
  68.     <xsl:when test=".='Abstract'">
  69.         <abstract>
  70.             <xsl:apply-templates select="key('headchildren', generate-id())"/>
  71.                  <xsl:apply-templates select="key('children', generate-id())"/>
  72.         </abstract>
  73.     </xsl:when>
  74.     <xsl:otherwise>
  75.         <xsl:call-template name="make-section">
  76.             <xsl:with-param name="current" select="@text:level"/>
  77.                 <xsl:with-param name="prev" select="1"/>
  78.         </xsl:call-template>
  79.         <!--<sect1>
  80.                  <title>
  81.                        <xsl:apply-templates/>
  82.                  </title>
  83.                      <xsl:apply-templates select="key('headchildren', generate-id())"/>
  84.                  <xsl:apply-templates select="key('children', generate-id())"/>
  85.            </sect1>-->
  86.     </xsl:otherwise>
  87. </xsl:choose>
  88.    
  89. </xsl:template>
  90.  
  91. <xsl:template match="text:h[@text:level='2'] | text:h[@text:level='3']| text:h[@text:level='4'] | text:h[@text:level='5']">
  92. <xsl:variable name="level" select="@text:level"></xsl:variable>
  93. <xsl:call-template name="make-section">
  94.     <xsl:with-param name="current" select="$level"/>
  95.     <xsl:with-param name="prev" select="preceding-sibling::text:h[@text:level < $level][1]/@text:level "/>
  96. </xsl:call-template>
  97.  
  98. </xsl:template>
  99.  
  100. <xsl:template name="make-section">
  101.     <xsl:param name="current"/>
  102.     <xsl:param name="prev"/>
  103.     <xsl:choose>
  104.         <xsl:when test="$current > $prev+1">
  105.             <xsl:text disable-output-escaping="yes"><sect</xsl:text><xsl:value-of select="$prev +1"/><xsl:text disable-output-escaping="yes">></xsl:text>
  106.             <title>
  107.                 </title>
  108.             <xsl:call-template name="make-section">
  109.                 <xsl:with-param name="current" select="$current"/>
  110.                 <xsl:with-param name="prev" select="$prev +1"/>
  111.             </xsl:call-template>
  112.         <xsl:text disable-output-escaping="yes"></sect</xsl:text><xsl:value-of select="$prev +1 "/><xsl:text disable-output-escaping="yes">></xsl:text>
  113.         </xsl:when>
  114.         
  115.         <xsl:otherwise>
  116.             <xsl:text disable-output-escaping="yes"><sect</xsl:text><xsl:value-of select="$current"/><xsl:text disable-output-escaping="yes">></xsl:text>
  117.                     <title>
  118.                                <xsl:apply-templates/>
  119.                         </title>
  120.                  <xsl:apply-templates select="key('headchildren', generate-id())"/>
  121.                     <xsl:apply-templates select="key('children', generate-id())"/>
  122.             <xsl:text disable-output-escaping="yes"></sect</xsl:text><xsl:value-of select="$current"/><xsl:text disable-output-escaping="yes">></xsl:text>
  123.         </xsl:otherwise>
  124.     </xsl:choose>
  125. </xsl:template>
  126.  
  127.  
  128. <xsl:template match="text:p">
  129.         <xsl:element name="para">
  130.               <xsl:apply-templates/>
  131.         </xsl:element>
  132. </xsl:template>
  133.  
  134.  
  135.  
  136. <xsl:template match="/office:document">
  137.     <xsl:element name="article">
  138.         <xsl:attribute name="lang"><xsl:value-of select="/office:document/office:meta/dc:language"/>
  139.         </xsl:attribute>
  140.         <xsl:apply-templates />
  141.     </xsl:element>
  142. </xsl:template>
  143.  
  144. <xsl:template match="office:meta">
  145.     <!--<xsl:apply-templates/>-->
  146. </xsl:template>
  147.  
  148. <xsl:template match="text:ordered-list">
  149.     <xsl:element name="orderedlist">
  150.         <xsl:apply-templates/>
  151.     </xsl:element>
  152. </xsl:template>
  153.  
  154.  
  155.  
  156. <xsl:template match="meta:editing-cycles">
  157. </xsl:template>
  158.  
  159. <xsl:template match="meta:user-defined">
  160. </xsl:template>
  161.  
  162. <xsl:template match="meta:editing-duration">
  163. </xsl:template>
  164.  
  165. <xsl:template match="dc:language">
  166. </xsl:template>
  167.  
  168. <xsl:template match="dc:date">
  169.     <!--<pubdate>
  170.         <xsl:value-of select="substring-before(.,'T')"/>
  171.     </pubdate>-->
  172. </xsl:template>
  173.  
  174. <xsl:template match="meta:creation-date">
  175. </xsl:template>
  176.  
  177. <xsl:template match="office:body">
  178. <xsl:apply-templates select="key('headchildren', generate-id())"/>
  179.    <xsl:apply-templates select="text:h[@text:level='1']"/>
  180.     <!--<xsl:apply-templates/>-->
  181. </xsl:template>
  182.  
  183. <xsl:template match="office:styles">
  184.     <xsl:apply-templates/>
  185. </xsl:template>
  186.  
  187. <xsl:template match="office:script">
  188. </xsl:template>
  189.  
  190.  
  191. <xsl:template match="office:settings">
  192. </xsl:template>
  193.  
  194. <xsl:template match="office:font-decls">
  195. </xsl:template>
  196.  
  197. <xsl:template match="text:section">
  198. <xsl:choose>
  199.     <xsl:when test="@text:name='ArticleInfo'">
  200.         <articleinfo>
  201.             <title><xsl:value-of select="text:p[@text:style-name='Document Title']"/></title>
  202.             <subtitle><xsl:value-of select="text:p[@text:style-name='Document SubTitle']"/></subtitle>
  203.             <edition><xsl:value-of select="text:p/text:variable-set[@text:name='articleinfo.edition']"/></edition>
  204.             <xsl:for-each select="text:p/text:variable-set[substring-after(@text:name,'articleinfo.releaseinfo')]">
  205.                 <releaseinfo>
  206.                     <xsl:value-of select="."/>
  207.                 </releaseinfo>
  208.             </xsl:for-each>
  209.             <xsl:call-template name="ArticleInfo"><xsl:with-param name="level" select="0"/></xsl:call-template>
  210.     
  211.         </articleinfo>
  212.     </xsl:when>
  213.     <xsl:when test="@text:name='Abstract'">
  214.         <abstract>
  215.             <xsl:apply-templates/>
  216.         </abstract>
  217.     </xsl:when>
  218.     <xsl:when test="@text:name='Appendix'">
  219.         <appendix>
  220.             <xsl:apply-templates/>
  221.         </appendix>
  222.     </xsl:when>
  223.     <xsl:otherwise>
  224.         <xsl:variable name="sectvar"><xsl:text>sect</xsl:text><xsl:value-of select="count(ancestor::text:section)+1"/></xsl:variable>    
  225.         <xsl:variable name="idvar"><xsl:text> id="</xsl:text><xsl:value-of select="@text:name"/><xsl:text>"</xsl:text></xsl:variable>
  226.         <xsl:text disable-output-escaping="yes"><</xsl:text><xsl:value-of select="$sectvar"/><xsl:value-of select="$idvar"/><xsl:text  disable-output-escaping="yes">></xsl:text>
  227.             <xsl:apply-templates/>
  228.         <xsl:text disable-output-escaping="yes"></</xsl:text><xsl:value-of select="$sectvar"/><xsl:text  disable-output-escaping="yes">></xsl:text>
  229.     </xsl:otherwise>
  230.  
  231.  
  232. </xsl:choose>
  233. </xsl:template>
  234.  
  235. <xsl:template name="ArticleInfo">
  236.     <xsl:param name="level"/>
  237.     <xsl:variable name="author"><xsl:value-of select="concat('articleinfo.author_','', $level)"/></xsl:variable>
  238.     <xsl:if test="text:p/text:variable-set[contains(@text:name, $author )]">
  239.         <xsl:call-template name="Author"><xsl:with-param name="AuthorLevel" select="0"/></xsl:call-template>
  240.         <xsl:call-template name="Copyright"><xsl:with-param name="CopyrightLevel" select="0"/></xsl:call-template>    
  241.     </xsl:if>    
  242. </xsl:template>
  243.  
  244. <xsl:template name="Copyright">
  245.     <xsl:param name="CopyrightLevel"/>
  246.     
  247.     <xsl:variable name="Copyright"><xsl:value-of select="concat('articleinfo.copyright_','', $CopyrightLevel)"/></xsl:variable>
  248.     
  249.     <xsl:if test="text:p/text:variable-set[contains(@text:name,$Copyright)]">
  250.         <copyright>
  251.             <xsl:call-template name="Year">
  252.                 <xsl:with-param name="CopyrightLevel" select="$CopyrightLevel"/>
  253.                 <xsl:with-param name="YearlLevel" select="0"/>
  254.             </xsl:call-template>
  255.             <xsl:call-template name="Holder">
  256.                 <xsl:with-param name="CopyrightLevel" select="$CopyrightLevel"/>
  257.                 <xsl:with-param name="HolderlLevel" select="0"/>
  258.  
  259.             </xsl:call-template>
  260.         </copyright>
  261.     </xsl:if>
  262. </xsl:template>
  263.  
  264.  
  265. <xsl:template name="Year">
  266.     <xsl:param name="CopyrightLevel"/>
  267.     <xsl:param name="YearLevel"/>
  268.     <xsl:variable name="Copyright"><xsl:value-of select="concat('articleinfo.copyright_','', $CopyrightLevel)"/></xsl:variable>
  269. <xsl:variable name="Year"><xsl:value-of select="concat($Copyright,'',concat('.year_','',$YearLevel))"/></xsl:variable>
  270.  
  271.     <xsl:if test="text:p/text:variable-set[@text:name=$Year]">
  272.         <orgname>
  273.             <xsl:value-of select="text:p/text:variable-set[@text:name=$Year]"/>
  274.         </orgname>
  275.     </xsl:if>
  276. </xsl:template>
  277.  
  278.  
  279. <xsl:template name="Holder">
  280.     <xsl:param name="CopyrightLevel"/>
  281.     <xsl:param name="HolderLevel"/>
  282.     <xsl:variable name="Copyright"><xsl:value-of select="concat('articleinfo.copyright_','', $CopyrightLevel)"/></xsl:variable>
  283. <xsl:variable name="Holder"><xsl:value-of select="concat($Copyright,'',concat('.holder_','',$HolderLevel))"/></xsl:variable>
  284.  
  285.     <xsl:if test="text:p/text:variable-set[@text:name=$Holder]">
  286.         <orgname>
  287.             <xsl:value-of select="text:p/text:variable-set[@text:name=$Holder]"/>
  288.         </orgname>
  289.     </xsl:if>
  290. </xsl:template>
  291.  
  292.  
  293.  
  294. <xsl:template name="Author">
  295.     <xsl:param name="AuthorLevel"/>
  296.     <xsl:variable name="Author"><xsl:value-of select="concat('articleinfo.author_','', $AuthorLevel)"/></xsl:variable>    
  297.     <xsl:if test="text:p/text:variable-set[contains(@text:name, $Author )]">
  298.         <author>
  299.             <xsl:call-template name="Surname"><xsl:with-param name="AuthorLevel" select="$AuthorLevel"/><xsl:with-param name="SurnameLevel" select="0"/></xsl:call-template>
  300.             <xsl:call-template name="Firstname"><xsl:with-param name="AuthorLevel" select="$AuthorLevel"/><xsl:with-param name="FirstnameLevel" select="0"/></xsl:call-template>
  301.             <xsl:call-template name="Affiliation"><xsl:with-param name="AuthorLevel" select="$AuthorLevel"/><xsl:with-param name="AffilLevel" select="0"/></xsl:call-template>
  302.         </author>
  303.         <xsl:call-template name="Author"><xsl:with-param name="AuthorLevel" select="$AuthorLevel+1"/></xsl:call-template>
  304.     </xsl:if>    
  305. </xsl:template>
  306.  
  307.  
  308. <xsl:template name="Surname">
  309.     <xsl:param name="AuthorLevel"/>
  310.     <xsl:param name="SurnameLevel"/>
  311.     <xsl:variable name="Author"><xsl:value-of select="concat('articleinfo.author_','', $AuthorLevel)"/></xsl:variable>
  312.     <xsl:variable name="Surname"><xsl:value-of select="concat($Author,'',concat('.surname_','',$SurnameLevel))"/></xsl:variable>
  313.     <xsl:if test="text:p/text:variable-set[@text:name=$Surname]">
  314.         <surname>
  315.             <xsl:value-of select="text:p/text:variable-set[@text:name=$Surname]"/>
  316.         </surname>
  317.         <xsl:call-template name="Surname"><xsl:with-param name="AuthorLevel" select="$AuthorLevel"/>
  318.         <xsl:with-param name="SurnameLevel" select="SurnameLevel+1"/>
  319.         </xsl:call-template>
  320.  
  321.     </xsl:if>
  322. </xsl:template>
  323.  
  324.  
  325.  
  326.  
  327. <xsl:template name="Firstname">
  328.     <xsl:param name="AuthorLevel"/>
  329.     <xsl:param name="FirstnameLevel"/>
  330.     <xsl:variable name="Author"><xsl:value-of select="concat('articleinfo.author_','', $AuthorLevel)"/></xsl:variable>
  331.     <xsl:variable name="Firstname"><xsl:value-of select="concat($Author,'',concat('.firstname_','',$FirstnameLevel))"/></xsl:variable>
  332.     <xsl:if test="text:p/text:variable-set[@text:name=$Firstname]">
  333.         <firstname>
  334.             <xsl:value-of select="text:p/text:variable-set[@text:name=$Firstname]"/>
  335.         </firstname>
  336.         <xsl:call-template name="Surname">
  337.             <xsl:with-param name="AuthorLevel" select="$AuthorLevel"/>
  338.             <xsl:with-param name="FirstnameLevel" select="FirstnameLevel+1"/>
  339.         </xsl:call-template>
  340.     </xsl:if>
  341. </xsl:template>
  342.  
  343.  
  344.  
  345. <xsl:template name="Affiliation">
  346.     <xsl:param name="AuthorLevel"/>
  347.     <xsl:param name="AffilLevel"/>
  348.     <xsl:variable name="Author"><xsl:value-of select="concat('articleinfo.author_','', $AuthorLevel)"/></xsl:variable>
  349.     <xsl:variable name="Affil"><xsl:value-of select="concat($Author,'',concat('.affiliation_','',$AffilLevel))"/></xsl:variable>
  350.     <xsl:if test="text:p/text:variable-set[contains(@text:name,$Affil)]">
  351.         <affiliation>
  352.             <xsl:call-template name="Orgname">
  353.                 <xsl:with-param name="AuthorLevel" select="$AuthorLevel"/>
  354.                 <xsl:with-param name="AffilLevel" select="$AffilLevel"/><xsl:with-param name="OrgLevel" select="0"/>
  355.             </xsl:call-template>
  356.             <xsl:call-template name="Address">
  357.                 <xsl:with-param name="AuthorLevel" select="$AuthorLevel"/>
  358.                 <xsl:with-param name="AffilLevel" select="$AffilLevel"/><xsl:with-param name="AddressLevel" select="0"/>
  359.  
  360.             </xsl:call-template>
  361.         </affiliation>
  362.     </xsl:if>
  363. </xsl:template>
  364.  
  365. <xsl:template name="Orgname">
  366.     <xsl:param name="AuthorLevel"/>
  367.     <xsl:param name="AffilLevel"/>
  368.     <xsl:param name="OrgLevel"/>
  369.  
  370.     <xsl:variable name="Author"><xsl:value-of select="concat('articleinfo.author_','', $AuthorLevel)"/></xsl:variable>
  371. <xsl:variable name="Affil"><xsl:value-of select="concat($Author,'',concat('.affiliation_','',$AffilLevel))"/></xsl:variable>
  372.     <xsl:variable name="Org"><xsl:value-of select="concat($Affil,'',concat('.orgname_','',$OrgLevel))"/></xsl:variable>
  373.  
  374.     <xsl:if test="text:p/text:variable-set[@text:name=$Org]">
  375.         <orgname>
  376.             <xsl:value-of select="text:p/text:variable-set[@text:name=$Org]"/>
  377.         </orgname>
  378.     </xsl:if>
  379. </xsl:template>
  380.  
  381. <xsl:template name="Address">
  382.     <xsl:param name="AuthorLevel"/>
  383.     <xsl:param name="AffilLevel"/>
  384.     <xsl:param name="AddressLevel"/>
  385.  
  386.     <xsl:variable name="Author"><xsl:value-of select="concat('articleinfo.author_','', $AuthorLevel)"/></xsl:variable>
  387. <xsl:variable name="Affil"><xsl:value-of select="concat($Author,'',concat('.affiliation_','',$AffilLevel))"/></xsl:variable>
  388.     <xsl:variable name="Address"><xsl:value-of select="concat($Affil,'',concat('.address_','',$AddressLevel))"/></xsl:variable>
  389.  
  390.     <xsl:if test="text:p/text:variable-set[@text:name=$Address]">
  391.         <address>
  392.             <xsl:value-of select="text:p/text:variable-set[@text:name=$Address]"/>
  393.         </address>
  394.     </xsl:if>
  395. </xsl:template>
  396.  
  397.  
  398.  
  399.  
  400. <xsl:template match="text:p[@text:style-name='Document Title']">
  401. </xsl:template>
  402.  
  403. <xsl:template match="text:p[@text:style-name='Document SubTitle']">
  404. </xsl:template>
  405.  
  406.  
  407. <xsl:template match="text:p[@text:style-name='Section Title']">
  408.     <xsl:element name="title">
  409.         <xsl:apply-templates/>
  410.     </xsl:element>
  411. </xsl:template>
  412.  
  413. <xsl:template match="text:p[@text:style-name='Appendix Title']">
  414.     <xsl:element name="title">
  415.         <xsl:apply-templates/>
  416.     </xsl:element>
  417. </xsl:template>
  418.  
  419.  
  420. <!--<xsl:template match="text:p[@text:style-name='VarList Item']">
  421.     <xsl:if test="not(preceding-sibling::text:p[@text:style-name='VarList Item'])">
  422.         <xsl:text disable-output-escaping="yes"><listitem></xsl:text>
  423.     </xsl:if>
  424.         <para>
  425.             <xsl:apply-templates/>
  426.         </para>
  427.     <xsl:if test="not(following-sibling::text:p[@text:style-name='VarList Item'])">
  428.         <xsl:text disable-output-escaping="yes"></listitem></xsl:text>
  429.     </xsl:if>
  430. </xsl:template>-->
  431.  
  432. <xsl:template match="text:p[@text:style-name='VarList Term']">
  433.     <xsl:element name="term">
  434.             <xsl:apply-templates/>
  435.     </xsl:element>
  436. </xsl:template>
  437.  
  438. <xsl:template match="text:p[@text:style-name='VarList Item']">
  439.     <xsl:element name="listitem">
  440.         <xsl:element name="para">
  441.             <xsl:apply-templates/>
  442.         </xsl:element>
  443.     </xsl:element>
  444. </xsl:template>
  445.  
  446. <xsl:template match="text:p[@text:style-name='Section1 Title']">
  447.     <xsl:element name="title">
  448.         <xsl:apply-templates/>
  449.     </xsl:element>
  450. </xsl:template>
  451.  
  452.  
  453. <xsl:template match="text:p[@text:style-name='Section2 Title']">
  454.     <xsl:element name="title">
  455.         <xsl:apply-templates/>
  456.     </xsl:element >
  457. </xsl:template>
  458.  
  459.  
  460. <xsl:template match="text:p[@text:style-name='Section3 Title']">
  461.     <xsl:element name="title">
  462.         <xsl:apply-templates/>
  463.     </xsl:element>
  464. </xsl:template>
  465.  
  466. <xsl:template match="text:footnote-citation">
  467. </xsl:template>
  468.  
  469. <xsl:template match="text:p[@text:style-name='Mediaobject']">
  470.     <mediaobject>
  471.         <xsl:apply-templates/>
  472.     </mediaobject>
  473. </xsl:template>
  474.  
  475. <xsl:template match="office:annotation/text:p">
  476.     <note>
  477.     <remark>
  478.         <xsl:apply-templates/>
  479.     </remark>
  480.     </note>
  481. </xsl:template>
  482.  
  483. <!--<xsl:template match="meta:initial-creator">
  484.     <author>
  485.     <xsl:apply-templates />
  486.         </author>
  487. </xsl:template>-->
  488.  
  489. <xsl:template match="table:table"> 
  490.     <xsl:choose>
  491.         <xsl:when test="following-sibling::text:p[@text:style-name='Table']">
  492.             <table frame="all">
  493.                  <xsl:attribute name="id">
  494.                     <xsl:value-of select="@table:name"/>
  495.                 </xsl:attribute>
  496.                 <title>
  497.                     <xsl:value-of select="following-sibling::text:p[@text:style-name='Table']"/>
  498.                 </title>
  499.                 <xsl:call-template name="generictable"/>
  500.             </table>
  501.         </xsl:when>
  502.         <xsl:otherwise>
  503.             <informaltable frame="all">
  504.                 <xsl:call-template name="generictable"/>
  505.             </informaltable>
  506.         </xsl:otherwise>
  507.     </xsl:choose>
  508. </xsl:template>
  509.  
  510.  
  511. <xsl:template name="generictable">
  512.             <xsl:variable name="cells" select="count(descendant::table:table-cell)" ></xsl:variable>
  513.             <xsl:variable name="rows"><xsl:value-of select="count(descendant::table:table-row) "/></xsl:variable>
  514.             <xsl:variable name="cols"><xsl:value-of select="$cells div $rows"/></xsl:variable>
  515.             <xsl:variable name="numcols">
  516.             <xsl:choose>
  517.                     <xsl:when test="child::table:table-column/@table:number-columns-repeated">
  518.                             <xsl:value-of select="number(table:table-column/@table:number-columns-repeated+1)"/>
  519.                     </xsl:when>
  520.                     <xsl:otherwise >
  521.                             <xsl:value-of select="$cols"/>
  522.                     </xsl:otherwise>
  523.             </xsl:choose>
  524.         </xsl:variable>
  525.         <xsl:element name="tgroup">
  526.             <xsl:attribute name="cols">
  527.                         <xsl:value-of select="$numcols"/>
  528.             </xsl:attribute>    
  529.             <xsl:call-template name="colspec"><xsl:with-param name="left" select="1" /></xsl:call-template>
  530.                 <xsl:apply-templates/>
  531.         </xsl:element>
  532. </xsl:template>
  533.  
  534.  
  535.  
  536. <xsl:template name="colspec">
  537.     <xsl:param name="left"/>
  538.     <xsl:if test="number($left < ( table:table-column/@table:number-columns-repeated +2)  )">
  539.             <xsl:element name="colspec">
  540.                 <xsl:attribute name="colnum"><xsl:value-of select="$left"/></xsl:attribute>
  541.                 <xsl:attribute name="colname">c<xsl:value-of select="$left"/></xsl:attribute>
  542.             </xsl:element>
  543.             <xsl:call-template name="colspec"><xsl:with-param name="left" select="$left+1" /></xsl:call-template>
  544.     </xsl:if>
  545. </xsl:template>
  546.  
  547.  
  548.  
  549. <xsl:template match="table:table-column">
  550.         <xsl:apply-templates/>
  551. </xsl:template>
  552.  
  553. <xsl:template match="table:table-header-rows">
  554.     <thead>
  555.         <xsl:apply-templates/>
  556.     </thead>    
  557. </xsl:template>
  558.  
  559. <xsl:template match="table:table-header-rows/table:table-row">
  560.     <row>
  561.         <xsl:apply-templates />
  562.     </row>
  563. </xsl:template>
  564.  
  565. <xsl:template match="table:table/table:table-row">
  566.     <xsl:if test="not(preceding-sibling::table:table-row)">
  567.         <xsl:text disable-output-escaping="yes"><tbody></xsl:text>
  568.     </xsl:if>
  569.     <row>
  570.         <xsl:apply-templates />
  571.     </row>
  572.         <xsl:if test="not(following-sibling::table:table-row)">
  573.         <xsl:text disable-output-escaping="yes"></tbody></xsl:text>
  574.     </xsl:if>
  575. </xsl:template>
  576.  
  577. <xsl:template match="table:table-cell">
  578.  <xsl:element name="entry">
  579.          <xsl:if test="@table:number-columns-spanned >'1'">
  580.             <xsl:attribute name="namest"><xsl:value-of select="concat('c',count(preceding-sibling::table:table-cell[not(@table:number-columns-spanned)]) +sum(preceding-sibling::table:table-cell/@table:number-columns-spanned)+1)"/></xsl:attribute>
  581.             <xsl:attribute name="nameend"><xsl:value-of select="concat('c',count(preceding-sibling::table:table-cell[not(@table:number-columns-spanned)]) +sum(preceding-sibling::table:table-cell/@table:number-columns-spanned)+ @table:number-columns-spanned)"/></xsl:attribute>
  582.         </xsl:if>
  583.         <xsl:apply-templates />
  584.     </xsl:element>
  585. </xsl:template>
  586.  
  587. <xsl:template match="text:p">
  588. <xsl:choose>
  589.     <xsl:when test="@text:style-name='Table'">
  590.     </xsl:when>
  591.     <xsl:otherwise>
  592.         <para>        
  593.             <xsl:apply-templates/>
  594.         </para>
  595.     </xsl:otherwise>
  596. </xsl:choose>
  597. </xsl:template>
  598.  
  599. <xsl:template match="text:unordered-list">
  600. <xsl:choose>
  601.     <xsl:when  test="@text:style-name='Var List'">
  602.         <variablelist>
  603.             <xsl:apply-templates/>
  604.         </variablelist>
  605.     </xsl:when>
  606.     <xsl:when  test="@text:style-name='UnOrdered List'">
  607.         <variablelist>
  608.             <xsl:apply-templates/>
  609.         </variablelist>
  610.     </xsl:when>
  611.     <xsl:otherwise>
  612.     <itemizedlist>
  613.         <title></title>
  614.         <xsl:apply-templates/>
  615.     </itemizedlist>
  616.     </xsl:otherwise>
  617. </xsl:choose>
  618. </xsl:template>
  619.  
  620. <xsl:template match="text:list-item">
  621. <!--    <xsl:if test="parent::text:unordered-list/@text:style-name='Var List'">
  622.         
  623.     </xsl:if>
  624.     <xsl:if test="not(parent::text:unordered-list/@text:style-name='Var List')">
  625.         <listitem>
  626.             <xsl:apply-templates/>
  627.         </listitem>
  628.     </xsl:if>-->
  629.     <xsl:choose>
  630.         <xsl:when test="parent::text:unordered-list/@text:style-name='Var List' ">
  631.             <xsl:if test="child::text:p[@text:style-name='VarList Term']">
  632.             <xsl:element name="varlistentry">
  633.                     <xsl:apply-templates select="child::text:p[@text:style-name='VarList Term']"/>
  634.                         <xsl:if test="following-sibling::text:list-item[1]/text:p[@text:style-name='VarList Item']">
  635.                             <xsl:apply-templates select="following-sibling::text:list-item[1]/text:p"/>
  636.                         </xsl:if>
  637.                   </xsl:element>
  638.             </xsl:if>
  639.         </xsl:when>
  640.         <xsl:otherwise>
  641.             <xsl:element name="listitem">
  642.                 <xsl:apply-templates/>
  643.             </xsl:element>
  644.         </xsl:otherwise>
  645.     </xsl:choose>    
  646. </xsl:template>
  647.  
  648.  
  649.  
  650.  
  651.  
  652. <xsl:template match="dc:title">
  653. </xsl:template>
  654.  
  655. <xsl:template match="dc:description">
  656.     <abstract><para>
  657.         <xsl:apply-templates/>
  658.         </para>
  659.     </abstract>
  660. </xsl:template>
  661.  
  662. <xsl:template match="dc:subject">
  663. </xsl:template>
  664.  
  665.  
  666. <xsl:template match="meta:generator">
  667. </xsl:template>
  668.  
  669. <xsl:template match="draw:plugin">
  670. <xsl:element name="audioobject">
  671.     <xsl:attribute name="fileref">
  672.         <xsl:value-of select="@xlink:href"/>
  673.     </xsl:attribute>
  674.     <xsl:attribute name="width">
  675.     </xsl:attribute>
  676. </xsl:element>
  677. </xsl:template>
  678.  
  679. <xsl:template match="text:footnote">
  680.     <footnote>
  681.         <xsl:apply-templates/>
  682.     </footnote>
  683. </xsl:template>
  684.  
  685. <xsl:template match="text:footnote-body">
  686.         <xsl:apply-templates/>
  687. </xsl:template>
  688.  
  689.  
  690. <xsl:template match="draw:text-box">
  691. </xsl:template>
  692.  
  693.  
  694.  
  695. <xsl:template match="draw:image">
  696. <xsl:choose>
  697.     <xsl:when test="parent::text:p[@text:style-name='Mediaobject']">
  698.         <xsl:element name="imageobject">
  699.             <xsl:element name="imagedata">
  700.             <xsl:attribute name="fileref">
  701.                 <xsl:value-of select="@xlink:href"/>
  702.             </xsl:attribute>
  703.             </xsl:element>
  704.             <xsl:element name="caption">
  705.                 <xsl:value-of select="."/>
  706.             </xsl:element>
  707.         </xsl:element>
  708.     </xsl:when>
  709.     <xsl:otherwise>
  710.         <xsl:element name="inlinegraphic">
  711.             <xsl:attribute name="fileref">
  712.                 <xsl:value-of select="@xlink:href"/>
  713.             </xsl:attribute>
  714.             <xsl:attribute name="width"></xsl:attribute>
  715.         </xsl:element>
  716.     </xsl:otherwise>
  717. </xsl:choose>
  718. </xsl:template>
  719.  
  720.  
  721.  
  722.  
  723.  
  724. <xsl:template match="text:span">
  725. <xsl:choose>
  726. <xsl:when test="./@text:style-name='GuiMenu'">
  727.         <xsl:element name="guimenu">
  728.             <xsl:value-of select="."/>    
  729.         </xsl:element>
  730.     </xsl:when>
  731.     <xsl:when test="./@text:style-name='GuiSubMenu'">
  732.         <xsl:element name="guisubmenu">
  733.             <xsl:value-of select="."/>    
  734.         </xsl:element>
  735.     </xsl:when>
  736.         <xsl:when test="@text:style-name='GuiMenuItem'">
  737.         <xsl:element name="guimenuitem">
  738.             <xsl:value-of select="."/>    
  739.         </xsl:element>
  740.     </xsl:when>
  741.     <xsl:when test="@text:style-name='GuiButton'">
  742.         <xsl:element name="guibutton">
  743.             <xsl:value-of select="."/>    
  744.         </xsl:element>
  745.     </xsl:when>
  746.         <xsl:when test="@text:style-name='GuiButton'">
  747.         <xsl:element name="guibutton">
  748.             <xsl:value-of select="."/>    
  749.         </xsl:element>
  750.     </xsl:when>
  751.     <xsl:when test="@text:style-name='GuiLabel'">
  752.         <xsl:element name="guilabel">
  753.             <xsl:value-of select="."/>    
  754.         </xsl:element>
  755.     </xsl:when>
  756.     <xsl:when test="@text:style-name='Emphasis'">
  757.         <xsl:element name="emphasis">
  758.             <xsl:value-of select="."/>    
  759.         </xsl:element>
  760.     </xsl:when>
  761.     <xsl:when test="@text:style-name='FileName'">
  762.         <xsl:element name="filename">
  763.             <xsl:value-of select="."/>    
  764.         </xsl:element>
  765.     </xsl:when>
  766.     <xsl:when test="@text:style-name='Application'">
  767.         <xsl:element name="application">
  768.             <xsl:value-of select="."/>    
  769.         </xsl:element>
  770.     </xsl:when>
  771.     <xsl:when test="@text:style-name='Command'">
  772.         <command>
  773.             <xsl:apply-templates/>
  774.         </command>
  775.     </xsl:when>
  776.     <xsl:when test="@text:style-name='SubScript'">
  777.         <subscript>
  778.             <xsl:apply-templates/>
  779.         </subscript>
  780.     </xsl:when>
  781.     <xsl:when test="@text:style-name='SuperScript'">
  782.         <superscript>
  783.             <xsl:apply-templates/>
  784.         </superscript>
  785.     </xsl:when>
  786.     <xsl:when test="@text:style-name='SystemItem'">
  787.         <systemitem>
  788.             <xsl:apply-templates/>
  789.         </systemitem>
  790.     </xsl:when>
  791.     <xsl:when test="@text:style-name='ComputerOutput'">
  792.         <computeroutput>
  793.             <xsl:apply-templates/>
  794.         </computeroutput>
  795.     </xsl:when>
  796.     <xsl:when test="@text:style-name='Highlight'">
  797.         <highlight>
  798.             <xsl:apply-templates/>
  799.         </highlight>
  800.     </xsl:when>
  801.         <xsl:when test="@text:style-name='KeyCap'">
  802.         <keycap>
  803.             <xsl:apply-templates/>
  804.         </keycap>
  805.     </xsl:when>
  806.     <xsl:when test="@text:style-name='KeySym'">
  807.         <xsl:element name="keysym">
  808.             <xsl:apply-templates/>
  809.         </xsl:element>
  810.     </xsl:when>
  811.     <xsl:when test="@text:style-name='KeyCombo'">
  812.         <keycombo>
  813.             <xsl:apply-templates/>
  814.         </keycombo>
  815.     </xsl:when>
  816.     <xsl:otherwise>
  817.         <xsl:apply-templates/>
  818.     </xsl:otherwise>
  819. </xsl:choose>
  820.     
  821. </xsl:template>
  822.  
  823.  
  824. <xsl:template match="text:a">
  825.     <xsl:choose>
  826.         <xsl:when test="contains(@xlink:href,'://')">
  827.             <xsl:element name="ulink">
  828.                 <xsl:attribute name="url">
  829.                     <xsl:value-of select="@xlink:href"/>
  830.                 </xsl:attribute>
  831.                 <xsl:apply-templates/>
  832.             </xsl:element>
  833.         </xsl:when>
  834.         <xsl:when test="not(contains(@xlink:href,'#'))">
  835.             <xsl:element name="olink">
  836.                 <xsl:attribute name="targetdocent">
  837.                     <xsl:value-of select="@xlink:href"/>
  838.                 </xsl:attribute>
  839.                 <xsl:apply-templates/>
  840.             </xsl:element>
  841.         </xsl:when>
  842.         <xsl:otherwise>
  843.         <xsl:variable name="linkvar" select="substring-after(@xlink:href,'#')"/>
  844.             <xsl:element name="link">
  845.                 <xsl:attribute name="linkend">
  846.                     <xsl:value-of select="substring-before($linkvar,'%')"/>    
  847.                 </xsl:attribute>
  848.                 <xsl:apply-templates/>
  849.             </xsl:element>
  850.         </xsl:otherwise>
  851.     </xsl:choose>
  852. </xsl:template>
  853.  
  854.  
  855. </xsl:stylesheet>