home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 June / PCpro_2005_06.ISO / files / opensource / openoffice / openofficeorg3.cab / master_document.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-09-20  |  11.1 KB  |  247 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.    $RCSfile: master_document.xsl,v $
  5.  
  6.    $Revision: 1.4 $
  7.  
  8.    last change: $Author: rt $ $Date: 2004/09/20 12:23:38 $
  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 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  65.         xmlns:office="http://openoffice.org/2000/office"
  66.         xmlns:style="http://openoffice.org/2000/style"
  67.         xmlns:text="http://openoffice.org/2000/text"
  68.         xmlns:table="http://openoffice.org/2000/table"
  69.         xmlns:draw="http://openoffice.org/2000/drawing"
  70.         xmlns:fo="http://www.w3.org/1999/XSL/Format"
  71.         xmlns:xlink="http://www.w3.org/1999/xlink"
  72.         xmlns:number="http://openoffice.org/2000/datastyle"
  73.         xmlns:svg="http://www.w3.org/2000/svg"
  74.         xmlns:chart="http://openoffice.org/2000/chart"
  75.         xmlns:dr3d="http://openoffice.org/2000/dr3d"
  76.         xmlns:math="http://www.w3.org/1998/Math/MathML"
  77.         xmlns:form="http://openoffice.org/2000/form"
  78.         xmlns:script="http://openoffice.org/2000/script"
  79.         xmlns:dc="http://purl.org/dc/elements/1.1/"
  80.         xmlns:meta="http://openoffice.org/2000/meta"
  81.         xmlns:config="http://openoffice.org/2001/config"
  82.         xmlns:help="http://openoffice.org/2000/help"
  83.         xmlns:java="http://xml.apache.org/xslt/java"
  84.         xmlns:sxg="http://www.jclark.com/xt/java/org.openoffice.xslt.OOoMasterDocument"
  85.         xmlns:sxg-xt="http://www.jclark.com/xt/java/org.openoffice.xslt.OOoNodeHandlingXT"
  86.         xmlns="http://www.w3.org/1999/xhtml"
  87.         version="1.0"
  88.         exclude-result-prefixes="office style text table draw fo xlink number svg chart dr3d math form script dc meta config help java sxg sxg-xt">
  89.  
  90.     <xsl:include href="master_refs_workaround.xsl" />
  91.     <xsl:include href="master_chapter_numbering.xsl" />
  92.     <xsl:include href="master_usability_links.xsl" />
  93.  
  94.     <!--
  95.     SUMMARY:
  96.      following parameter triggers a (quite time consuming) workaround for enabling of chapter links in the table-of-content.
  97.  
  98.     IN DETAIL:
  99.      Currently some links used in the Office XML (for example, in the content table as '#7.Some%20Example%20Headline%7Outline')
  100.      are not a valid URLs (cmp. bug id# 102311).
  101.      No file destination is specified nor exist any anchor element for these links in the Office XML.
  102.      A workaround for this transformation therefore had to be made. This time-consuming mechanism is disabled by default and
  103.      can be activated by a parameter (i.e. 'childDocumentExist'). A creation of an anchor is made for each header element.
  104.      All header titles gonna be encoded to be usable in a relative URL.  -->
  105.     <xsl:param name="childDocumentExist" select="boolean(/*/office:body/text:section/text:section-source/@xlink:href)" />
  106.  
  107.     <!-- Used for the bug workaround of missing content table links
  108.         To avoid ambigous HTML references from the content table -->
  109.     <xsl:param name="currentChildContentRef" />
  110.  
  111.     <!-- Used for the bug workaround of missing content table links
  112.         By this node-set the relation between content-table link and children document header can be unambigous established -->
  113.     <xsl:param name="contentTableHeadings" />
  114.  
  115.  
  116.  
  117.     <!-- ******************************************************************************************************* -->
  118.     <!-- ***  TRANSFORMATION OF ALL CHILD DOCUMENTS OF THE MASTER DOCUMENT BY USING A EXTERNAL HELPER CLASS  *** -->
  119.     <!-- ******************************************************************************************************* -->
  120.  
  121.  
  122.     <!-- a new element 'contentTableHeadings' will be added to the helper variable the first time a child will be transformed -->
  123.     <xsl:template name="transform-global-document-and-children">
  124.         <xsl:param name="globalData" />
  125.  
  126.         <xsl:choose>
  127.             <xsl:when test="$globalData/content-table-headings">
  128.                 <xsl:call-template name="start-child-transformation">
  129.                     <xsl:with-param name="globalData" select="$globalData" />
  130.                 </xsl:call-template>
  131.             </xsl:when>
  132.             <xsl:otherwise>
  133.                 <!-- The necessary auxiliary variable hasn't build yet.
  134.                 This variable gonna store all headers (with chapter numbers) and the URL of their files
  135.  
  136.                 After the creation the template 'start-self-and-children-transformation'
  137.                 is being called!  -->
  138.                 <xsl:call-template name="create-helper-variables-for-Content-Table">
  139.                     <xsl:with-param name="globalData" select="$globalData" />
  140.                 </xsl:call-template>
  141.             </xsl:otherwise>
  142.         </xsl:choose>
  143.     </xsl:template>
  144.  
  145.  
  146.  
  147.     <xsl:template name="start-self-and-children-transformation">
  148.         <xsl:param name="globalData" />
  149.  
  150.         <xsl:if test="$debugEnabled">
  151.             <xsl:call-template name="debug-content-table-headings-variable">
  152.                 <xsl:with-param name="globalData" select="$globalData" />
  153.             </xsl:call-template>
  154.  
  155.             <xsl:message>Parsing the master document...</xsl:message>
  156.         </xsl:if>
  157.  
  158.  
  159.         <xsl:apply-templates>
  160.             <xsl:with-param name="globalData" select="$globalData" />
  161.         </xsl:apply-templates>
  162.  
  163.  
  164.         <xsl:if test="$debugEnabled">
  165.             <xsl:message>Parsing the child documents...</xsl:message>
  166.         </xsl:if>
  167.         <xsl:call-template name="start-child-transformation">
  168.             <xsl:with-param name="globalData" select="$globalData" />
  169.         </xsl:call-template>
  170.     </xsl:template>
  171.  
  172.  
  173.  
  174.  
  175.     <xsl:template name="start-child-transformation">
  176.         <xsl:param name="globalData" />
  177.  
  178.         <xsl:if test="$debugEnabled">
  179.             <xsl:message>Starting the child transformations...</xsl:message>
  180.         </xsl:if>
  181.  
  182.         <!-- As the childs of a master document (with suffix .sxg) do not know anything about their global parent,
  183.             the transformation of master documents children have to be done implizit.
  184.             Otherwise the chapter number of the children will always start with zero, as they do not know anything about the
  185.             proceding chapters.
  186.             Furthermore, they don't have any links about preceeding and following documents and no linking for usability reasons
  187.             could be done. Therefore the children have to be transformed during the transformation of a global (sxg) document -->
  188.         <xsl:if test="$debugEnabled">
  189.             <xsl:choose>
  190.                 <xsl:when test="$globalData/content-table-headings">
  191.                     <xsl:message>Contentable data exists as global data!</xsl:message>
  192.                 </xsl:when>
  193.                 <xsl:otherwise>
  194.                     <xsl:message>No Contentable global data exists!</xsl:message>
  195.                 </xsl:otherwise>
  196.             </xsl:choose>
  197.         </xsl:if>
  198.         <!-- testcase giving out the variable as file
  199.         <xsl:element name="debug-output">
  200.         <xsl:copy-of select="$globalData/content-table-headings" />
  201.         </xsl:element> -->
  202.  
  203.         <!-- currently this function only works with node-sets from XT -->
  204.         <xsl:choose>
  205.             <xsl:when test="function-available('sxg-xt:transform-children')">
  206.                 <xsl:message>
  207.                     <xsl:value-of select="sxg-xt:transform-children( $globalData/content-table-headings, string($sourceBaseURL), string($targetBaseURL), string($optionalURLSuffix), string($dpi), string($outputType), $childDocumentExist, $debugEnabled)" />
  208.                 </xsl:message>
  209.             </xsl:when>
  210.             <xsl:otherwise>
  211.                 <xsl:message terminate="yes">ERROR: Java method transformChildren to transform all children of a master document could not be found. Be sure to use the XT processor.</xsl:message>
  212.             </xsl:otherwise>
  213.         </xsl:choose>
  214.     </xsl:template>
  215.  
  216.  
  217.     <xsl:template name="debug-content-table-headings-variable">
  218.         <xsl:param name="globalData" />
  219.  
  220.         <xsl:message>
  221.             <xsl:text>**** THE HEADING VARIABLE **** </xsl:text>
  222.         </xsl:message>
  223.  
  224.         <xsl:for-each select="$globalData/content-table-headings/heading">
  225.             <xsl:message>
  226.                 <xsl:text>**** new heading:        </xsl:text>
  227.             </xsl:message>
  228.             <xsl:message>content-table-id:      <xsl:value-of select="@content-table-id" />
  229.             </xsl:message>
  230.             <xsl:message>child-document-no:     <xsl:value-of select="@child-document-no" />
  231.             </xsl:message>
  232.             <xsl:message>file-url:              <xsl:value-of select="@file-url" />
  233.             </xsl:message>
  234.             <xsl:message>out-file-url:          <xsl:value-of select="@out-file-url" />
  235.             </xsl:message>
  236.             <xsl:message>level:                 <xsl:value-of select="@level" />
  237.             </xsl:message>
  238.             <xsl:message>title:                 <xsl:value-of select="@title" />
  239.             </xsl:message>
  240.             <xsl:message>encoded-title:         <xsl:value-of select="@encoded-title" />
  241.             </xsl:message>
  242.             <xsl:message>absolute-chapter-level:<xsl:value-of select="@absolute-chapter-level" />
  243.             </xsl:message>
  244.         </xsl:for-each>
  245.     </xsl:template>
  246.  
  247. </xsl:stylesheet>