123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: CCS
- (c) Copyright IBM Corp. 2005, 2010
- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- -->
- <xsl:stylesheet version="1.0" xmlns:ldx="http://developer.cognos.com/schemas/rds/contentmodel/1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
- <xsl:output method="xml" omit-xml-declaration="yes" encoding="UTF-8" version="1.0"/>
- <xsl:variable name="gateway">http://localhost:80/cognos8/cgi-bin/cognos.cgi/</xsl:variable>
- <xsl:template match="/">
- <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
- <fo:layout-master-set>
- <fo:simple-page-master page-height="11in" page-width="8.5in"
- margin="5mm 25mm 5mm 25mm" master-name="A4">
- <fo:region-body margin="20mm 0mm 20mm 0mm"/>
- </fo:simple-page-master>
- </fo:layout-master-set>
-
- <fo:page-sequence master-reference="A4">
- <fo:flow flow-name="xsl-region-body">
- <fo:block>
- <xsl:apply-templates select="//ldx:document/ldx:page"/>
- <xsl:apply-templates select="//ldx:filterResultSet/ldx:filterResult/ldx:reportElement/*"/>
- </fo:block>
- </fo:flow>
- </fo:page-sequence>
- </fo:root>
- </xsl:template>
- <xsl:template match="ldx:page">
- <fo:block-container overflow="hidden">
- <xsl:attribute name="id"><xsl:value-of select="ldx:id"/></xsl:attribute>
- <fo:block>
- <xsl:apply-templates select="ldx:header/*"/>
- </fo:block>
- <fo:block>
- <xsl:apply-templates select="ldx:body/*"/>
- </fo:block>
- <fo:block>
- <xsl:apply-templates select="ldx:footer/*"/>
- </fo:block>
- </fo:block-container>
- </xsl:template>
- <xsl:template match="ldx:item">
- <xsl:for-each select="*">
- <xsl:call-template name="item"/>
- </xsl:for-each>
- </xsl:template>
- <xsl:template name="item">
- <xsl:variable name="bookmark" select="ldx:drills/ldx:drill/ldx:bookmark"/>
- <xsl:choose>
- <xsl:when test="$bookmark">
- <fo:basic-link>
- <xsl:attribute name="internal-destination"><xsl:value-of select="$bookmark"/></xsl:attribute>
- <xsl:apply-templates select="."/>
- </fo:basic-link>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select="."/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="ldx:txt">
- <xsl:variable name="txtClass">
- <xsl:value-of select="ldx:style"/>
- </xsl:variable>
- <fo:inline>
- <xsl:for-each select="/ldx:document/ldx:styleGroup[ldx:name=$txtClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:for-each select="/ldx:filterResultSet/ldx:styleGroup[ldx:name=$txtClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:attribute name="id"><xsl:value-of select="ldx:id"/></xsl:attribute>
- <xsl:choose>
- <xsl:when test="ldx:fmtVal">
- <xsl:variable name="newText">
- <xsl:call-template name="replace-string">
- <xsl:with-param name="text" select="ldx:fmtVal"/>
- <xsl:with-param name="from" select="'('"/>
- <xsl:with-param name="to" select="' ('"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:value-of select="$newText"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="newText">
- <xsl:call-template name="replace-string">
- <xsl:with-param name="text" select="ldx:val"/>
- <xsl:with-param name="from" select="'('"/>
- <xsl:with-param name="to" select="'​('"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:value-of select="$newText"/>
- </xsl:otherwise>
- </xsl:choose>
- </fo:inline>
- </xsl:template>
- <xsl:template name="replace-string">
- <xsl:param name="text"/>
- <xsl:param name="from"/>
- <xsl:param name="to"/>
- <xsl:choose>
- <xsl:when test="contains($text, $from)">
- <xsl:variable name="before" select="substring-before($text, $from)"/>
- <xsl:variable name="after" select="substring-after($text, $from)"/>
- <xsl:variable name="prefix" select="concat($before, $to)"/>
-
- <xsl:value-of select="$before"/>
- <xsl:value-of select="$to"/>
- <xsl:call-template name="replace-string">
- <xsl:with-param name="text" select="$after"/>
- <xsl:with-param name="from" select="$from"/>
- <xsl:with-param name="to" select="$to"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$text"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!-- <xsl:template name="textFormatter">
- <xsl:param name="breakText"/>
- <xsl:if test="string-length($breakText)">
- <xsl:value-of select="substring($breakText,1,3)"/>
- <xsl:call-template name="textFormatter">
- <xsl:with-param name="breakText" select="substring($breakText,4)"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:template> -->
- <xsl:template match="ldx:img">
- <fo:inline>
- <fo:external-graphic>
- <xsl:attribute name="src">
- <xsl:if test="not(contains(ldx:url, 'http'))">
- <xsl:value-of select="$gateway"/>
- </xsl:if>
- <xsl:if test="substring(ldx:url,1,3)='../' or substring(ldx:url,1,3)='..\'"><xsl:text>..\</xsl:text></xsl:if>
- <xsl:value-of select="ldx:url"/>
- </xsl:attribute>
- </fo:external-graphic>
- </fo:inline>
- </xsl:template>
- <xsl:template match="ldx:cht">
- <fo:inline>
- <fo:external-graphic>
- <xsl:attribute name="id"><xsl:value-of select="ldx:id"/></xsl:attribute>
- <xsl:attribute name="src"><xsl:if test="not(contains(ldx:url, 'http'))"><xsl:value-of select="$gateway"/></xsl:if><xsl:value-of select="ldx:url"/>
- </xsl:attribute>
- </fo:external-graphic>
- </fo:inline>
- </xsl:template>
- <xsl:template match="ldx:html"/>
- <xsl:template match="ldx:hlink">
- <fo:basic-link>
- <xsl:attribute name="external-destination">
- <xsl:value-of select="ldx:target"/>
- </xsl:attribute>
- <xsl:apply-templates select="ldx:contents/*"/>
- </fo:basic-link>
- </xsl:template>
- <xsl:template match="ldx:bmrk">
- <fo:block>
- <xsl:attribute name="id"><xsl:value-of select="ldx:label"/></xsl:attribute>
- </fo:block>
- </xsl:template>
- <xsl:template match="ldx:rept">
- <xsl:variable name="reptClass">
- <xsl:value-of select="ldx:style"/>
- </xsl:variable>
- <fo:block>
- <xsl:for-each select="/ldx:document/ldx:styleGroup[ldx:name=$reptClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:for-each select="/ldx:filterResultSet/ldx:styleGroup[ldx:name=$reptClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:attribute name="id"><xsl:value-of select="ldx:id"/></xsl:attribute>
- <xsl:apply-templates select="ldx:item"/>
- </fo:block>
- </xsl:template>
- <xsl:template match="ldx:reptbl">
- <xsl:variable name="reptblClass">
- <xsl:value-of select="ldx:style"/>
- </xsl:variable>
- <fo:table fox:widow-content-limit="6 * 1.2em" table-layout="fixed" width="100%">
- <xsl:attribute name="padding">0</xsl:attribute>
- <xsl:attribute name="border">0</xsl:attribute>
- <xsl:attribute name="id"><xsl:value-of select="ldx:id"/></xsl:attribute>
- <xsl:attribute name="border-collapse">collapse</xsl:attribute>
- <xsl:for-each select="/ldx:document/ldx:styleGroup[ldx:name=$reptblClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:for-each select="/ldx:filterResultSet/ldx:styleGroup[ldx:name=$reptblClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:for-each select="ldx:row[0]/ldx:cell">
- <fo:table-column column-width="proportional-column-width(1)"/>
- </xsl:for-each>
- <fo:table-body>
- <xsl:for-each select="ldx:row">
- <fo:table-row>
- <xsl:apply-templates select="ldx:cell"/>
- </fo:table-row>
- </xsl:for-each>
- </fo:table-body>
- </fo:table>
- </xsl:template>
- <xsl:template match="ldx:rtxt">
- <xsl:call-template name="RichTextItem"/>
- </xsl:template>
- <xsl:template name="RichTextItem">
- <xsl:for-each select="ldx:item">
- <xsl:call-template name="RichTextItem"/>
- </xsl:for-each>
- <xsl:apply-templates select="ldx:div|ldx:span|ldx:txt|ldx:rtList"/>
- </xsl:template>
- <xsl:template match="ldx:div">
- <xsl:variable name="divClass">
- <xsl:value-of select="ldx:style"/>
- </xsl:variable>
- <fo:block>
- <xsl:for-each select="/ldx:document/ldx:styleGroup[ldx:name=$divClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:for-each select="/ldx:filterResultSet/ldx:styleGroup[ldx:name=$divClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:for-each select="ldx:item">
- <xsl:call-template name="RichTextItem"/>
- </xsl:for-each>
- </fo:block>
- </xsl:template>
- <xsl:template match="ldx:span">
- <xsl:variable name="spanClass">
- <xsl:value-of select="ldx:style"/>
- </xsl:variable>
- <fo:block>
- <fo:inline>
- <xsl:for-each select="/ldx:document/ldx:styleGroup[ldx:name=$spanClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:for-each select="/ldx:filterResultSet/ldx:styleGroup[ldx:name=$spanClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:for-each select="ldx:item">
- <xsl:call-template name="RichTextItem"/>
- </xsl:for-each>
- </fo:inline>
- </fo:block>
- </xsl:template>
- <xsl:template match="ldx:rtList">
- <xsl:variable name="rtListClass">
- <xsl:value-of select="ldx:style"/>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="ldx:ordered = 'true'">
- <fo:list-block provisional-distance-between-starts="1cm" provisional-label-separation="0.5">
- <xsl:attribute name="space-after">
- <xsl:choose>
- <xsl:when test="ancestor::ldx:rtList"><xsl:text>0pt</xsl:text></xsl:when>
- <xsl:otherwise><xsl:text>12pt</xsl:text></xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <xsl:attribute name="start-indent">
- <xsl:variable name="nested">
- <xsl:choose>
- <xsl:when test="count(ancestor::ldx:rtList)">
- <xsl:value-of select="1 + (count(ancestor::ldx:rtList)) * 1.25"/>
- </xsl:when>
- <xsl:otherwise><xsl:text>1</xsl:text></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:value-of select="concat($nested, 'cm')"/>
- </xsl:attribute>
- <xsl:for-each select="/ldx:document/ldx:styleGroup[ldx:name=$rtListClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:for-each select="/ldx:filterResultSet/ldx:styleGroup[ldx:name=$rtListClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:for-each select="ldx:listItem">
- <fo:list-item>
- <fo:list-item-label end-indent="label-end()">
- <fo:block>
- <xsl:variable name="label-num"><xsl:number value="position()"/></xsl:variable>
- <xsl:number value="$label-num" format="1. "/>
- </fo:block>
- </fo:list-item-label>
- <fo:list-item-body start-indent="body-start()">
- <fo:block>
- <xsl:call-template name="RichTextItem"/>
- </fo:block>
- </fo:list-item-body>
- </fo:list-item>
- </xsl:for-each>
- </fo:list-block>
- </xsl:when>
- <xsl:otherwise>
- <fo:list-block provisional-distance-between-starts="1cm" provisional-label-separation="0.5">
- <xsl:attribute name="space-after">
- <xsl:choose>
- <xsl:when test="ancestor::ldx:rtList"><xsl:text>0pt</xsl:text></xsl:when>
- <xsl:otherwise><xsl:text>12pt</xsl:text></xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <xsl:attribute name="start-indent">
- <xsl:variable name="nested">
- <xsl:choose>
- <xsl:when test="count(ancestor::ldx:rtList)">
- <xsl:value-of select="1 + (count(ancestor::ldx:rtList)) * 1.25"/>
- </xsl:when>
- <xsl:otherwise><xsl:text>1</xsl:text></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:value-of select="concat($nested, 'cm')"/>
- </xsl:attribute>
- <xsl:for-each select="/ldx:document/ldx:styleGroup[ldx:name=$rtListClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:for-each select="/ldx:filterResultSet/ldx:styleGroup[ldx:name=$rtListClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:for-each select="ldx:listItem">
- <fo:list-item>
- <fo:list-item-body start-indent="body-start()">
- <fo:block>
- <xsl:call-template name="RichTextItem"/>
- </fo:block>
- </fo:list-item-body>
- </fo:list-item>
- </xsl:for-each>
- </fo:list-block>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="ldx:lcr">
- <xsl:apply-templates select="ldx:item"/>
- </xsl:template>
- <xsl:template match="ldx:lst">
- <xsl:variable name="lstClass">
- <xsl:value-of select="ldx:style"/>
- </xsl:variable>
- <fo:table fox:widow-content-limit="6 * 1.2em" table-layout="fixed" width="100%">
- <xsl:attribute name="padding">0</xsl:attribute>
- <xsl:attribute name="border">0</xsl:attribute>
- <xsl:attribute name="border-collapse">collapse</xsl:attribute>
- <xsl:for-each select="/ldx:document/ldx:styleGroup[ldx:name=$lstClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:for-each select="/ldx:filterResultSet/ldx:styleGroup[ldx:name=$lstClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:for-each select="ldx:colTitle">
- <xsl:call-template name="createColumns"/>
- </xsl:for-each>
- <fo:table-body>
- <xsl:if test="ldx:colTitle">
- <fo:table-row>
- <xsl:apply-templates select="ldx:colTitle"/>
- </fo:table-row>
- </xsl:if>
- <xsl:apply-templates select="ldx:group"/>
- </fo:table-body>
- </fo:table>
- </xsl:template>
- <xsl:template match="ldx:colTitle">
- <xsl:variable name="colTitleClass">
- <xsl:value-of select="ldx:style"/>
- </xsl:variable>
- <fo:table-cell>
- <xsl:for-each select="/ldx:document/ldx:styleGroup[ldx:name=$colTitleClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:for-each select="/ldx:filterResultSet/ldx:styleGroup[ldx:name=$colTitleClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <fo:block-container overflow="hidden">
- <fo:block>
- <xsl:apply-templates select="ldx:item"/>
- </fo:block>
- </fo:block-container>
- </fo:table-cell>
- </xsl:template>
- <xsl:template match="ldx:grp | ldx:group">
- <xsl:apply-templates select="*"/>
- </xsl:template>
- <xsl:template match="ldx:header | ldx:footer">
- <xsl:apply-templates select="ldx:row"/>
- </xsl:template>
- <xsl:template match="ldx:row">
- <fo:table-row>
- <xsl:apply-templates select="ldx:cell"/>
- </fo:table-row>
- </xsl:template>
- <xsl:template match="ldx:cell">
- <xsl:call-template name="cell"/>
- </xsl:template>
- <xsl:template match="ldx:ctab">
- <xsl:variable name="ctabClass">
- <xsl:value-of select="ldx:style"/>
- </xsl:variable>
- <fo:table fox:widow-content-limit="6 * 1.2em" table-layout="fixed" width="100%">
- <xsl:attribute name="padding">0</xsl:attribute>
- <xsl:attribute name="border">0</xsl:attribute>
- <xsl:attribute name="id"><xsl:value-of select="ldx:id"/></xsl:attribute>
- <xsl:attribute name="border-collapse">collapse</xsl:attribute>
- <xsl:for-each select="/ldx:document/ldx:styleGroup[ldx:name=$ctabClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:for-each select="/ldx:filterResultSet/ldx:styleGroup[ldx:name=$ctabClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:choose>
- <xsl:when test="ldx:row/ldx:nestedDimension/ldx:nestedDimension">
- <xsl:call-template name="createColumns"/>
- <xsl:call-template name="createColumns"/>
- <xsl:call-template name="createColumns"/>
- </xsl:when>
- <xsl:when test="ldx:row/ldx:nestedDimension">
- <xsl:call-template name="createColumns"/>
- <xsl:call-template name="createColumns"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="createColumns"/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:for-each select="ldx:column">
- <xsl:call-template name="nestedColumns"/>
- </xsl:for-each>
- <fo:table-body>
- <fo:table-row>
- <xsl:apply-templates select="ldx:corner"/>
- <xsl:apply-templates select="ldx:column"/>
- </fo:table-row>
- <xsl:if test="count(ldx:column/ldx:nestedDimension) > 0">
- <fo:table-row>
- <xsl:call-template name="nestedTable"/>
- </fo:table-row>
- </xsl:if>
- <xsl:for-each select="ldx:row">
- <fo:table-row>
- <xsl:call-template name="insideNestedRowDimension"/>
- </fo:table-row>
- <xsl:if test="count(ldx:nestedDimension) > 1">
- <xsl:call-template name="otherInsideNestedRowDimension"/>
- </xsl:if>
- </xsl:for-each>
- </fo:table-body>
- </fo:table>
- </xsl:template>
- <xsl:template name="nestedColumns">
- <xsl:choose>
- <xsl:when test="ldx:nestedDimension">
- <xsl:for-each select="ldx:nestedDimension">
- <xsl:call-template name="nestedColumns"/>
- </xsl:for-each>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="createColumns"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="createColumns">
- <xsl:variable name="colWidth">
- <xsl:value-of select="ldx:style"/>
- </xsl:variable>
- <fo:table-column>
- <xsl:for-each select="/ldx:document/ldx:styleGroup[ldx:name=$colWidth]">
- <xsl:for-each select="ldx:boxStyle/ldx:width">
- <xsl:attribute name="column-width">
- 3 * <xsl:call-template name="processSizeValue"/>
- </xsl:attribute>
- </xsl:for-each>
- </xsl:for-each>
- <xsl:for-each select="/ldx:filterResultSet/ldx:styleGroup[ldx:name=$colWidth]">
- <xsl:for-each select="ldx:boxStyle/ldx:width">
- <xsl:attribute name="column-width">
- 3 * <xsl:call-template name="processSizeValue"/>
- </xsl:attribute>
- </xsl:for-each>
- </xsl:for-each>
- </fo:table-column>
- </xsl:template>
- <xsl:template match="ldx:corner">
- <xsl:call-template name="cell"/>
- </xsl:template>
- <xsl:template name="cell">
- <xsl:variable name="cellClass">
- <xsl:value-of select="ldx:style"/>
- </xsl:variable>
- <fo:table-cell>
- <xsl:for-each select="/ldx:document/ldx:styleGroup[ldx:name=$cellClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:for-each select="/ldx:filterResultSet/ldx:styleGroup[ldx:name=$cellClass]">
- <xsl:apply-templates select="*"/>
- </xsl:for-each>
- <xsl:if test="ldx:rspan">
- <xsl:attribute name="number-rows-spanned"><xsl:value-of select="ldx:rspan"/></xsl:attribute>
- </xsl:if>
- <xsl:if test="ldx:cspan">
- <xsl:attribute name="number-columns-spanned"><xsl:value-of select="ldx:cspan"/></xsl:attribute>
- </xsl:if>
- <fo:block-container overflow="hidden">
- <fo:block>
- <xsl:apply-templates select="ldx:item"/>
- </fo:block>
- </fo:block-container>
- </fo:table-cell>
- </xsl:template>
- <xsl:template match="ldx:column">
- <xsl:call-template name="nestedDimension"/>
- </xsl:template>
- <xsl:template name="nestedDimension">
- <xsl:for-each select="ldx:name">
- <xsl:call-template name="cell"/>
- </xsl:for-each>
- </xsl:template>
- <xsl:template name="nestedTable">
- <xsl:for-each select="ldx:column/ldx:nestedDimension | ldx:nestedDimension/ldx:nestedDimension">
- <xsl:call-template name="nestedDimension"/>
- </xsl:for-each>
- </xsl:template>
- <xsl:template name="insideNestedRowDimension">
- <xsl:for-each select="ldx:name">
- <xsl:call-template name="cell"/>
- </xsl:for-each>
- <xsl:for-each select="ldx:nestedDimension">
- <xsl:if test="position()=1">
- <xsl:call-template name="insideNestedRowDimension"/>
- </xsl:if>
- </xsl:for-each>
- <xsl:if test="count(ldx:nestedDimension) = 0">
- <xsl:variable name="start" select="ldx:start"/>
- <xsl:for-each select="ancestor::ldx:ctab/ldx:table/ldx:row[(position()-1)=$start]/ldx:cell">
- <xsl:call-template name="cell"/>
- </xsl:for-each>
- </xsl:if>
- </xsl:template>
- <xsl:template name="otherInsideNestedRowDimension">
- <xsl:for-each select="ldx:nestedDimension">
- <xsl:if test="position()!=1">
- <fo:table-row>
- <xsl:for-each select="ldx:name">
- <xsl:call-template name="cell"/>
- </xsl:for-each>
- <xsl:call-template name="otherInsideNestedRowDimension"/>
- </fo:table-row>
- </xsl:if>
- </xsl:for-each>
- <xsl:if test="count(ldx:nestedDimension) = 0">
- <xsl:variable name="start" select="ldx:start"/>
- <xsl:for-each select="ancestor::ldx:ctab/ldx:table/ldx:row[(position()-1)=$start]/ldx:cell">
- <xsl:call-template name="cell"/>
- </xsl:for-each>
- </xsl:if>
- </xsl:template>
- <xsl:template match="ldx:font">
- <xsl:attribute name="font-family">
- <xsl:value-of select="ldx:family"/>
- </xsl:attribute>
- <xsl:attribute name="font-size">
- <xsl:for-each select="ldx:size">
- <xsl:call-template name="processSizeValue"/>
- </xsl:for-each>
- </xsl:attribute>
- <xsl:apply-templates select="ldx:fontStyle/*"/>
- </xsl:template>
- <xsl:template match="ldx:bold">
- <xsl:if test=". = 'true'">
- <xsl:attribute name="font-weight">bold</xsl:attribute>
- </xsl:if>
- </xsl:template>
- <xsl:template match="ldx:italics">
- <xsl:if test=". = 'true'">
- <xsl:attribute name="font-style">italic</xsl:attribute>
- </xsl:if>
- </xsl:template>
- <xsl:template match="ldx:underline">
- <xsl:if test=". = 'true'">
- <xsl:attribute name="text-decoration">underline</xsl:attribute>
- </xsl:if>
- </xsl:template>
- <xsl:template match="ldx:overline">
- <xsl:if test=". = 'true'">
- <xsl:attribute name="text-decoration">overline</xsl:attribute>
- </xsl:if>
- </xsl:template>
- <xsl:template match="ldx:strikethrough">
- <xsl:if test=". = 'true'">
- <xsl:attribute name="text-decoration">line-through</xsl:attribute>
- </xsl:if>
- </xsl:template>
- <xsl:template match="ldx:boxStyle">
- <xsl:apply-templates select="*"/>
- </xsl:template>
- <xsl:template match="ldx:height">
- <xsl:attribute name="height">
- <xsl:call-template name="processSizeValue"/>
- </xsl:attribute>
- </xsl:template>
- <xsl:template match="ldx:margin">
- <xsl:for-each select="ldx:top | ldx:left | ldx:right | ldx:bottom">
- <xsl:call-template name="processMarginSide"/>
- </xsl:for-each>
- </xsl:template>
- <xsl:template match="ldx:padding">
- <xsl:for-each select="ldx:top | ldx:left | ldx:right | ldx:bottom">
- <xsl:call-template name="processPaddingSide"/>
- </xsl:for-each>
- </xsl:template>
- <xsl:template match="ldx:border">
- <xsl:for-each select="ldx:top | ldx:left | ldx:right | ldx:bottom">
- <xsl:call-template name="processBorderSide"/>
- </xsl:for-each>
- </xsl:template>
- <xsl:template name="processBorderSide">
- <xsl:variable name="side" select="name()"/>
- <xsl:for-each select="ldx:width">
- <xsl:variable name="borderwidth">
- <xsl:value-of select="concat('border-',$side,'-width')"/>
- </xsl:variable>
- <xsl:attribute name="{$borderwidth}">
- <xsl:call-template name="processSizeValue"/>
- </xsl:attribute>
- </xsl:for-each>
- <xsl:for-each select="ldx:color">
- <xsl:variable name="bordercolor">
- <xsl:value-of select="concat('border-',$side,'-color')"/>
- </xsl:variable>
- <xsl:attribute name="{$bordercolor}">
- <xsl:text>#</xsl:text><xsl:call-template name="color"/>
- </xsl:attribute>
- </xsl:for-each>
- <xsl:for-each select="ldx:lineStyle">
- <xsl:variable name="borderstyle">
- <xsl:value-of select="concat('border-',$side,'-style')"/>
- </xsl:variable>
- <xsl:attribute name="{$borderstyle}">
- <xsl:value-of select="translate(.,
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
- </xsl:attribute>
- </xsl:for-each>
- </xsl:template>
- <xsl:template name="processMarginSide">
- <xsl:variable name="marginside">
- <xsl:value-of select="concat('margin-',name())"/>
- </xsl:variable>
- <xsl:attribute name="{$marginside}">
- <xsl:call-template name="processSizeValue"/>
- </xsl:attribute>
- </xsl:template>
- <xsl:template name="processPaddingSide">
- <xsl:variable name="paddingside">
- <xsl:value-of select="concat('padding-',name())"/>
- </xsl:variable>
- <xsl:attribute name="{$paddingside}">
- <xsl:call-template name="processSizeValue"/>
- </xsl:attribute>
- </xsl:template>
- <xsl:template match="ldx:hAlign">
- <xsl:attribute name="text-align">
- <xsl:value-of select="translate(.,
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
- </xsl:attribute>
- </xsl:template>
- <xsl:template match="ldx:vAlign">
- <xsl:attribute name="vertical-align">
- <xsl:value-of select="translate(.,
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
- </xsl:attribute>
- </xsl:template>
- <xsl:template match="ldx:fgColor">
- <xsl:attribute name="color">
- <xsl:text>#</xsl:text><xsl:call-template name="color"/>
- </xsl:attribute>
- </xsl:template>
- <xsl:template match="ldx:bgColor">
- <xsl:attribute name="background-color">
- <xsl:text>#</xsl:text><xsl:call-template name="color"/>
- </xsl:attribute>
- </xsl:template>
- <xsl:template name="color">
- <xsl:call-template name="toHex">
- <xsl:with-param name="decimalNumber" select="ldx:Red"/>
- </xsl:call-template>
- <xsl:call-template name="toHex">
- <xsl:with-param name="decimalNumber" select="ldx:Green"/>
- </xsl:call-template>
- <xsl:call-template name="toHex">
- <xsl:with-param name="decimalNumber" select="ldx:Blue"/>
- </xsl:call-template>
- </xsl:template>
- <xsl:template name="processSizeValue">
- <xsl:value-of select="ldx:val"/>
- <xsl:call-template name="processUnits"/>
- </xsl:template>
- <xsl:template name="processUnits">
- <xsl:variable name="units" select="ldx:units"/>
- <xsl:choose>
- <xsl:when test="$units = 'PERCENT'">
- <xsl:text>%</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="translate($units,
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:variable name="hexDigits" select="'0123456789ABCDEF'"/>
- <xsl:template name="toHex">
- <xsl:param name="decimalNumber"/>
- <xsl:if test="$decimalNumber <= 16">
- <xsl:text>0</xsl:text>
- </xsl:if>
- <xsl:call-template name="toHexVal">
- <xsl:with-param name="decimalNumber" select="$decimalNumber"/>
- </xsl:call-template>
- </xsl:template>
- <xsl:template name="toHexVal">
- <xsl:param name="decimalNumber"/>
- <xsl:if test="$decimalNumber >= 16">
- <xsl:call-template name="toHexVal">
- <xsl:with-param name="decimalNumber" select="floor($decimalNumber div 16)"/>
- </xsl:call-template>
- </xsl:if>
- <xsl:value-of select="substring($hexDigits,
- ($decimalNumber mod 16) + 1, 1)"/>
- </xsl:template>
- <xsl:template match="*">
- <!--Unknown element. Ignore-->
- </xsl:template>
- </xsl:stylesheet>
|