Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <xsl:stylesheet version="2.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:fn="http://www.w3.org/2005/xpath-functions"
- xmlns:ntw="Number2Word.uri"
- exclude-result-prefixes="ntw">
- <xsl:output method="html"/>
- <xsl:strip-space elements="*"/>
- <xsl:variable name="ThisDocument" select="document('')"/>
- <xsl:template match="/">
- <xsl:text disable-output-escaping="yes"><![CDATA[<!DOCTYPE html>]]></xsl:text>
- <html>
- <head>
- <xsl:text disable-output-escaping="yes"><![CDATA[</meta>]]></xsl:text>
- <title>
- <xsl:value-of select="chapter/title"/>
- </title>
- <link rel="stylesheet" href="C:\Users\u0138039\Desktop\Proview\SG\Commentary_SG_XML-03032014\SG-Walter Woon on Company Law (3rd ed)\XSLT\main.css" type="text/css"/>
- <xsl:text disable-output-escaping="yes"><![CDATA[</link>]]></xsl:text>
- </head>
- <body>
- <xsl:apply-templates/>
- <xsl:if test="//footnote">
- <section class="tr_footnotes">
- <hr/>
- <xsl:apply-templates select="//footnote" mode="footnote"/>
- </section>
- </xsl:if>
- </body>
- </html>
- </xsl:template>
- <xsl:template name="TitleCase">
- <xsl:param name="text" />
- <xsl:param name="lastletter" select="' '"/>
- <xsl:if test="$text">
- <xsl:variable name="thisletter" select="substring($text,1,1)"/>
- <xsl:choose>
- <xsl:when test="$lastletter=' '">
- <xsl:value-of select="translate($thisletter,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$thisletter"/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:call-template name="TitleCase">
- <xsl:with-param name="text" select="substring($text,2)"/>
- <xsl:with-param name="lastletter" select="$thisletter"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:template>
- <xsl:template match="chapter">
- <section class="tr_chapter">
- <xsl:apply-templates select="./title[1]/page[1]"/>
- <div class="chapter">
- <xsl:variable name="num_L">
- <xsl:value-of select="string-length(@num)"></xsl:value-of>
- </xsl:variable>
- <xsl:variable name="num_S">
- <xsl:choose>
- <xsl:when test="$num_L=1">
- <xsl:value-of select="concat('0',@num)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="@num"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <a name="LRSC_CH_{$num_S}"/>
- <xsl:variable name="cnum">
- <xsl:choose>
- <xsl:when test="starts-with(@num,'0')">
- <xsl:value-of select="substring-after(@num,'0')"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="@num"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <div class="chapter-title">
- <span class="chapter-num">
- <xsl:value-of select="normalize-space(concat('Chapter ',$cnum,' '))"/>
- </span> 
- <xsl:value-of select="./title/content-style/text()"/>
- </div>
- <xsl:apply-templates select="child::node()[not(self::title)]"/>
- </div>
- </section>
- </xsl:template>
- <xsl:template match="chapter/para">
- <xsl:variable name="for">
- <xsl:value-of select="current()/@align"/>
- </xsl:variable>
- <div class="{concat('para align-',$for)}">
- <xsl:apply-templates/>
- </div>
- </xsl:template>
- <!-- Index templates -->
- <xsl:template name="toc" match="chapter/toc">
- <div class="toc">
- <xsl:call-template name="toc-part"/>
- </div>
- </xsl:template>
- <xsl:template name="toc-part" match="chapter/toc/toc-part">
- <div class="toc-part">
- <xsl:call-template name="toc-div"/>
- </div>
- </xsl:template>
- <xsl:template name="toc-div" match="chapter/toc/toc-part/toc-div">
- <table class="toc-div">
- <tbody>
- <tr>
- <td>
- <xsl:for-each select="current()/toc-part/toc-div/*">
- <xsl:call-template name="toc-item"/>
- </xsl:for-each>
- </td>
- </tr>
- </tbody>
- </table>
- </xsl:template>
- <xsl:template name="toc-item" match="chapter/toc/toc-part/toc-div/toc-item">
- <xsl:variable name="tocpg">
- <xsl:value-of select="concat('P',current()/toc-pg/text())"/>
- </xsl:variable>
- <xsl:variable name="tocpgtag" select="translate($tocpg,'.', '-')"/>
- <xsl:variable name="chapternumber">
- <!-- Get num attribute of parent node -->
- <xsl:value-of select="ancestor::chapter[1]/@num"/>
- </xsl:variable>
- <xsl:variable name="strl">
- <xsl:value-of select="string-length(substring-after(@num,'.'))"/>
- </xsl:variable>
- <xsl:variable name="Brac">
- <xsl:choose>
- <xsl:when test="contains(substring-after(@num,'.'),'.')">
- <xsl:value-of select="3"/>
- </xsl:when>
- <xsl:when test="contains(@num,'(')">
- <xsl:value-of select="2"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="1"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="NewL">
- <xsl:value-of select="string-length(substring-before(current()/toc-pg,'.'))"/>
- </xsl:variable>
- <xsl:variable name="newNum">
- <xsl:choose>
- <xsl:when test="$NewL=1">
- <xsl:value-of select="concat('0',substring-before(current()/toc-pg/text(),'.'))"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="substring-before(current()/toc-pg/text(),'.')"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="d">
- <xsl:value-of select="concat('toc-item-',$ThisDocument//ntw:nums[@num=$Brac]/@word,'-level')"/>
- </xsl:variable>
- <xsl:variable name="new">
- <xsl:value-of select="concat('er:#LRSC_CH_',$newNum,'/',$tocpgtag)"/>
- </xsl:variable>
- <table class="{$d}">
- <tbody>
- <tr>
- <td class="toc-item-num">
- <xsl:value-of select="current()/@num"/>
- </td>
- <td class="toc-title">
- <xsl:value-of select="current()/toc-title"/>
- </td>
- <xsl:variable name="toc-title" select="upper-case(current()/toc-title/text())" />
- <td class="toc-pg">
- <xsl:variable name="refe">
- <xsl:choose>
- <xsl:when test="//section[title/*[upper-case(text()) = $toc-title]]/section[1]/para[1]/@num">
- <xsl:value-of select="//section[title/*[upper-case(text()) = $toc-title]]/section[1]/para[1]/@num[1]"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="//section[title/*[upper-case(text()) = $toc-title]]/para[1]/@num[1]"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="full">
- <xsl:value-of select="$refe"/>
- </xsl:variable>
- <xsl:variable name="pre">
- <xsl:value-of select="substring-before($refe,'.')"/>
- </xsl:variable>
- <xsl:variable name="post">
- <xsl:value-of select="substring-after($refe,'.')"/></xsl:variable>
- <xsl:variable name="siz">
- <xsl:choose>
- <xsl:when test="$pre>'1'">
- <xsl:value-of select="concat('LRSC_CH_',$pre,'/P',translate($full,'.','-'))"></xsl:value-of>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat('LRSC_CH_0',$pre,'/P',translate($full,'.','-'))"></xsl:value-of>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <a href="{$siz}">
- <xsl:value-of select="./toc-pg"/>
- </a>
- </td>
- </tr>
- </tbody>
- </table>
- <xsl:if test="./toc-subitem">
- <xsl:for-each select="./toc-subitem">
- <xsl:apply-templates select="."/>
- </xsl:for-each>
- </xsl:if>
- <!--</table>-->
- </xsl:template>
- <xsl:template match="toc-subitem">
- <xsl:variable name="tocpg">
- <xsl:value-of select="concat('P',current()/toc-pg/text())"/>
- </xsl:variable>
- <xsl:variable name="tocpgtag" select="translate($tocpg,'.', '-')"/>
- <xsl:variable name="chapternumber">
- <!-- Get num attribute of parent node -->
- <xsl:value-of select="ancestor::chapter[1]/@num"/>
- </xsl:variable>
- <xsl:variable name="strl">
- <xsl:value-of select="string-length(substring-after(@num,'.'))"/>
- </xsl:variable>
- <xsl:variable name="Brac">
- <xsl:choose>
- <xsl:when test="contains(substring-after(@num,'.'),'.')">
- <xsl:value-of select="3"/>
- </xsl:when>
- <xsl:when test="contains(@num,'(')">
- <xsl:value-of select="2"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="1"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="NewL">
- <xsl:value-of select="string-length(substring-before(current()/toc-pg,'.'))"/>
- </xsl:variable>
- <xsl:variable name="newNum">
- <xsl:choose>
- <xsl:when test="$NewL=1">
- <xsl:value-of select="concat('0',substring-before(current()/toc-pg/text(),'.'))"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="substring-before(current()/toc-pg/text(),'.')"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="d">
- <xsl:value-of select="concat('toc-item-',$ThisDocument//ntw:nums[@num='2']/@word,'-level')"/>
- </xsl:variable>
- <xsl:variable name="new">
- <xsl:value-of select="concat('er:#LRSC_CH_',$newNum,'/',$tocpgtag)"/>
- </xsl:variable>
- <table class="{$d}">
- <tbody>
- <tr>
- <td class="toc-item-num">
- <xsl:value-of select="current()/@num"/>
- </td>
- <td class="toc-title">
- <xsl:value-of select="current()/toc-title"/>
- </td>
- <xsl:variable name="toc-title" select="upper-case(current()/toc-title/*)" />
- <td class="toc-pg">
- <xsl:variable name="refe">
- <xsl:choose>
- <xsl:when test="//section[title/*[upper-case(text()) = $toc-title]]/section[1]/para[1]/@num[1]">
- <xsl:value-of select="//section[title/*[upper-case(text()) = $toc-title]]/section[1]/para[1]/@num[1]"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="//section[title/*[upper-case(text()) = $toc-title]]/para[1]/@num[1]"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="full">
- <xsl:value-of select="$refe"/>
- </xsl:variable>
- <xsl:variable name="pre">
- <xsl:value-of select="substring-before($refe,'.')"/>
- </xsl:variable>
- <xsl:variable name="post">
- <xsl:value-of select="substring-after($refe,'.')"/></xsl:variable>
- <xsl:variable name="siz">
- <xsl:choose>
- <xsl:when test="$pre>'1'">
- <xsl:value-of select="concat('LRSC_CH_',$pre,'/P',translate($full,'.','-'))"></xsl:value-of>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat('LRSC_CH_0',$pre,'/P',translate($full,'.','-'))"></xsl:value-of>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <a href="{$siz}">
- <xsl:value-of select="./toc-pg"/>
- </a>
- </td>
- </tr>
- </tbody>
- </table>
- <xsl:if test="./toc-subitem">
- <xsl:apply-templates/>
- </xsl:if>
- <!--</table>-->
- </xsl:template>
- <!-- Index Templates Complete -->
- <!-- Paragraph templates -->
- <xsl:template name="section" match="section">
- <!-- Variables-->
- <xsl:variable name="classname">
- <!--Get name attribute of current node -->
- <xsl:value-of select="concat('section-',@level)"/>
- </xsl:variable>
- <xsl:variable name="size">
- <xsl:value-of select="string-length(ancestor::chapter[1]/@num)"/>
- </xsl:variable>
- <xsl:variable name="Chn">
- <xsl:value-of select="ancestor::chapter[1]/@num"/>
- </xsl:variable>
- <xsl:variable name="chapternumber">
- <!-- Get num attribute of parent node -->
- <xsl:choose>
- <xsl:when test="$size=1">
- <xsl:value-of select="concat('0',$Chn)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$Chn"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="sectnum">
- <xsl:number level="any" count="section" format="1"/>
- </xsl:variable>
- <!--Create a string variable by concat string method -->
- <xsl:variable name="sectionname">
- <xsl:value-of select="concat('CH_',$chapternumber,'-SEC-', $sectnum)"/>
- </xsl:variable>
- <!-- Template Content -->
- <div class="{$classname}">
- <a name="{$sectionname}"> </a>
- <div class="section-title">
- <xsl:if test="not(contains(./@num,'unnumbered'))">
- <xsl:if test="./@num">
- <span class="section-num">
- <xsl:value-of select="@num"/>
- </span>
- <xsl:text> </xsl:text>
- </xsl:if>
- </xsl:if>
- <xsl:apply-templates select="title"/>
- </div>
- <xsl:apply-templates select="child::node()[not(self::title)]"/>
- </div>
- </xsl:template>
- <xsl:template name="para" match="section/para">
- <xsl:choose>
- <xsl:when test="current()/@align">
- <div class="para align-{@align}">
- <xsl:apply-templates/>
- </div>
- </xsl:when>
- <xsl:when test="current()/@num">
- <xsl:choose>
- <xsl:when test="child::node()[1][self::*]">
- <xsl:apply-templates select="child::page[1]"/>
- <div class="para">
- <xsl:call-template name="phrase"/>
- <xsl:apply-templates select="child::node()[not(self::page)]"/>
- </div>
- </xsl:when>
- <xsl:otherwise>
- <div class="para">
- <xsl:call-template name="phrase"/>
- <xsl:apply-templates/>
- </div>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <div class="para">
- <xsl:apply-templates/>
- </div>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="text()">
- <xsl:analyze-string select="." regex="(([Cc]hapter)\s(\d+))">
- <xsl:matching-substring>
- <xsl:choose>
- <xsl:when test="number(regex-group(3)) < 14">
- <a href="{concat('er:#LRSC_CH_',format-number(number(regex-group(3)),'00'),'/','LRSC_CH_',format-number(number(regex-group(3)),'00'))}">
- <xsl:value-of select="."/>
- </a>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="."/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:matching-substring>
- <xsl:non-matching-substring>
- <xsl:analyze-string select="." regex="([0-9]+)/([0-9]+)">
- <xsl:matching-substring>
- <a
- href="{concat('er:#LRSC_CH_',format-number(number(regex-group(1)),'00'),'/P',format-number(number(regex-group(1)),'0'),'-',regex-group(2))}">
- <xsl:value-of select="."/>
- </a>
- </xsl:matching-substring>
- <xsl:non-matching-substring>
- <xsl:analyze-string select="." regex="http://[^ ]+">
- <xsl:matching-substring>
- <a href="{.}">
- <xsl:value-of select="."/>
- </a>
- </xsl:matching-substring>
- <xsl:non-matching-substring>
- <xsl:value-of select="."/>
- </xsl:non-matching-substring>
- </xsl:analyze-string>
- </xsl:non-matching-substring>
- </xsl:analyze-string>
- </xsl:non-matching-substring>
- </xsl:analyze-string>
- </xsl:template>
- <xsl:template name="phraseExtract" match="section/extract">
- <div class="extract">
- <xsl:apply-templates/>
- </div>
- </xsl:template>
- <xsl:template name="newPh" match="extract/para">
- <div class="para">
- <xsl:apply-templates/>
- </div>
- </xsl:template>
- <xsl:template match="para/case">
- <xsl:apply-templates/>
- </xsl:template>
- <xsl:template name="ItemTex" match="itemizedlist">
- <ul class="itemizedlist">
- <xsl:for-each select="item">
- <li class="item">
- <xsl:apply-templates/>
- </li>
- </xsl:for-each>
- </ul>
- </xsl:template>
- <xsl:template name="phrase">
- <xsl:choose>
- <xsl:when test="parent::title">
- <xsl:variable name="phrase">
- <xsl:value-of select="concat('P',@num)"/>
- </xsl:variable>
- <xsl:variable name="newphrase" select="translate($phrase,'.','-')"/>
- <a>
- <xsl:attribute name="name">
- <xsl:value-of select="$newphrase">
- </xsl:value-of>
- </xsl:attribute>
- </a>
- <span class="phrase1">
- <xsl:value-of select="current()"/>
- </span>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="phrase">
- <xsl:value-of select="concat('P',@num)"/>
- </xsl:variable>
- <xsl:variable name="newphrase" select="translate($phrase,'.','-')"/>
- <a>
- <xsl:attribute name="name">
- <xsl:value-of select="$newphrase">
- </xsl:value-of>
- </xsl:attribute>
- </a>
- <span class="phrase">
- <xsl:value-of select="current()/@num"/>
- </span>
- </xsl:otherwise>
- </xsl:choose>
- <!--<xsl:apply-templates/>-->
- </xsl:template>
- <!-- Table Templates -->
- <xsl:template match="table|legtable|informaltable">
- <table cellspacing="1">
- <xsl:attribute name="class">
- <xsl:choose>
- <xsl:when test="@frame = 'top'">frame-above</xsl:when>
- <xsl:when test="@frame = 'bottom'">frame-below</xsl:when>
- <xsl:when test="@frame = 'topbot'">frame-topbot</xsl:when>
- <xsl:when test="@frame = 'all'">frame-all</xsl:when>
- <xsl:when test="@frame = 'sides'">frame-vsides</xsl:when>
- <xsl:when test="@frame = 'none'">frame-none</xsl:when>
- <xsl:when test="local-name()='informaltable'">frame-box</xsl:when>
- <xsl:otherwise>void</xsl:otherwise>
- </xsl:choose>
- </xsl:attribute><xsl:apply-templates/>
- </table>
- </xsl:template>
- <!--
- <xsl:template match="table/title | legtable/title | informaltable/title">
- <caption>
- <xsl:apply-templates/>
- </caption>
- </xsl:template>
- -->
- <xsl:template match="tgroup">
- <colgroup>
- <xsl:apply-templates select="colspec"/>
- </colgroup>
- <xsl:apply-templates select="thead"/>
- <xsl:apply-templates select="tbody"/>
- <xsl:apply-templates select="tfoot"/>
- </xsl:template>
- <xsl:template match="tgroup/colspec">
- <col class="colnum-{current()/@colnum} colname-{current()/@colname} colwidth-{translate(current()/@colwidth,'%','')}"/>
- <xsl:text disable-output-escaping="yes"><![CDATA[</col>]]></xsl:text>
- <xsl:apply-templates/>
- </xsl:template>
- <xsl:template match="tgroup/thead">
- <thead><xsl:if test="@valign">
- <xsl:attribute name="class"> <xsl:if test="@valign">
- <xsl:value-of select="@valign"/>
- </xsl:if>
- </xsl:attribute>
- </xsl:if>
- <xsl:apply-templates/>
- </thead>
- </xsl:template>
- <xsl:template match="tgroup/tbody">
- <tbody>
- <xsl:if test="@valign">
- <xsl:attribute name="class" select="@valign"/>
- </xsl:if>
- <xsl:apply-templates/>
- </tbody>
- </xsl:template>
- <xsl:template match="tgroup/tfoot">
- <tfoot>
- <xsl:if test="@valign">
- <xsl:attribute name="class" select="@valign"/>
- </xsl:if>
- <xsl:apply-templates/>
- </tfoot>
- </xsl:template>
- <xsl:template match="tgroup//row">
- <tr>
- <xsl:if test="@valign">
- <xsl:attribute name="class" select="@valign"/>
- </xsl:if>
- <xsl:if test="@rowsep = '1'">
- <xsl:attribute name="class" select="'rowsep'"/>
- </xsl:if>
- <!-- MH 14/1/2014 -->
- <xsl:if test="@rowsep = '0'">
- <xsl:attribute name="class" select="'rownone'"/>
- </xsl:if>
- <xsl:apply-templates/>
- </tr><xsl:text>
- </xsl:text>
- </xsl:template>
- <xsl:template name="getColPosition">
- <xsl:param name="column"/>
- <xsl:param name="index" select="0"/>
- <xsl:variable name="colspan">
- <xsl:choose>
- <xsl:when test="($index > 0) and $column/@namest and $column/@nameend">
- <xsl:variable name="namest" select="$column/@namest" />
- <xsl:variable name="nameend" select="$column/@nameend" />
- <xsl:variable name="posStart">
- <xsl:for-each select="$column/ancestor::tgroup/colspec">
- <xsl:if test="lower-case(@colname) = lower-case($namest)">
- <xsl:value-of select="position()"/>
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
- <xsl:variable name="posEnd">
- <xsl:for-each select="$column/ancestor::tgroup/colspec">
- <xsl:if test="lower-case(@colname) = lower-case($nameend)">
- <xsl:value-of select="position()"/>
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
- <xsl:value-of select="number($posEnd) - number($posStart) + 1"/>
- </xsl:when>
- <xsl:otherwise>1</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="$column/preceding-sibling::entry[1]">
- <xsl:call-template name="getColPosition">
- <xsl:with-param name="column" select="$column/preceding-sibling::entry[1]"/>
- <xsl:with-param name="index" select="$colspan + $index"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="$colspan + $index"/></xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="tgroup//row/entry">
- <xsl:choose>
- <xsl:when test="ancestor::thead">
- <th>
- <xsl:if test="@morerows"><xsl:attribute name="rowspan" select="@morerows+1"/></xsl:if>
- <xsl:if test="@valign"><xsl:attribute name="valign" select="@valign"/></xsl:if>
- <xsl:if test="@align"><xsl:attribute name="class" select="concat('align-',@align)"/></xsl:if>
- <xsl:if test="@namest">
- <xsl:attribute name="colspan">
- <xsl:variable name="namest" select="@namest" />
- <xsl:variable name="nameend" select="@nameend" />
- <xsl:variable name="posStart">
- <xsl:for-each select="ancestor::tgroup/colspec">
- <xsl:if test="lower-case(translate(@colname,'col','')) = lower-case($namest)">
- <xsl:value-of select="position()"/>
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
- <xsl:variable name="posEnd">
- <xsl:for-each select="ancestor::tgroup/colspec">
- <xsl:if test="lower-case(translate(@colname,'col','')) = lower-case($nameend)">
- <xsl:value-of select="position()"/>
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="$posEnd=''">
- <xsl:message>
- <xsl:text>TD missing @nameend
- </xsl:text>
- <xsl:if test="ancestor-or-self::*[@uci]">
- <xsl:text>The closest UCI is </xsl:text>
- <xsl:value-of select="ancestor-or-self::*[@uci][1]/@uci"/>
- <xsl:text>
- </xsl:text>
- </xsl:if>
- </xsl:message>
- <xsl:text>1</xsl:text>
- </xsl:when>
- <xsl:when test="$posStart=''">
- <xsl:message>
- <xsl:text>TD missing @namest
- </xsl:text>
- <xsl:if test="ancestor-or-self::*[@uci]">
- <xsl:text>The closest UCI is </xsl:text>
- <xsl:value-of select="ancestor-or-self::*[@uci][1]/@uci"/>
- <xsl:text>
- </xsl:text>
- </xsl:if>
- </xsl:message>
- <xsl:text>1</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$posEnd - $posStart + 1"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:if>
- <xsl:variable name="curPosition">
- <xsl:call-template name="getColPosition">
- <xsl:with-param name="column" select="."/>
- </xsl:call-template>
- <!-- xsl:value-of select="position()"/ -->
- </xsl:variable>
- <xsl:variable name="className">
- <xsl:choose>
- <xsl:when test="@colsep = '1' or ancestor::tgroup/@colsep = '1'">
- <xsl:text>colsep </xsl:text>
- </xsl:when>
- <!-- MH 14/1/2014 -->
- <xsl:when test="@colsep = '0' or ancestor::tgroup/@colsep = '0'">
- <xsl:text>colnone </xsl:text>
- </xsl:when>
- <xsl:when test="ancestor::tgroup/colspec[position() = $curPosition]/@colsep = '1'">
- <xsl:text>colsep </xsl:text>
- </xsl:when>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test="@rowsep = '1' or ancestor::tgroup/@rowsep = '1'">
- <xsl:text>rowsep</xsl:text>
- </xsl:when>
- <!-- MH 14/1/2014 -->
- <xsl:when test="@rowsep = '0' or ancestor::tgroup/@rowsep = '0'">
- <xsl:text>rownone</xsl:text>
- </xsl:when>
- <xsl:when test="ancestor::tgroup/colspec[position() = $curPosition]/@rowsep = '1'">
- <xsl:text>rowsep</xsl:text>
- </xsl:when>
- </xsl:choose>
- </xsl:variable>
- <xsl:if test="$className != ''">
- <xsl:attribute name="class" select="$className"/>
- </xsl:if>
- <xsl:variable name="alignment">
- <xsl:choose>
- <xsl:when test="@align">
- <xsl:value-of select="@align"/>
- </xsl:when>
- <xsl:when test="ancestor::tgroup/colspec[position() = $curPosition]/@align">
- <xsl:value-of select="ancestor::tgroup/colspec[position() = $curPosition]/@align"/>
- </xsl:when>
- <xsl:when test="ancestor::tgroup/@align">
- <xsl:value-of select="ancestor::tgroup/@align"/>
- </xsl:when>
- </xsl:choose>
- </xsl:variable>
- <xsl:if test="$alignment != ''">
- <xsl:attribute name="align" select="$alignment"/>
- </xsl:if>
- <xsl:choose>
- <!-- Antony Suryadinata 21 June 2012 - Disabled outputting leaders -->
- <xsl:when test="symbol[@role='leader' and not(following-sibling::node())] and false()">
- <div class="not_used_leader">
- <div class="item">
- <xsl:apply-templates/>
- </div>
- <div class="ref"> </div>
- </div>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="normalize-space(.) = ''"> </xsl:when>
- <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </th>
- </xsl:when>
- <xsl:otherwise>
- <td>
- <xsl:if test="@morerows"><xsl:attribute name="rowspan" select="@morerows+1"/></xsl:if>
- <xsl:if test="@valign"><xsl:attribute name="class" select="@valign"/></xsl:if>
- <xsl:if test="@namest">
- <xsl:attribute name="colspan">
- <xsl:variable name="namest" select="@namest" />
- <xsl:variable name="nameend" select="@nameend" />
- <xsl:variable name="posStart">
- <xsl:for-each select="ancestor::tgroup/colspec">
- <xsl:if test="lower-case(translate(@colname,'col','')) = lower-case($namest)">
- <xsl:value-of select="position()"/>
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
- <xsl:variable name="posEnd">
- <xsl:for-each select="ancestor::tgroup/colspec">
- <xsl:if test="lower-case(translate(@colname,'col','')) = lower-case($nameend)">
- <xsl:value-of select="position()"/>
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="$posEnd=''">
- <xsl:message>
- <xsl:text>TD missing @nameend
- </xsl:text>
- <xsl:if test="ancestor-or-self::*[@uci]">
- <xsl:text>The closest UCI is </xsl:text>
- <xsl:value-of select="ancestor-or-self::*[@uci][1]/@uci"/>
- <xsl:text>
- </xsl:text>
- </xsl:if>
- </xsl:message>
- <xsl:text>1</xsl:text>
- </xsl:when>
- <xsl:when test="$posStart=''">
- <xsl:message>
- <xsl:text>TD missing @namest
- </xsl:text>
- <xsl:if test="ancestor-or-self::*[@uci]">
- <xsl:text>The closest UCI is </xsl:text>
- <xsl:value-of select="ancestor-or-self::*[@uci][1]/@uci"/>
- <xsl:text>
- </xsl:text>
- </xsl:if>
- </xsl:message>
- <xsl:text>1</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$posEnd - $posStart + 1"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:if>
- <xsl:variable name="curPosition">
- <xsl:call-template name="getColPosition">
- <xsl:with-param name="column" select="."/>
- </xsl:call-template>
- <!-- xsl:value-of select="position()"/ -->
- </xsl:variable>
- <xsl:variable name="className">
- <xsl:choose>
- <xsl:when test="@colsep = '1' or ancestor::tgroup/@colsep = '1'">
- <xsl:text>colsep </xsl:text>
- </xsl:when>
- <!-- MH 14/1/2014 -->
- <xsl:when test="@colsep = '0' or ancestor::tgroup/@colsep = '0'">
- <xsl:text>colnone </xsl:text>
- </xsl:when>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test="@rowsep = '1' or ancestor::tgroup/@rowsep = '1'">
- <xsl:text>rowsep</xsl:text>
- </xsl:when>
- <!-- MH 14/1/2014 -->
- <xsl:when test="@rowsep = '0' or ancestor::tgroup/@rowsep = '0'">
- <xsl:text>rownone</xsl:text>
- </xsl:when>
- <xsl:when test="ancestor::tgroup/colspec[position() = $curPosition]/@rowsep = '1'">
- <xsl:text>rowsep</xsl:text>
- </xsl:when>
- </xsl:choose>
- </xsl:variable>
- <xsl:if test="$className != ''">
- <xsl:attribute name="class" select="$className"/>
- </xsl:if>
- <xsl:variable name="alignment">
- <xsl:choose>
- <xsl:when test="@align">
- <xsl:value-of select="@align"/>
- </xsl:when>
- <xsl:when test="ancestor::tgroup/colspec[position() = $curPosition]/@align">
- <xsl:value-of select="ancestor::tgroup/colspec[position() = $curPosition]/@align"/>
- </xsl:when>
- <xsl:when test="ancestor::tgroup/@align">
- <xsl:value-of select="ancestor::tgroup/@align"/>
- </xsl:when>
- </xsl:choose>
- </xsl:variable>
- <xsl:if test="$alignment != ''">
- <xsl:attribute name="align" select="$alignment"/>
- </xsl:if>
- <xsl:choose>
- <!-- Antony Suryadinata 21 June 2012 - Disabled outputting leaders -->
- <xsl:when test="symbol[@role='leader' and not(following-sibling::node())] and false()">
- <div class="not_used_leader">
- <div class="item">
- <xsl:apply-templates/>
- </div>
- <div class="ref"> </div>
- </div>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="normalize-space(.) = ''"> </xsl:when>
- <xsl:otherwise>
- <div class="para">
- <xsl:apply-templates/>
- </div>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </td>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!-- Table Templates complete -->
- <!--List templates -->
- <xsl:template name="orderedlist" match="orderedlist">
- <ol class="eng-orderedlist orderedlist">
- <xsl:apply-templates/>
- </ol>
- </xsl:template>
- <xsl:template name="orderitem" match="item">
- <xsl:choose>
- <xsl:when test="./para[1]/page[1]">
- <xsl:apply-templates select="./para[1]/page[1]"/>
- <li class="item">
- <xsl:apply-templates select="child::node()[fn:not(child::para/page[1])]"/>
- </li>
- </xsl:when>
- <xsl:otherwise>
- <li class="item">
- <xsl:apply-templates/>
- </li>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="orderitempara" match="item/para">
- <xsl:choose>
- <xsl:when test="contains(../../@type,'manual')">
- <div class="para">
- <xsl:choose>
- <xsl:when test="position()=1">
- <span class="item-num">
- <xsl:choose>
- <xsl:when test="contains(parent::item[1]/@num,'bull')">
- <xsl:text>•</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="parent::item[1]/@num"/>
- </xsl:otherwise>
- </xsl:choose>
- </span>
- <xsl:text> </xsl:text>
- <xsl:apply-templates select="child::node()[not(self::page)]"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates/>
- </xsl:otherwise>
- </xsl:choose>
- </div>
- </xsl:when>
- <xsl:otherwise>
- <span class="bullet-list">
- <xsl:value-of select="../../@type"/>
- </span>
- <xsl:apply-templates/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!--List templates Complete -->
- <!-- Paragraph templates Complete -->
- <!-- Footnote Templates-->
- <xsl:template match="footnote">
- <xsl:variable name="varHeaderNote" select='concat("f",@num)'/>
- <xsl:variable name="varFootNote" select='concat("#ftn.",@num)'/>
- <sup><a name="{$varHeaderNote}" href="{$varFootNote}" class="tr_ftn"><xsl:value-of select="@num"/></a>
- </sup>
- </xsl:template>
- <xsl:template match="footnote" mode="footnote">
- <xsl:if test="preceding::node()[page[1]]">
- <xsl:variable name="op"><</xsl:variable>
- <xsl:variable name="apos">'</xsl:variable>
- <xsl:variable name="cl">></xsl:variable>
- <xsl:value-of select="concat($op,'?pb label=',$apos,preceding::page[1]/@num,$apos,'?',$cl)"/>
- </xsl:if>
- <div class="tr_footnote">
- <div class="footnote">
- <sup>
- <a>
- <xsl:attribute name="name"><xsl:text>ftn.</xsl:text><xsl:value-of select="@num"/></xsl:attribute>
- <xsl:attribute name="href"><xsl:text>#f</xsl:text><xsl:value-of select="@num"/></xsl:attribute>
- <xsl:attribute name="class"><xsl:text>tr_ftn</xsl:text></xsl:attribute>
- <xsl:value-of select="@num"/>
- </a>
- </sup>
- <xsl:apply-templates/>
- </div>
- </div>
- </xsl:template>
- <xsl:template match="footnote/para/uri">
- <xsl:variable name="url1">
- <xsl:value-of select="translate(@href, '<','')" />
- </xsl:variable>
- <xsl:variable name="url2">
- <xsl:value-of select="translate($url1, '>','')" />
- </xsl:variable>
- <a href="{$url2}">
- <xsl:value-of select="." />
- </a>
- </xsl:template>
- <!-- Footnote Templates Complete -->
- <xsl:template match="content-style">
- <xsl:choose>
- <xsl:when test="./@format">
- <span class="format-{@format}">
- <xsl:apply-templates/>
- </span>
- </xsl:when>
- <xsl:otherwise>
- <xsl:if test="preceding-sibling::content-style">
- <xsl:text> </xsl:text>
- </xsl:if>
- <xsl:variable name="fontStyle">
- <xsl:value-of select="concat('font-style-',@font-style)"/>
- </xsl:variable>
- <span class="{$fontStyle}">
- <xsl:apply-templates/>
- </span>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="extract">
- <div class="extract">
- <xsl:apply-templates/>
- </div>
- </xsl:template>
- <xsl:template name="fig" match="figure">
- <div class="figure">
- <!--<div class="figure-title">
- <xsl:value-of select="current()/title"/>
- </div>-->
- <xsl:variable name="numb">
- <xsl:value-of select="substring-before(graphic/@href,'.')"/>
- </xsl:variable>
- <xsl:variable name="figCon">
- <xsl:value-of select="concat('er:#',$numb)"/>
- </xsl:variable>
- <img class="graphic" src="{$figCon}" alt=""/>
- <xsl:text disable-output-escaping="yes"><![CDATA[</img>]]></xsl:text>
- </div>
- </xsl:template>
- <xsl:template match="chapter-meta">
- </xsl:template>
- <xsl:template match="page">
- <xsl:variable name="op"><</xsl:variable>
- <xsl:variable name="apos">'</xsl:variable>
- <xsl:variable name="cl">></xsl:variable>
- <xsl:value-of select="concat($op,'?pb label=',$apos,./@num,$apos,'?',$cl)"/>
- <xsl:apply-templates/>
- </xsl:template>
- <!-- Namespace ntw-->
- <ntw:nums num="1" word="first"/>
- <ntw:nums num="2" word="second"/>
- <ntw:nums num="3" word="third"/>
- <ntw:nums num="4" word="forth"/>
- <ntw:nums num="5" word="fifth"/>
- <ntw:nums num="6" word="sixth"/>
- <ntw:nums num="7" word="seventh"/>
- <ntw:nums num="8" word="eighth"/>
- <ntw:nums num="9" word="nighth"/>
- <ntw:nums num="10" word="tenth"/>
- <!-- Namespace ntw ends -->
- </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement