home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 June / PCpro_2005_06.ISO / files / opensource / openoffice / openofficeorg3.cab / header.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2005-01-31  |  14.1 KB  |  337 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.    $RCSfile: header.xsl,v $
  5.  
  6.    $Revision: 1.4 $
  7.  
  8.    last change: $Author: rt $ $Date: 2005/01/28 15:23:52 $
  9.  
  10.    The Contents of this file are made available subject to the terms of
  11.    either of the following licenses
  12.  
  13.           - GNU Lesser General Public License Version 2.1
  14.           - Sun Industry Standards Source License Version 1.1
  15.  
  16.    Sun Microsystems Inc., October, 2000
  17.  
  18.    GNU Lesser General Public License Version 2.1
  19.    =============================================
  20.    Copyright 2000 by Sun Microsystems, Inc.
  21.    901 San Antonio Road, Palo Alto, CA 94303, USA
  22.  
  23.    This library is free software; you can redistribute it and/or
  24.    modify it under the terms of the GNU Lesser General Public
  25.    License version 2.1, as published by the Free Software Foundation.
  26.  
  27.    This library is distributed in the hope that it will be useful,
  28.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  29.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  30.    Lesser General Public License for more details.
  31.  
  32.    You should have received a copy of the GNU Lesser General Public
  33.    License along with this library; if not, write to the Free Software
  34.    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  35.    MA  02111-1307  USA
  36.  
  37.  
  38.    Sun Industry Standards Source License Version 1.1
  39.    =================================================
  40.    The contents of this file are subject to the Sun Industry Standards
  41.    Source License Version 1.1 (the "License"); You may not use this file
  42.    except in compliance with the License. You may obtain a copy of the
  43.    License at http://www.openoffice.org/license.html.
  44.  
  45.    Software provided under this License is provided on an "AS IS" basis,
  46.    WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
  47.    WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
  48.    MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
  49.    See the License for the specific provisions governing your rights and
  50.    obligations concerning the Software.
  51.  
  52.    The Initial Developer of the Original Code is: Sun Microsystems, Inc.
  53.  
  54.    Copyright ┬⌐ 2002 by Sun Microsystems, Inc.
  55.  
  56.    All Rights Reserved.
  57.  
  58.    Contributor(s): _______________________________________
  59.  
  60. -->
  61. <!--
  62.     For further documentation and updates visit http://xml.openoffice.org/sx2ml
  63. -->
  64. <xsl:stylesheet version="1.0"
  65.                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  66.                 xmlns:office="http://openoffice.org/2000/office"
  67.                 xmlns:style="http://openoffice.org/2000/style"
  68.                 xmlns:text="http://openoffice.org/2000/text"
  69.                 xmlns:table="http://openoffice.org/2000/table"
  70.                 xmlns:draw="http://openoffice.org/2000/drawing"
  71.                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
  72.                 xmlns:xlink="http://www.w3.org/1999/xlink"
  73.                 xmlns:number="http://openoffice.org/2000/datastyle"
  74.                 xmlns:svg="http://www.w3.org/2000/svg"
  75.                 xmlns:chart="http://openoffice.org/2000/chart"
  76.                 xmlns:dr3d="http://openoffice.org/2000/dr3d"
  77.                 xmlns:math="http://www.w3.org/1998/Math/MathML"
  78.                 xmlns:form="http://openoffice.org/2000/form"
  79.                 xmlns:script="http://openoffice.org/2000/script"
  80.                 xmlns:dc="http://purl.org/dc/elements/1.1/"
  81.                 xmlns:meta="http://openoffice.org/2000/meta"
  82.                 xmlns:config="http://openoffice.org/2001/config"
  83.                 xmlns:help="http://openoffice.org/2000/help"
  84.                 exclude-result-prefixes="office style text table draw fo xlink number svg chart dr3d math form script dc meta config help"
  85.                 xmlns="http://www.w3.org/1999/xhtml">
  86.  
  87.  
  88.  
  89.     <!-- ************** -->
  90.     <!-- *** header *** -->
  91.     <!-- ************** -->
  92.  
  93.     <xsl:template name="create-header">
  94.         <xsl:param name="globalData" />
  95.  
  96.         <xsl:element name="head">
  97.             <xsl:if test="$debugEnabled"><xsl:message>CSS helper variable will be created....</xsl:message></xsl:if>
  98.             <xsl:call-template name='xhtml-header-properties'>
  99.                 <xsl:with-param name="globalData" select="$globalData" />
  100.             </xsl:call-template>
  101.  
  102.             <!--+++++ CSS (CASCADING STYLE SHEET) HEADER STYLE WAY +++++-->
  103.             <xsl:if test="$outputType = 'CSS_HEADER'">
  104.                 <xsl:if test="$debugEnabled"><xsl:message>CSS variable ready, header will be created....</xsl:message></xsl:if>
  105.                 <!-- constructing the css header simulating inheritance of style-families by style order -->
  106.                 <xsl:call-template name='create-css-styleheader'>
  107.                     <xsl:with-param name="globalData" select="$globalData" />
  108.                 </xsl:call-template>
  109.                 <xsl:if test="$debugEnabled"><xsl:message>CSS header creation finished!</xsl:message></xsl:if>
  110.             </xsl:if>
  111.         </xsl:element>
  112.  
  113.     </xsl:template>
  114.  
  115.  
  116.     <!-- Creating a CSS style header from the collected styles of the 'globalData' parameter -->
  117.     <xsl:template name='create-css-styleheader'>
  118.         <xsl:param name="globalData" />
  119.  
  120.         <xsl:element name="style">
  121.             <xsl:attribute name="type">text/css</xsl:attribute>
  122. <xsl:text>
  123.     </xsl:text>
  124.     <xsl:call-template name='create-page-layout'>
  125.         <xsl:with-param name="globalData" select="$globalData" />
  126.     </xsl:call-template>
  127. <xsl:text>table { border-collapse:collapse; border-spacing:0; empty-cells:show }
  128.     </xsl:text>
  129. <xsl:text>td, th { vertical-align:top; }
  130.     </xsl:text>
  131. <xsl:text>h1, h2, h3, h4, h5, h6 { clear:both }
  132.     </xsl:text>
  133. <xsl:text>* { margin:0; }
  134.     </xsl:text>
  135.             <xsl:for-each select="$globalData/all-styles/style">
  136.             <!-- 2DO: only the style family in conjunction with the style name, makes the style unambigous -->
  137.         <xsl:text>*.</xsl:text><!--<xsl:value-of select="@style:family" /><xsl:text>:</xsl:text>--><xsl:value-of select="translate(@style:name, '. %()/\+', '')" /><xsl:text> { </xsl:text> <xsl:value-of select="final-properties" /><xsl:text>}
  138.     </xsl:text>
  139.             </xsl:for-each>
  140.         </xsl:element>
  141.  
  142.     </xsl:template>
  143.  
  144.  
  145.     <!-- Creating CSS page layout based on first office master style -->
  146.     <xsl:template name='create-page-layout'>
  147.         <xsl:param name="globalData" />
  148.  
  149. <xsl:text>@page { </xsl:text>
  150.  
  151.         <xsl:call-template name="page-size">
  152.             <xsl:with-param name="globalData"   select="$globalData" />
  153.         </xsl:call-template>
  154.         <xsl:call-template name="page-margin">
  155.             <xsl:with-param name="globalData"   select="$globalData" />
  156.         </xsl:call-template>
  157.  
  158. <xsl:text> }
  159.     </xsl:text>
  160.  
  161.     </xsl:template>
  162.  
  163.  
  164.  
  165.     <xsl:template name="page-size">
  166.         <xsl:param name="globalData" />
  167.  
  168.         <xsl:variable name="printOrientation"  select="$globalData/styles-file/*/office:automatic-styles/style:page-master/style:properties/@style:print-orientation" />
  169.         <xsl:variable name="pageWidth"         select="$globalData/styles-file/*/office:automatic-styles/style:page-master/style:properties/@fo:page-width" />
  170.         <xsl:variable name="pageHeight"        select="$globalData/styles-file/*/office:automatic-styles/style:page-master/style:properties/@fo:page-height" />
  171.         <xsl:choose>
  172.             <xsl:when test="$pageWidth and $pageHeight">
  173.                 <xsl:text>size: </xsl:text>
  174.                 <xsl:value-of select="$pageWidth" />
  175.                 <xsl:text> </xsl:text>
  176.                 <xsl:value-of select="$pageHeight" />
  177.                 <xsl:text>; </xsl:text>
  178.             </xsl:when>
  179.             <xsl:when test="$printOrientation">
  180.                 <xsl:text>size: </xsl:text>
  181.                 <xsl:value-of select="$printOrientation" />
  182.                 <xsl:text>; </xsl:text>
  183.             </xsl:when>
  184.         </xsl:choose>
  185.     </xsl:template>
  186.  
  187.  
  188.  
  189.     <xsl:template name="page-margin">
  190.         <xsl:param name="globalData" />
  191.  
  192.         <xsl:variable name="marginTop"  select="$globalData/styles-file/*/office:automatic-styles/style:page-master/style:properties/@fo:margin-top" />
  193.         <xsl:if test="$marginTop">
  194.             <xsl:text>margin-top: </xsl:text>
  195.             <xsl:value-of select="$marginTop" />
  196.             <xsl:text>; </xsl:text>
  197.         </xsl:if>
  198.         <xsl:variable name="marginBottom"  select="$globalData/styles-file/*/office:automatic-styles/style:page-master/style:properties/@fo:margin-bottom" />
  199.         <xsl:if test="$marginBottom">
  200.             <xsl:text>margin-bottom: </xsl:text>
  201.             <xsl:value-of select="$marginBottom" />
  202.             <xsl:text>; </xsl:text>
  203.         </xsl:if>
  204.         <xsl:variable name="marginLeft"  select="$globalData/styles-file/*/office:automatic-styles/style:page-master/style:properties/@fo:margin-left" />
  205.         <xsl:if test="$marginLeft">
  206.             <xsl:text>margin-left: </xsl:text>
  207.             <xsl:value-of select="$marginLeft" />
  208.             <xsl:text>; </xsl:text>
  209.         </xsl:if>
  210.         <xsl:variable name="marginRight"  select="$globalData/styles-file/*/office:automatic-styles/style:page-master/style:properties/@fo:margin-right" />
  211.         <xsl:if test="$marginRight">
  212.             <xsl:text>margin-right: </xsl:text>
  213.             <xsl:value-of select="$marginRight" />
  214.         </xsl:if>
  215.     </xsl:template>
  216.  
  217.  
  218.  
  219.     <!-- ********************************************************** -->
  220.     <!-- *** Common XHTML header for CSS_INLINED and CSS_HEADER *** -->
  221.     <!-- ********************************************************** -->
  222.  
  223.     <xsl:template name='xhtml-header-properties'>
  224.         <xsl:param name="globalData" />
  225.  
  226.         <!-- explicit output content-type for low-tech browser (e.g. IE6) -->
  227.         <xsl:element name="meta">
  228.             <xsl:attribute name="http-equiv">content-type</xsl:attribute>
  229.             <xsl:attribute name="content">text/html; charset=utf-8</xsl:attribute>
  230.         </xsl:element>
  231.  
  232.         <!-- title of document for browser frame title -->
  233.         <xsl:element name="title">
  234.             <xsl:choose>
  235.                 <xsl:when test="$globalData/meta-file/*/office:meta/dc:title">
  236.                     <xsl:value-of select="$globalData/meta-file/*/office:meta/dc:title" />
  237.                 </xsl:when>
  238.                 <!--<xsl:otherwise>
  239.                     <xsl:text>- no title specified</xsl:text>
  240.                 </xsl:otherwise>-->
  241.             </xsl:choose>
  242.         </xsl:element>
  243.  
  244.         <!-- a bit commercial -->
  245.         <xsl:element name="meta">
  246.             <xsl:attribute name="name">generator</xsl:attribute>
  247.             <xsl:attribute name="content">StarOffice/OpenOffice XSLT (http://xml.openoffice.org/sx2ml)</xsl:attribute>
  248.         </xsl:element>
  249.  
  250.         <!-- the author of the input source -->
  251.         <xsl:call-template name="add-meta-tag">
  252.             <xsl:with-param name="meta-name" select="'author'" />
  253.             <xsl:with-param name="meta-data" select="$globalData/meta-file/*/office:meta/meta:initial-creator" />
  254.         </xsl:call-template>
  255.  
  256.         <!-- creation-date of the input source -->
  257.         <xsl:call-template name="add-meta-tag">
  258.             <xsl:with-param name="meta-name" select="'created'" />
  259.             <xsl:with-param name="meta-data" select="$globalData/meta-file/*/office:meta/meta:creation-date" />
  260.         </xsl:call-template>
  261.  
  262.         <!-- name of last changing person of the input source -->
  263.         <xsl:call-template name="add-meta-tag">
  264.             <xsl:with-param name="meta-name" select="'changedby'" />
  265.             <xsl:with-param name="meta-data" select="$globalData/meta-file/*/office:meta/dc:creator" />
  266.         </xsl:call-template>
  267.  
  268.         <!-- last changing date of the input source -->
  269.         <xsl:call-template name="add-meta-tag">
  270.             <xsl:with-param name="meta-name" select="'changed'" />
  271.             <xsl:with-param name="meta-data" select="$globalData/meta-file/*/office:meta/dc:date" />
  272.         </xsl:call-template>
  273.  
  274.  
  275.         <!-- short description about the input source -->
  276.         <xsl:call-template name="add-meta-tag">
  277.             <xsl:with-param name="meta-name" select="'subject'" />
  278.             <xsl:with-param name="meta-data" select="$globalData/meta-file/*/office:meta/dc:subject" />
  279.         </xsl:call-template>
  280.  
  281.         <!-- detailed description about the input source -->
  282.         <xsl:call-template name="add-meta-tag">
  283.             <xsl:with-param name="meta-name" select="'description'" />
  284.             <xsl:with-param name="meta-data" select="$globalData/meta-file/*/office:meta/dc:description" />
  285.         </xsl:call-template>
  286.  
  287.         <!-- keywords about the input source -->
  288.         <xsl:call-template name="add-meta-keywords">
  289.             <xsl:with-param name="keyWords" select="$globalData/meta-file/*/office:meta/meta:keywords" />
  290.         </xsl:call-template>
  291.  
  292.         <!-- title of document for browser frame title -->
  293.         <xsl:element name="base">
  294.             <xsl:attribute name="href">
  295.                 <xsl:value-of select="$targetURL" />
  296.             </xsl:attribute>
  297.         </xsl:element>
  298.     </xsl:template>
  299.  
  300.     <!-- generic template for adding common meta tags -->
  301.     <xsl:template name="add-meta-tag">
  302.         <xsl:param name="meta-name" />
  303.         <xsl:param name="meta-data" />
  304.  
  305.         <xsl:if test="$meta-data">
  306.             <xsl:element name="meta">
  307.                 <xsl:attribute name="name">
  308.                     <xsl:value-of select="$meta-name" />
  309.                 </xsl:attribute>
  310.                 <xsl:attribute name="content">
  311.                     <xsl:value-of select="$meta-data" />
  312.                 </xsl:attribute>
  313.             </xsl:element>
  314.         </xsl:if>
  315.     </xsl:template>
  316.  
  317.     <!-- helper template to write keyword elements into a tokenized string -->
  318.     <xsl:template name="add-meta-keywords">
  319.         <xsl:param name="keyWords" />
  320.  
  321.         <xsl:if test="$keyWords">
  322.             <xsl:element name="meta">
  323.                 <xsl:attribute name="name">keywords</xsl:attribute>
  324.                 <xsl:attribute name="content">
  325.                     <xsl:for-each select="$keyWords/meta:keyword">
  326.                         <xsl:value-of select="." />
  327.                         <xsl:if test="position() != last()">
  328.                             <xsl:text>, </xsl:text>
  329.                         </xsl:if>
  330.                     </xsl:for-each>
  331.                 </xsl:attribute>
  332.             </xsl:element>
  333.         </xsl:if>
  334.     </xsl:template>
  335.  
  336. </xsl:stylesheet>
  337.