我有下面的 xml 文档。
<chapter num="1">
<title>DIRECTORS</title>
<para align="center">
<content-style font-style="italic">By Stefan Lo</content-style>
</para>
<para align="right">
P<content-style format="smallcaps">ARA</content-style>.
</para>
<toc>
<toc-part>
<toc-div>
<toc-item num="I.">
<toc-title>Effect of Winding-up and Receiverships on Directors</toc-title>
<toc-pg>1.001</toc-pg>
</toc-item>
<toc-item num="II.">
<toc-title>Civil Liability of Directors</toc-title>
<toc-pg>1.015</toc-pg>
</toc-item>
<toc-item num="III.">
<toc-title>Criminal Liability of Directors</toc-title>
<toc-pg>1.059</toc-pg>
</toc-item>
<toc-item num="IV.">
<toc-title>Disqualification of Directors</toc-title>
<toc-pg>1.065</toc-pg>
</toc-item>
</toc-div>
</toc-part>
</toc>
<section level="sect1" number-type="manual" num="I.">
<title>EFFECT OF winding-up AND RECEIVERSHIPS ON DIRECTORS</title>
<section level="sect2" number-type="manual">
<title>Compulsory Winding-up</title>
<section level="sect3" number-type="manual">
<title>Powers of Directors</title>
<section level="sect4" number-type="manual">
<title>General</title>
<para>
<phrase>1.001</phrase> The presentation of a petition for the winding-up of the company by the court does not in itself affect the powers or position of the directors who may continue to operate the business of the company.<footnote num="1">
<para>
<case>
<content-style font-style="italic">Re Oriental Bank Corp, ex p Guillemin</content-style> (1884) 28 Ch D 634
</case>; <case>
<content-style font-style="italic">Mersey Steel and Iron Co v Naylor Benzon & Co</content-style> (1882) 9 QBD 648
</case>.
</para>
</footnote> However, the directors would need to ensure that they do not engage in fraudulent trading,<footnote num="2">
<para>CO, s.275: see "Fraudulent trading" at paras 1.032 ff, below.</para>
</footnote> and in addition, should be aware that if a winding-up order is made, any disposition of the company's property and any alteration in the status of the members of the company after the date of the petition would be void unless validated by the court.<footnote num="3">
</footnote>
</para>
</section>
</section>
</section>
</section>
</chapter>
和下面的xslt。
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 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:\Documents and Settings\u0138039\Desktop\B3\main.css" type="text/css"/>
<xsl:text disable-output-escaping="yes"><![CDATA[</link>]]></xsl:text>
</head>
<body>
<xsl:apply-templates/>
<hr/>
<xsl:text disable-output-escaping="yes"><![CDATA[</hr>]]></xsl:text>
<section class="tr_footnotes">
<xsl:apply-templates select="//footnote" mode="footnote"/>
</section>
</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">
<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="CLI_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:variable name="TiC">
<xsl:call-template name="TitleCase">
<xsl:with-param name="text" select="translate(normalize-space(title),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')" />
</xsl:call-template>
</xsl:variable>
<!--<xsl:apply-templates select="$TiC"/>-->
<xsl:value-of select="title"/>
</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="nu">
<xsl:number format="I."/>
</xsl:variable>
<xsl:variable name="Brac">
<xsl:choose>
<xsl:when test="contains(current()/@num,$nu)">
<xsl:value-of select="3"/>
</xsl:when>
<xsl:when test="contains(current()/@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:#CLI_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>
<td class="toc-pg">
<a href="{$new}">
<xsl:value-of select="current()/toc-pg"/>
</a>
</td>
</tr>
</tbody>
</table>
<!--</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(current()/@num,' '))">
<xsl:if test="@level='sect1'">
<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:otherwise>
<div class="para">
<xsl:apply-templates/>
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="section/para/text()">
<xsl:text> </xsl:text>
<xsl:value-of select="normalize-space(.)" />
</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">
<div class="para">
<span class="bullet-list">
<xsl:value-of select="parent::itemizedlist/@type"/>
</span>
<xsl:text> </xsl:text>
<xsl:value-of select="current()/para"/>
<xsl:apply-templates select="extract|para"/>
</div>
</li>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template name="phrase" match="phrase">
<xsl:variable name="phrase">
<xsl:value-of select="concat('P',text())"/>
</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()"/>
</span>
</xsl:template>
<!-- Table Templates -->
<xsl:template name="table" match="table">
<table style="frame-{current()/@frame} width-{translate(current()/@width,'%','')}">
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="tgroup">
<colgroup>
<xsl:apply-templates select=".//colspec"/>
</colgroup>
<xsl:apply-templates select="child::node()[not(self::colspec)]"/>
</xsl:template>
<xsl:template name="tbody" match="tgroup/tbody">
<tbody>
<xsl:for-each select="current()/row">
<xsl:call-template name="row"/>
</xsl:for-each>
</tbody>
</xsl:template>
<xsl:template name="thead" match="tgroup/thead">
<xsl:for-each select="current()/row">
<thead>
<tr>
<xsl:for-each select="current()/entry">
<xsl:call-template name="headentry"/>
</xsl:for-each>
</tr>
</thead>
</xsl:for-each>
</xsl:template>
<xsl:template name="colspec" match="colspec">
<col class="colnum-{current()/@colnum} colname-{current()/@colname} colwidth-{translate(current()/@colwidth,'%','')}"/>
</xsl:template>
<xsl:template name="row" match="tbody/row">
<tr>
<xsl:for-each select="current()/entry">
<xsl:call-template name="entry"/>
</xsl:for-each>
</tr>
</xsl:template>
<xsl:template name="entry" match="entry">
<xsl:variable name="count">
<xsl:value-of select="count(preceding-sibling::* | following-sibling::*)"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="$count < 2">
<xsl:if test="position()=1">
<td>
<div class="para align-center">
<xsl:value-of select="para[position()=1]"/>
</div>
</td>
<td>
<div class="para">
<xsl:value-of select="following-sibling::node()"/>
</div>
</td>
</xsl:if>
</xsl:when>
<xsl:when test="$count > 1">
<td>
<div class="para">
<xsl:apply-templates/>
</div>
</td>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template name="headentry">
<th>
<xsl:if test="translate(current()/@namest,'col','') != translate(current()/@nameend,'col','')">
<xsl:variable name="colspan">
<xsl:value-of select="translate(current()/@nameend,'col','') - translate(current()/@namest,'col','') + 1"/>
</xsl:variable>
<xsl:attribute name="colspan">
<xsl:value-of select="$colspan"></xsl:value-of>
</xsl:attribute>
</xsl:if>
<div class="para">
<xsl:value-of select="current()/para/text()"/>
</div>
</th>
</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">
<li class="item">
<xsl:apply-templates/>
</li>
</xsl:template>
<xsl:template name="orderitempara" match="item/para">
<div class="para">
<span class="item-num">
<xsl:if test="position()=1">
<xsl:value-of select="parent::item[1]/@num"/>
</xsl:if>
</span>
<xsl:text> </xsl:text>
<xsl:apply-templates/>
</div>
</xsl:template>
<!--List templates Complete -->
<!-- Paragraph templates Complete -->
<!-- Footnote Templates-->
<xsl:template match="footnote">
<sup>
<a>
<xsl:attribute name="name">
<xsl:text>f</xsl:text>
<xsl:value-of select="@num"/>
</xsl:attribute>
<xsl:attribute name="href">
<xsl:text>#ftn.</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="normalize-space(@num)"/>
</a>
</sup>
</xsl:template>
<xsl:template match="footnote" mode="footnote">
<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>
<div class="para">
<xsl:variable name="new">
<xsl:value-of select="current()"/>
</xsl:variable>
<xsl:variable name="new1">
<xsl:value-of select="substring(substring-after(current(),'paragraph'),2,5)"/>
</xsl:variable>
<xsl:variable name="roo">
<xsl:value-of select="substring(//@num,2)"/>
</xsl:variable>
<xsl:variable name="befTex">
<xsl:value-of select="substring-before(current(),'paragraph')"/>
</xsl:variable>
<xsl:variable name="before">
<xsl:value-of select="substring-before($new1,'.')"/>
</xsl:variable>
<xsl:variable name="after">
<xsl:value-of select="substring(substring-after($new1,'.'),1,3)"/>
</xsl:variable>
<xsl:variable name="centTex">
<xsl:value-of select="substring(substring-after(current(),$after),1)"/>
</xsl:variable>
<xsl:variable name="pCon">
<xsl:value-of select="concat('paragraph',' ',$before,'.',$after)"/>
</xsl:variable>
<xsl:variable name="tes">
<xsl:if test="contains($centTex,'Chapter')">
<xsl:value-of select="concat(' ',substring(substring-before($centTex,'Chapter'),2))"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="ChapNu">
<xsl:value-of select="normalize-space(substring(substring-after(current(),'Chapter'),1,2))"/>
</xsl:variable>
<xsl:variable name="ChapNuC">
<xsl:value-of select="concat('er:#BVI_CH_0',$ChapNu,'/BVI_CH_0',$ChapNu)"/>
</xsl:variable>
<xsl:variable name="curSel">
<xsl:value-of select="concat('#P',$before,'-',$after)"/>
</xsl:variable>
<xsl:variable name="ChapCon">
<xsl:value-of select="concat('Chapter',' ',substring(substring-after(current(),'Chapter'),2,1))"/>
</xsl:variable>
<xsl:variable name="conc1">
<xsl:value-of select="concat('er:#BVI_CH_0',$before,'/P',$before,'-',$after)"/>
</xsl:variable>
<xsl:value-of select="$befTex"/>
<xsl:choose>
<xsl:when test="contains(substring(substring-after($new,'paragraph'),1,3),'.')">
<xsl:choose>
<xsl:when test="$before = $roo">
<a href="{$curSel}">
<xsl:value-of select="$pCon"/>
</a>
</xsl:when>
<xsl:otherwise>
<a href="{$conc1}">
<xsl:value-of select="$pCon"/>
</a>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="$tes"/>
<xsl:if test="contains($centTex,'Chapter')">
<a href="{$ChapNuC}">
<xsl:value-of select="$ChapCon"/>
</a>
</xsl:if>
<xsl:text>.</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</div>
</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:variable name="fontStyle">
<xsl:value-of select="concat('font-style-',@font-style)"/>
</xsl:variable>
<span class="{$fontStyle}">
<xsl:apply-templates/>
</span>
</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>
实际上,我得到了正确的输出,但是在 para 和脚注编号之间有一个额外的空格。请让我知道如何删除该空间。下面是我得到的输出。
<span class="phrase">1.001</span> The presentation of a petition for the winding-up of the company by the court does not in itself affect the powers or position of the directors who may continue to operate the business of the company.<sup>
<a name="f1" href="#ftn.1" class="tr_ftn">1</a>
谢谢