| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- This file is part of the DITA Open Toolkit project.
- See the accompanying license.txt file for applicable licenses. -->
- <!-- (c) Copyright IBM Corp. 2005 All Rights Reserved. -->
- <xsl:stylesheet
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
- xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
- xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
- xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
- xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
- xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
- xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
- xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
- xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
- xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
- xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
- xmlns:math="http://www.w3.org/1998/Math/MathML"
- xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
- xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
- xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0"
- xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"
- xmlns:prodtools="http://www.ibm.com/xmlns/prodtools"
- version="2.0"
- >
- <xsl:output method="xml"/>
- <xsl:output indent="yes"/>
- <xsl:strip-space elements="*"/>
- <!-- =========== CALS (OASIS) TABLE =========== -->
- <xsl:template match="*[contains(@class,' topic/table ')]" name="topic.table">
-
- <!-- render table -->
- <xsl:call-template name="render_table"/>
-
- </xsl:template>
-
- <xsl:template name="create_columns_for_table">
- <xsl:param name="column" select="0"/>
- <xsl:if test="$column > 0">
- <table:table-column/>
- <xsl:call-template name="create_columns_for_table">
- <xsl:with-param name="column" select="$column - 1"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:template>
- <xsl:template name="dotable">
- <xsl:apply-templates/>
- </xsl:template>
- <xsl:template match="*[contains(@class,' topic/tgroup ')]" name="topic.tgroup">
- <xsl:variable name="tablenameId" select="generate-id(.)"/>
-
- <xsl:variable name="columnNum">
- <xsl:call-template name="count_columns_for_table"/>
- </xsl:variable>
-
- <!-- start flagging -->
- <xsl:apply-templates select="parent::*[contains(@class, ' topic/table ')]" mode="start-add-odt-flags">
- <xsl:with-param name="family" select="'_table'"/>
- </xsl:apply-templates>
-
- <table:table table:name="{concat('Table', $tablenameId)}">
-
- <!-- table background flagging -->
- <xsl:apply-templates select="parent::*[contains(@class, ' topic/table ')]" mode="start-add-odt-flags">
- <xsl:with-param name="family" select="'_table_attr'"/>
- </xsl:apply-templates>
- <xsl:call-template name="create_columns_for_table">
- <xsl:with-param name="column" select="$columnNum"/>
- </xsl:call-template>
- <xsl:call-template name="dotable"/>
- </table:table>
- <!-- end flagging -->
- <xsl:apply-templates select="parent::*[contains(@class, ' topic/table ')]" mode="end-add-odt-flags">
- <xsl:with-param name="family" select="'_table'"/>
- </xsl:apply-templates>
- </xsl:template>
-
-
- <xsl:template name="count_columns_for_table">
- <xsl:choose>
- <xsl:when test="@cols">
- <xsl:value-of select="@cols"/>
- </xsl:when>
- <xsl:when test="not(child::*[contains(@class, ' topic/colspec ')])">
- <xsl:choose>
- <xsl:when test="child::*[contains(@class, ' topic/thead ')]">
- <xsl:value-of select="count(child::*[contains(@class, ' topic/thead ')][1]
- /child::*[contains(@class, ' topic/row ')][1]
- /child::*[contains(@class, ' topic/entry ')])"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="count(descendant::*[contains(@class, ' topic/row ')][1]
- /child::*[contains(@class, ' topic/entry ')])"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="count(child::*[contains(@class, ' topic/colspec ')])"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="*[contains(@class,' topic/table ')]/*[contains(@class,' topic/title ')]">
- <xsl:variable name="ancestorlang">
- <xsl:call-template name="getLowerCaseLang"/>
- </xsl:variable>
- <xsl:variable name="tbl-count-actual" select="count(preceding::*[contains(@class,' topic/table ') or contains(@class,' topic/simpletable ')]/*[contains(@class,' topic/title ')])+1"/>
-
- <text:p text:style-name="center">
- <text:span text:style-name="bold">
- <xsl:choose>
- <!-- Hungarian: "1.
- Table " -->
- <xsl:when test="( (string-length($ancestorlang)=5 and contains($ancestorlang,'hu-hu')) or
- (string-length($ancestorlang)=2 and contains($ancestorlang,'hu')) )">
- <xsl:value-of
- select="$tbl-count-actual"/><xsl:text>. </xsl:text>
- <xsl:call-template
- name="getVariable">
- <xsl:with-param name="id" select="'Table'"/>
- </xsl:call-template>
- <xsl:text>
- </xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="getVariable">
- <xsl:with-param name="id" select="'Table'"/>
- </xsl:call-template>
- <xsl:text> </xsl:text>
- <xsl:value-of select="$tbl-count-actual"/><xsl:text>. </xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:value-of select="."/>
- </text:span>
- </text:p>
- </xsl:template>
- <xsl:template match="*[contains(@class,' topic/table ')]/*[contains(@class,' topic/desc ')]">
- <text:p text:style-name="center">
- <xsl:apply-templates/>
- </text:p>
- </xsl:template>
- <xsl:template match="*[contains(@class,' topic/colspec ')]"/>
- <xsl:template match="*[contains(@class,' topic/spanspec ')]"/>
- <xsl:template match="*[contains(@class,' topic/thead ')]" name="topic.thead">
- <xsl:apply-templates/>
- </xsl:template>
- <xsl:template match="*[contains(@class,' topic/tfoot ')]"/>
- <xsl:template match="*[contains(@class,' topic/tbody ')]" name="topic.tbody">
- <xsl:apply-templates/>
- <!-- process table footer -->
- <xsl:apply-templates select="../*[contains(@class,' topic/tfoot ')]" mode="gen-tfoot"/>
- </xsl:template>
- <!-- special mode for table footers -->
- <xsl:template match="*[contains(@class,' topic/tfoot ')]" mode="gen-tfoot">
- <xsl:apply-templates/>
- </xsl:template>
- <xsl:template match="*[contains(@class,' topic/row ')]" name="topic.row">
-
- <xsl:choose>
- <xsl:when test="parent::*[contains(@class,' topic/thead ')]">
- <table:table-header-rows>
- <table:table-row>
- <xsl:apply-templates select="*[contains(@class,' topic/entry ')][1]"/>
- </table:table-row>
- </table:table-header-rows>
- </xsl:when>
- <xsl:otherwise>
- <table:table-row>
- <xsl:apply-templates select="*[contains(@class,' topic/entry ')][1]"/>
- </table:table-row>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="count-colmax">
- <xsl:choose>
- <xsl:when test="../../../*[contains(@class,' topic/colspec ')]">
- <xsl:value-of select="number(count(../../../*[contains(@class,' topic/colspec ')]))"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="number(count(../../*[contains(@class,' topic/row ')][1]/*[contains(@class,' topic/entry ')]))"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="*[contains(@class,' topic/entry ')]" name="topic.entry">
- <xsl:param name="currentpos" select="1"/>
- <xsl:variable name="rowspan">
- <xsl:call-template name="get-rows-span"/>
- </xsl:variable>
- <xsl:variable name="col-max-num">
- <xsl:call-template name="count-colmax"/>
- </xsl:variable>
- <xsl:variable name="startpos">
- <xsl:call-template name="find-entry-start-position"/>
- </xsl:variable>
- <xsl:variable name="endpos">
- <xsl:call-template name="find-entry-end-position">
- <xsl:with-param name="startposition" select="$startpos"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:if test="$startpos > $currentpos">
- <!-- render col/row spanned cell.-->
- <xsl:call-template name="emit-empty-cell">
- <xsl:with-param name="startpos" select="$startpos"/>
- <xsl:with-param name="currentpos" select="$currentpos"/>
- </xsl:call-template>
- </xsl:if>
- <!-- finding colspan -->
- <xsl:variable name="colspan">
- <xsl:call-template name="find-colspan"/>
- </xsl:variable>
- <!--
- <xsl:choose>
- <xsl:when test="parent::*/parent::*[contains(@class,' topic/thead ')]">
- <xsl:call-template name="topic.thead_entry"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="topic.tbody_entry"/>
- </xsl:otherwise>
- </xsl:choose>
- -->
- <table:table-cell office:value-type="string">
- <xsl:if test="$colspan > 1">
- <xsl:attribute name="table:number-columns-spanned">
- <xsl:value-of select="$colspan"/>
- </xsl:attribute>
- </xsl:if>
-
- <xsl:if test="$rowspan > 1">
- <xsl:attribute name="table:number-rows-spanned">
- <xsl:value-of select="$rowspan"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:call-template name="create_style_table"/>
-
- <text:p text:style-name="indent_paragraph_style">
- <xsl:apply-templates/>
- </text:p>
-
- </table:table-cell>
- <!-- render col spanned cell.-->
- <!--
- <xsl:call-template name="emit-empty-cell-for-colspan">
- <xsl:with-param name="span" select="$colspan"/>
- </xsl:call-template>
- -->
- <xsl:if test="following-sibling::*[contains(@class,' topic/entry ')]">
- <xsl:apply-templates select="following-sibling::*[contains(@class,' topic/entry ')][1]">
- <xsl:with-param name="currentpos" select="$endpos + 1"/>
- </xsl:apply-templates>
- </xsl:if>
- <xsl:if test="not(following-sibling::*[contains(@class,' topic/entry ')]) and not(($endpos + 1) > $col-max-num)">
- <!-- if this is the last entry in current row and next position is not greater than the number of columns in a row-->
- <xsl:call-template name="emit-empty-cell">
- <xsl:with-param name="startpos" select="$col-max-num + 1"/> <!-- make sure the remaining columns will be generated -->
- <xsl:with-param name="currentpos" select="$endpos + 1"/>
- </xsl:call-template>
- </xsl:if>
- <!-- get text node -->
-
- </xsl:template>
- <!-- create style for table
- for simpletable refer create_style_stable template
- -->
- <xsl:template name="create_style_table">
- <!-- create style attribute -->
- <xsl:variable name="colpos" select="number(substring-after(@colname, 'col'))"/>
- <xsl:variable name="rowpos">
- <xsl:choose>
- <!-- row belongs to thead -->
- <xsl:when test="parent::*[contains(@class, ' topic/row ')]
- /parent::*[contains(@class, ' topic/thead ')]">
- <xsl:value-of select="1"/>
- </xsl:when>
- <!-- there's no thead -->
- <xsl:when test="not(parent::*[contains(@class, ' topic/row ')]
- /parent::*[contains(@class, ' topic/tbody ')]
- /preceding-sibling::*[contains(@class, ' topic/thead ')])">
- <xsl:value-of select="count(parent::*[contains(@class, ' topic/row ')]/
- preceding-sibling::*[contains(@class, ' topic/row ')]) + 1"/>
- </xsl:when>
- <!-- there is thead and row belongs to tbody -->
- <xsl:when test="parent::*[contains(@class, ' topic/row ')]
- /parent::*[contains(@class, ' topic/tbody ')]
- /preceding-sibling::*[contains(@class, ' topic/thead ')]">
- <xsl:value-of select="2"/>
- </xsl:when>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:choose>
- <!-- first cell in the first row -->
- <xsl:when test="$rowpos = 1 and $colpos = 1 ">
- <xsl:attribute name="table:style-name">cell_style_1</xsl:attribute>
- </xsl:when>
- <!-- not first cell but in the first row -->
- <xsl:when test="$rowpos = 1 and $colpos != 1 ">
- <xsl:attribute name="table:style-name">cell_style_2</xsl:attribute>
- </xsl:when>
- <!-- first cell but not in the first row -->
- <xsl:when test="$rowpos != 1 and $colpos = 1 ">
- <xsl:attribute name="table:style-name">cell_style_3</xsl:attribute>
- </xsl:when>
- <!-- other cells -->
- <xsl:otherwise>
- <xsl:attribute name="table:style-name">cell_style_4</xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!-- do header entries -->
- <xsl:template name="topic.thead_entry">
- <xsl:call-template name="doentry"/>
- </xsl:template>
- <!-- do body entries -->
- <xsl:template name="topic.tbody_entry">
- <xsl:call-template name="doentry"/>
- </xsl:template>
- <xsl:template name="doentry">
- <!--xsl:variable name="colspan-num">
- <xsl:call-template name="find-colspan"></xsl:call-template>
- </xsl:variable>
- <xsl:variable name="empty-cell-num" select="$colspan-num - 1"/-->
- <xsl:apply-templates/>
- <!--xsl:call-template name="emit-empty-cell">
- <xsl:with-param name="num" select="$empty-cell-num"/>
- </xsl:call-template-->
- </xsl:template>
- <xsl:template match="*[contains(@class,' topic/colspec ')]" mode="count-rowwidth">
- <xsl:param name="totalwidth">0</xsl:param> <!-- Total counted width so far -->
- <xsl:variable name="thiswidth"> <!-- Width of this column -->
- <xsl:choose>
- <xsl:when test="@colwidth and contains(@colwidth,'*') and not(@colwidth='*')"><xsl:value-of select="substring-before(@colwidth,'*')"/></xsl:when>
- <xsl:otherwise>1</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <!-- If there are more colspecs, continue, otherwise return the current count -->
- <xsl:choose>
- <xsl:when test="following-sibling::*[contains(@class,' topic/colspec ')]">
- <xsl:apply-templates select="following-sibling::*[contains(@class,' topic/colspec ')][1]" mode="count-rowwidth">
- <xsl:with-param name="totalwidth" select="$totalwidth + $thiswidth"/>
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="$totalwidth + $thiswidth"/></xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!-- Find the starting column of an entry in a row. -->
- <xsl:template name="find-entry-start-position">
- <xsl:choose>
- <!-- if the column number is specified, use it -->
- <xsl:when test="@colnum">
- <xsl:value-of select="@colnum"/>
- </xsl:when>
- <xsl:when test="not(../../../*[contains(@class,' topic/colspec ')])">
- <xsl:variable name="prev-sib" select="count(preceding-sibling::*)"/>
- <xsl:value-of select="$prev-sib+1"/>
- </xsl:when>
- <!-- If there is a defined column name, check the colspans to determine position -->
- <xsl:when test="@colname">
- <!-- count the number of colspans before the one this entry references, plus one -->
- <xsl:value-of select="number(count(../../../*[contains(@class,' topic/colspec ')][@colname=current()/@colname]/preceding-sibling::*[contains(@class, ' topic/colspec ')])+1)"/>
- </xsl:when>
- <!-- If the starting column is defined, check colspans to determine position -->
- <xsl:when test="@namest">
- <xsl:value-of select="number(count(../../../*[contains(@class,' topic/colspec ')][@colname=current()/@namest]/preceding-sibling::*[contains(@class, ' topic/colspec ')])+1)"/>
- </xsl:when>
- <!-- Need a test for spanspec -->
- <xsl:when test="@spanname">
- <xsl:variable name="startspan"> <!-- starting column for this span -->
- <xsl:value-of select="../../../*[contains(@class,' topic/spanspec ')][@spanname=current()/@spanname]/@namest"/>
- </xsl:variable>
- <xsl:value-of select="number(count(../../../*[contains(@class,' topic/colspec ')][@colname=$startspan]/preceding-sibling::*[contains(@class, ' topic/colspec ')])+1)"/>
- </xsl:when>
- <!-- Otherwise, just use the count of cells in this row -->
- <xsl:otherwise>
- <xsl:variable name="prev-sib" select="count(preceding-sibling::*)"/>
- <xsl:value-of select="$prev-sib+1"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!-- Find the end column of a cell. If the cell does not span any columns,
- the end position is the same as the start position. -->
- <xsl:template name="find-entry-end-position">
- <xsl:param name="startposition" select="0"/>
- <xsl:choose>
- <xsl:when test="not(../../../*[contains(@class,' topic/colspec ')])">
- <xsl:value-of select="$startposition"/>
- </xsl:when>
- <xsl:when test="@nameend">
- <xsl:value-of select="number(count(../../../*[contains(@class,' topic/colspec ')][@colname=current()/@nameend]/preceding-sibling::*[contains(@class, ' topic/colspec ')])+1)"/>
- </xsl:when>
- <xsl:when test="@spanname">
- <xsl:variable name="endspan"> <!-- starting column for this span -->
- <xsl:value-of select="../../../*[contains(@class,' topic/spanspec ')][@spanname=current()/@spanname]/@nameend"/>
- </xsl:variable>
- <xsl:value-of select="number(count(../../../*[contains(@class,' topic/colspec ')][@colname=$endspan]/preceding-sibling::*[contains(@class, ' topic/colspec ')])+1)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$startposition"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!-- Find the number of column spans between name-start and name-end attrs -->
- <xsl:template name="find-colspan">
- <xsl:variable name="startpos">
- <xsl:call-template name="find-entry-start-position"/>
- </xsl:variable>
- <xsl:variable name="endpos">
- <xsl:call-template name="find-entry-end-position">
- <xsl:with-param name="startposition" select="$startpos"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:value-of select="$endpos - $startpos + 1"/>
- </xsl:template>
- <xsl:template name="find-spanspec-colspan">
- <xsl:variable name="spanname" select="@spanname"/>
- <xsl:variable name="startcolname" select="../../../*[contains(@class,' topic/spanspec ')][@spanname=$spanname][1]/@namest"/>
- <xsl:variable name="endcolname" select="../../../*[contains(@class,' topic/spanspec ')][@spanname=$spanname][1]/@nameend"/>
- <xsl:variable name="startpos" select="number(count(../../../*[contains(@class,' topic/colspec ')][@colname=$startcolname]/preceding-sibling::*[contains(@class, ' topic/colspec ')])+1)"/>
- <xsl:variable name="endpos" select="number(count(../../../*[contains(@class,' topic/colspec ')][@colname=$endcolname]/preceding-sibling::*[contains(@class, ' topic/colspec ')])+1)"/>
- <xsl:value-of select="$endpos - $startpos + 1"/>
- </xsl:template>
- <xsl:template name="emit-empty-cell">
- <xsl:param name="currentpos" select="1"/>
- <xsl:param name="startpos" select="1"/>
- <xsl:if test="$startpos > $currentpos">
- <xsl:variable name="colspan">
- <xsl:apply-templates select="../preceding-sibling::*[*[contains(@class,' topic/entry ')][@morerows][@colnum=$currentpos or @colname=concat('col',$currentpos) or @namest=concat('col',$currentpos)]][1]/*[contains(@class,' topic/entry ')][@morerows][@colnum=$currentpos or @colname=concat('col',$currentpos) or @namest=concat('col',$currentpos)]" mode="find-colspan"/>
- </xsl:variable>
- <table:covered-table-cell/>
- <xsl:if test="not($colspan='') and ($startpos > ($currentpos + $colspan))">
- <xsl:call-template name="emit-empty-cell">
- <xsl:with-param name="startpos" select="$startpos"/>
- <xsl:with-param name="currentpos" select="$currentpos + $colspan"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:if>
- </xsl:template>
-
- <!--
- <xsl:template name="emit-empty-cell-for-colspan">
- <xsl:param name="span" select="0"/>
- <xsl:if test="$span > 1">
- <table:covered-table-cell/>
- <xsl:call-template name="emit-empty-cell-for-colspan">
- <xsl:with-param name="span" select="$span - 1"></xsl:with-param>
- </xsl:call-template>
- </xsl:if>
- </xsl:template>
- -->
-
- <xsl:template name="get-rows-span">
- <xsl:choose>
- <xsl:when test="@morerows">
- <xsl:value-of select="number(@morerows + 1)"/>
- </xsl:when>
- <xsl:otherwise>1</xsl:otherwise>
- </xsl:choose>
-
- </xsl:template>
-
- <xsl:template match="*[contains(@class,' topic/entry ')]" mode="find-colspan">
- <xsl:call-template name="find-colspan"/>
- </xsl:template>
-
- <xsl:template match="*[contains(@class,' topic/colspec ')]" mode="count-colwidth">
- <xsl:param name="colnum" select="1"/>
- <xsl:param name="span-width" select="0"/>
- <xsl:variable name="width">
- <xsl:choose>
- <xsl:when test="@colwidth and not(@colwidth='' or @colwidth='*')">
- <xsl:value-of select="substring-before(@colwidth,'*')"/>
- </xsl:when>
- <xsl:otherwise>1</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="$colnum > 1">
- <xsl:apply-templates select="following-sibling::*[1]" mode="count-colwidth">
- <xsl:with-param name="colnum" select="$colnum - 1"/>
- <xsl:with-param name="span-width" select="$span-width + $width"/>
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="$span-width + $width"/></xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <!--xsl:template name="count-colwidth">
- <xsl:param name="colnum" select="1"/>
- <xsl:param name="span-width" select="0"/>
- <xsl:variable name="width">
- <xsl:choose>
- <xsl:when test="@colwidth and not(@colwidth='')">
- <xsl:value-of select="substring-before(@colwidth,'*')"/>
- </xsl:when>
- <xsl:otherwise>1</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="$colnum > 1">
- <xsl:call-template name="count-colwidth">
- <xsl:with-param name="colnum" select="$colnum - 1"/>
- <xsl:with-param name="span-width" select="$span-width + $width"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="$span-width + $width"/></xsl:otherwise>
- </xsl:choose>
- </xsl:template-->
- <!-- Simple Table -->
- <xsl:template match="*[contains(@class,' topic/simpletable ')]" name="topic.simpletable">
-
- <!-- render stable -->
- <xsl:call-template name="render_simpletable"/>
-
- </xsl:template>
- <xsl:template name="create_simpletable">
- <xsl:variable name="tablenameId" select="generate-id(.)"/>
-
- <!-- start flagging -->
- <xsl:apply-templates select="." mode="start-add-odt-flags">
- <xsl:with-param name="family" select="'_table'"/>
- </xsl:apply-templates>
-
- <table:table table:name="{concat('Table', $tablenameId)}">
- <!-- table background flagging -->
- <xsl:apply-templates select="." mode="start-add-odt-flags">
- <xsl:with-param name="family" select="'_table_attr'"/>
- </xsl:apply-templates>
- <xsl:variable name="colnumNum">
- <xsl:call-template name="count_columns_for_simpletable"/>
- </xsl:variable>
- <xsl:call-template name="create_columns_for_simpletable">
- <xsl:with-param name="column" select="$colnumNum"/>
- </xsl:call-template>
- <xsl:call-template name="dotable"/>
- </table:table>
- <!-- end flagging -->
- <xsl:apply-templates select="." mode="end-add-odt-flags">
- <xsl:with-param name="family" select="'_table'"/>
- </xsl:apply-templates>
-
- </xsl:template>
- <xsl:template name="count_columns_for_simpletable">
- <xsl:choose>
- <xsl:when test="child::*[contains(@class, ' topic/sthead ')]">
- <xsl:value-of select="count(child::*[contains(@class, ' topic/sthead ')][1]
- /child::*[contains(@class, ' topic/stentry ')])"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="count(child::*[contains(@class, ' topic/strow ')][1]
- /child::*[contains(@class, ' topic/stentry ')])"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="create_columns_for_simpletable">
- <xsl:param name="column" select="0"/>
- <xsl:if test="$column > 0">
- <table:table-column/>
- <xsl:call-template name="create_columns_for_simpletable">
- <xsl:with-param name="column" select="$column - 1"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:template>
- <xsl:template match="*[contains(@class,' topic/simpletable ')]/*[contains(@class,' topic/title ')]">
- <xsl:variable name="ancestorlang">
- <xsl:call-template name="getLowerCaseLang"/>
- </xsl:variable>
- <xsl:variable name="tbl-count-actual" select="count(preceding::*[contains(@class,' topic/table ')
- or contains(@class,' topic/simpletable ')]/*[contains(@class,' topic/title ')])+1"/>
- <text:p text:style-name="bold">
- <xsl:choose>
- <!-- Hungarian: "1.Table " -->
- <xsl:when test="( (string-length($ancestorlang)=5 and contains($ancestorlang,'hu-hu')) or (string-length($ancestorlang)=2 and contains($ancestorlang,'hu')) )">
- <xsl:value-of select="$tbl-count-actual"/><xsl:text>. </xsl:text>
- <xsl:call-template name="getVariable">
- <xsl:with-param name="id" select="'Table'"/>
- </xsl:call-template><xsl:text>
- </xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="getVariable">
- <xsl:with-param name="id" select="'Table'"/>
- </xsl:call-template>
- <xsl:text> </xsl:text>
- <xsl:value-of select="$tbl-count-actual"/>
- <xsl:text>. </xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:value-of select="."/>
- </text:p>
- </xsl:template>
- <xsl:template match="*[contains(@class,' topic/sthead ')]">
- <table:table-header-rows>
- <table:table-row>
- <xsl:apply-templates mode="emit-cell-style"/>
- </table:table-row>
- </table:table-header-rows>
- </xsl:template>
-
- <xsl:template match="*[contains(@class,' topic/strow ')]">
- <table:table-row>
- <xsl:apply-templates mode="emit-cell-style"/>
- </table:table-row>
- </xsl:template>
- <xsl:template match="*[contains(@class,' topic/stentry ')]" mode="emit-cell-style">
- <xsl:variable name="totalcols" select="count(../*[contains(@class,' topic/stentry ')])">
- <!--xsl:apply-templates select="../*[contains(@class,' topic/stentry ')][1]" mode="count-rowwidth"/-->
- </xsl:variable>
- <!--
- <xsl:variable name="thiswidth-twips" select="$table-row-width div $totalcols"/>
- <xsl:value-of select="$valign"/>
- -->
- <table:table-cell office:value-type="string">
- <xsl:call-template name="create_style_stable"/>
-
- <text:p text:style-name="indent_paragraph_style">
- <xsl:apply-templates/>
- </text:p>
- </table:table-cell>
- </xsl:template>
-
- <xsl:template match="text()" mode="tags_in_sthead">
- <text:span text:style-name="bold">
- <xsl:apply-templates select="."/>
- </text:span>
- </xsl:template>
-
- <xsl:template match="*" mode="tags_in_sthead">
- <xsl:apply-templates select="."/>
- </xsl:template>
-
-
- <xsl:template name="create_style_stable">
- <!-- create style attribute -->
- <xsl:variable name="colpos" select="position()"/>
-
- <xsl:variable name="rowpos">
- <xsl:choose>
- <!-- row belongs to thead -->
- <xsl:when test="parent::*[contains(@class, ' topic/sthead ')]">
- <xsl:value-of select="1"/>
- </xsl:when>
- <!-- there's no thead -->
- <xsl:when test="not(parent::*[contains(@class, ' topic/strow ')]
- /preceding-sibling::*[contains(@class, ' topic/sthead ')])">
- <xsl:value-of select="count(parent::*[contains(@class, ' topic/strow ')]/
- preceding-sibling::*[contains(@class, ' topic/strow ')]) + 1"/>
- </xsl:when>
- <!-- there is thead and row belongs to tbody -->
- <xsl:when test="parent::*[contains(@class, ' topic/strow ')]
- /preceding-sibling::*[contains(@class, ' topic/sthead ')]">
- <xsl:value-of select="2"/>
- </xsl:when>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:choose>
- <!-- first column and first row -->
- <xsl:when test="$rowpos = 1 and $colpos = 1 ">
- <xsl:attribute name="table:style-name">cell_style_1</xsl:attribute>
- </xsl:when>
- <!-- not first column but first row -->
- <xsl:when test="$rowpos = 1 and $colpos != 1 ">
- <xsl:attribute name="table:style-name">cell_style_2</xsl:attribute>
- </xsl:when>
- <!-- first column but not first row -->
- <xsl:when test="$rowpos != 1 and $colpos = 1 ">
- <xsl:attribute name="table:style-name">cell_style_3</xsl:attribute>
- </xsl:when>
- <!-- other cells -->
- <xsl:otherwise>
- <xsl:attribute name="table:style-name">cell_style_4</xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="*[contains(@class,' topic/stentry ')]" mode="count-rowwidth">
- <xsl:param name="totalcols">0</xsl:param> <!-- Total counted columns so far -->
- <xsl:choose>
- <xsl:when test="following-sibling::*[contains(@class,' topic/stentry ')]">
- <xsl:apply-templates select="following-sibling::*[contains(@class,' topic/stentry ')][1]" mode="count-rowwidth">
- <xsl:with-param name="totalwidth" select="$totalcols + 1"/>
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="$totalcols + 1"/></xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="output-stentry-id">
- <!-- Find the position in this row -->
- <xsl:variable name="thiscolnum"><xsl:number level="single" count="*"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="@id"> <!-- If ID is specified, always use it -->
- <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
- </xsl:when>
- <!-- If no ID is specified, and this is a header cell, generate an ID -->
- <xsl:when test="parent::*[contains(@class,' topic/sthead ')] or
- (parent::*/parent::*/@keycol and number(parent::*/parent::*/@keycol)=number($thiscolnum))">
- <xsl:attribute name="id"><xsl:value-of select="generate-id(.)"/></xsl:attribute>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="create_table_cell_styles">
- <!-- for normal table -->
- <style:style style:name="cell_style_1" style:family="table-cell">
- <style:table-cell-properties fo:padding="0.0201in" fo:border="0.0007in solid #000000"/>
- </style:style>
- <style:style style:name="cell_style_2" style:family="table-cell">
- <style:table-cell-properties fo:padding="0.0201in" fo:border-left="none"
- fo:border-right="0.0007in solid #000000" fo:border-top="0.0007in solid #000000"
- fo:border-bottom="0.0007in solid #000000" />
- </style:style>
- <style:style style:name="cell_style_3" style:family="table-cell">
- <style:table-cell-properties fo:padding="0.0201in"
- fo:border-right="0.0007in solid #000000" fo:border-left="0.0007in solid #000000" fo:border-top="none"
- fo:border-bottom="0.0007in solid #000000"/>
- </style:style>
- <style:style style:name="cell_style_4" style:family="table-cell">
- <style:table-cell-properties fo:padding="0.0201in"
- fo:border-right="0.0007in solid #000000" fo:border-bottom="0.0007in solid #000000"
- fo:border-top="none" fo:border-left="none"/>
- </style:style>
-
- <!-- for task choice table without head, it is simple.-->
- <style:style style:name="cell_style_1_task" style:family="table-cell">
- <style:table-cell-properties fo:padding="0.0201in" fo:border-left="0.0007in solid #000000"
- fo:border-right="0.0007in solid #000000" fo:border-top="0.0007in solid #000000"
- fo:border-bottom="none" />
- </style:style>
- <style:style style:name="cell_style_2_task" style:family="table-cell">
- <style:table-cell-properties fo:padding="0.0201in" fo:border-left="none"
- fo:border-right="0.0007in solid #000000" fo:border-top="0.0007in solid #000000"
- fo:border-bottom="none"/>
- </style:style>
- </xsl:template>
- </xsl:stylesheet>
|