Xslt 1.0 需要替换特殊字符吗

Xslt 1.0 需要替换特殊字符吗,xslt-1.0,Xslt 1.0,嗨,我的xml文档的一部分如下。在这个xsm文档中,我有一个特殊字符“and”。我希望在使用XSL的HTML输出中,它们被替换为“and” 我正在搜索一个模板或任何其他替代方法来扫描我的整个XML文档,并在找到特殊字符的地方进行替换。现在它被一些白色框替换。请让我知道我是如何做到的 <para> <phrase>2.081</phrase> In creating a vehicle like a restricted pu

嗨,我的xml文档的一部分如下。在这个xsm文档中,我有一个特殊字符“and”。我希望在使用XSL的HTML输出中,它们被替换为“and”

我正在搜索一个模板或任何其他替代方法来扫描我的整个XML文档,并在找到特殊字符的地方进行替换。现在它被一些白色框替换。请让我知道我是如何做到的

<para>
            <phrase>2.081</phrase> In creating a vehicle like a restricted purpose company, the British Virgin Islands legislature was clearly concerned that, if such vehicles became widely used, there might be a risk that persons dealing with British Virgin Islands companies generally may have become concerned about the ability of companies to engage in day-to-day transactions. Accordingly, it sought to address these concerns by two slightly different mechanisms. Firstly, all restricted purpose companies were required to include the designation &#x201C;(SPV) Limited&#x201D; in their name, to make sure they were readily identifiable (even without reviewing their constitutional documents). Secondly, restricted purpose companies were made subject to licence fees significantly higher than regular companies to limit their use to appropriate cases.</para>
        <table frame="all" width="100%">
            <title>Comparing restricted purpose companies</title>
            <tgroup cols="3">
                <colspec colnum="1" colname="col1" colwidth="33%"/>
                <colspec colnum="2" colname="col2" colwidth="33%"/>
                <colspec colnum="3" colname="col3" colwidth="33%"/>
                <thead>

谢谢

因为我不确定您要在哪个位置计算所有的
元素这里是
count()
的解释:

您可以使用
count(节点集)
(将节点集替换为要计数的所需节点集)来计算从何处开始的所有节点。例如:

计算XML中的所有
元素:

    <?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:variable name="ThisDocument" select="document('')"/>
    <xsl:template match="/">


        <html>
            <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <title>
                    <xsl:value-of select="chapter/title"/>
                </title>
                <link rel="stylesheet" href="er:#css" type="text/css" />
            </head>

            <body>


                <xsl:apply-templates/>


                <hr />
                <section class="tr_footnotes">
                    <xsl:apply-templates select="//footnote" mode="footnote"/>
                </section>

            </body>
        </html>
    </xsl:template>



    <xsl:template match="chapter">
        <section>
            <div class="chapter">
                <a name="BVI-CH-{@num}" />
                <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="concat('Chapter ',$cnum,' ')"/>
</span>
                <xsl:apply-templates/>
            </div></div>
        </section>
    </xsl:template>

    <xsl:template match="chapter/para">
        <div class="para align-right">
            <span class="format-smallcaps">Para</span>.
        </div>
    </xsl:template>

    <!-- Index templates -->
    <xsl:template name="toc" match="chapter/toc">
        <div class="toc">
            <xsl:call-template name="toc-part"></xsl:call-template>
        </div>
    </xsl:template>
    <xsl:template name="toc-part" match="chapter/toc/toc-part">
        <div class="toc-part">
            <xsl:call-template name="toc-div"></xsl:call-template>
        </div>
    </xsl:template>
    <xsl:template name="toc-div" match="chapter/toc/toc-part/toc-div">
        <table class="toc-div">
            <tbody>
                <xsl:for-each select="current()/toc-part/toc-div/*">
                    <xsl:call-template name="toc-item"></xsl:call-template>
                </xsl:for-each>
            </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="itemlevel">
            <xsl:value-of select="$ThisDocument//ntw:nums[@num=$chapternumber]/@word"></xsl:value-of>
        </xsl:variable>
        <xsl:variable name="tocitemlevel">
            <xsl:value-of select="concat('toc-item-', $itemlevel,'-level')"></xsl:value-of>
        </xsl:variable>

        <table class="{$tocitemlevel}">
            <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="{$tocpgtag}">
                            <xsl:value-of select="current()/toc-pg"/>
                        </a>
                    </td>
                </tr>
            </tbody>
        </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="chapternumber">
            <!-- Get num attribute of parent node -->
            <xsl:value-of select="ancestor::chapter[1]/@num"/>
        </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-0', $sectnum)"/>
        </xsl:variable>
        <!-- Template Content  -->
        <div class="{$classname}">
            <a name="{$sectionname}"> </a>
            <div class="section-title">
                <span class="section-num">
                    <xsl:value-of select="@num"/>
                </span>
                <xsl:apply-templates/>
            </div>

        </div>
    </xsl:template>

    <!--<xsl:template name="para"  match="section/para">
    <xsl:variable name="count2">
    <xsl:value-of select="count[child::node()]"></xsl:value-of>
    </xsl:variable>    
    <xsl:choose>
                    <xsl:when test="$count2 &gt;=1">
                       <div class="para">
            <span class="phrase">
                <xsl:value-of select="current()/phrase"/>
            </span>

            <xsl:apply-templates/>
        </div>              
                    </xsl:when>
                    <xsl:when test="$count2 &lt; 1">
                     <span class="phrase">
                <xsl:value-of select="current()/phrase"/>
            </span>
                    <xsl:apply-templates mode="nr"/>
                    </xsl:when>
                </xsl:choose>


    </xsl:template>    -->







    <xsl:template name="para" match="section/para">
    <xsl:choose>
                    <xsl:when test="contains()">
                        <div class="para">
            <span class="phrase">
                <xsl:value-of select="current()/phrase"/>
            </span>

            <xsl:apply-templates/>
        </div>
                    </xsl:when>
                </xsl:choose>


    </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>

    </xsl:template>

    <!-- Table Templates  -->
    <xsl:template name ="table" match="table">

        <table style="frame-{current()/@frame} width-{translate(current()/@width,'%','')}"><colgroup></colgroup>

            <xsl:apply-templates/>

        </table>
    </xsl:template>
    <xsl:template name="tbody" match="tgroup/tbody">
        <tbody>
            <xsl:for-each select="current()/row">
                <xsl:call-template name="row"></xsl:call-template>
            </xsl:for-each>
        </tbody>
    </xsl:template>
    <xsl:template name="thead" match="tgroup/thead">
        <xsl:value-of select="name()"></xsl:value-of>
        <xsl:for-each select="current()/row">
            <xsl:value-of select="name()"></xsl:value-of>
            <tr>
                <xsl:for-each select="current()/entry">
                    <xsl:call-template name="headentry"></xsl:call-template>
                </xsl:for-each>
            </tr>
        </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:call-template>
            </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:value-of>
    </xsl:variable>
<xsl:choose>
    <xsl:when test="$count &lt; 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()"></xsl:value-of>
            </div>
        </td>
        </xsl:if>
    </xsl:when>
    <xsl:when test="$count &gt; 1">

        <td>
            <div class="para">

                <!--xsl:value-of select="current()"/-->  
               <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="orderedlist">

            <xsl:apply-templates/>

        </ol>
    </xsl:template>
    <xsl:template name="orderitem" match="orderlist/item">
        <li class="item">
            <xsl:apply-templates/>
        </li>
    </xsl:template>
    <xsl:template name="orderitempara" match="item/para">
        <xsl:variable name="itemnumber">
            <xsl:value-of select="parent::item[1]/@num"/>
        </xsl:variable><li class="item">
        <div class="para">
            <span class="item-num">
                <xsl:value-of select="parent::item[1]/@num"/>
            </span>

            <xsl:apply-templates></xsl:apply-templates>
        </div></li>
    </xsl:template>
    <!--List templates Complete -->

    <!-- Paragraph templates Complete -->



    <!-- Footnote Templates-->
    <xsl:template match="footnote"><sup>
        <a>
            <xsl:attribute name="name"><xsl:text>footnoteref</xsl:text><xsl:number level="any" count="footnote" format="1"/></xsl:attribute>
            <xsl:attribute name="href"><xsl:text>#footnote</xsl:text><xsl:number level="any" count="footnote" format="1"/></xsl:attribute>
            <xsl:attribute name="class">
                <xsl:text>tr_ftn</xsl:text><xsl:number level="any" count="footnote" format="1"/>
                </xsl:attribute>
                <xsl:number level="any" count="footnote" format="1"/>

        </a></sup>
    </xsl:template>
    <xsl:template match="footnote" mode="footnote"><sup>
        <li style="list-style-type:none;indent:0">
            <a>
                <xsl:attribute name="name"><xsl:text>footnote</xsl:text><xsl:number level="any" count="footnote" format="1"/></xsl:attribute>
                <xsl:attribute name="href"><xsl:text>#footnoteref</xsl:text><xsl:number level="any" count="footnote" format="1"/></xsl:attribute>
                <xsl:attribute name="class">
                <xsl:text>tr_ftn</xsl:text><xsl:number level="any" count="footnote" format="1"/>
                </xsl:attribute>
                    <xsl:number level="any" count="footnote" format="1"/>

            </a>
            <xsl:text> </xsl:text>
            <xsl:apply-templates/>
        </li></sup>
    </xsl:template>
    <xsl:template match="footnote/para/uri">
        <a>

        </a>
    </xsl:template>
    <!-- Footnote Templates Complete -->

    <xsl:template match="content-style">
        <xsl:choose>
            <xsl:when test="@format='smallcaps'">
                <xsl:value-of select="translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXZ','abcdefghijklmnopqrstuvwxyz')"/>
            </xsl:when>
            <xsl:when test="@format='superscript'">
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>



    <!-- Namespace ntw-->
    <ntw:nums num="01" word="first"></ntw:nums>
    <ntw:nums num="02" word="second"></ntw:nums>
    <ntw:nums num="03" word="third"></ntw:nums>
    <ntw:nums num="04" word="forth"></ntw:nums>
    <ntw:nums num="05" word="fifth"></ntw:nums>
    <ntw:nums num="06" word="sixth"></ntw:nums>
    <ntw:nums num="07" word="seventh"></ntw:nums>
    <ntw:nums num="08" word="eighth"></ntw:nums>
    <ntw:nums num="09" word="nighth"></ntw:nums>
    <ntw:nums num="10" word="tenth"></ntw:nums>
    <!-- Namespace ntw ends -->

</xsl:stylesheet>
<xsl:value-of select="count(//colspec)" />
<xsl:value-of select="count(colspec)" />
<xsl:value-of select="count(tgroup/colspec)" />

计算当前路径中的所有
元素:

    <?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:variable name="ThisDocument" select="document('')"/>
    <xsl:template match="/">


        <html>
            <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <title>
                    <xsl:value-of select="chapter/title"/>
                </title>
                <link rel="stylesheet" href="er:#css" type="text/css" />
            </head>

            <body>


                <xsl:apply-templates/>


                <hr />
                <section class="tr_footnotes">
                    <xsl:apply-templates select="//footnote" mode="footnote"/>
                </section>

            </body>
        </html>
    </xsl:template>



    <xsl:template match="chapter">
        <section>
            <div class="chapter">
                <a name="BVI-CH-{@num}" />
                <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="concat('Chapter ',$cnum,' ')"/>
</span>
                <xsl:apply-templates/>
            </div></div>
        </section>
    </xsl:template>

    <xsl:template match="chapter/para">
        <div class="para align-right">
            <span class="format-smallcaps">Para</span>.
        </div>
    </xsl:template>

    <!-- Index templates -->
    <xsl:template name="toc" match="chapter/toc">
        <div class="toc">
            <xsl:call-template name="toc-part"></xsl:call-template>
        </div>
    </xsl:template>
    <xsl:template name="toc-part" match="chapter/toc/toc-part">
        <div class="toc-part">
            <xsl:call-template name="toc-div"></xsl:call-template>
        </div>
    </xsl:template>
    <xsl:template name="toc-div" match="chapter/toc/toc-part/toc-div">
        <table class="toc-div">
            <tbody>
                <xsl:for-each select="current()/toc-part/toc-div/*">
                    <xsl:call-template name="toc-item"></xsl:call-template>
                </xsl:for-each>
            </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="itemlevel">
            <xsl:value-of select="$ThisDocument//ntw:nums[@num=$chapternumber]/@word"></xsl:value-of>
        </xsl:variable>
        <xsl:variable name="tocitemlevel">
            <xsl:value-of select="concat('toc-item-', $itemlevel,'-level')"></xsl:value-of>
        </xsl:variable>

        <table class="{$tocitemlevel}">
            <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="{$tocpgtag}">
                            <xsl:value-of select="current()/toc-pg"/>
                        </a>
                    </td>
                </tr>
            </tbody>
        </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="chapternumber">
            <!-- Get num attribute of parent node -->
            <xsl:value-of select="ancestor::chapter[1]/@num"/>
        </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-0', $sectnum)"/>
        </xsl:variable>
        <!-- Template Content  -->
        <div class="{$classname}">
            <a name="{$sectionname}"> </a>
            <div class="section-title">
                <span class="section-num">
                    <xsl:value-of select="@num"/>
                </span>
                <xsl:apply-templates/>
            </div>

        </div>
    </xsl:template>

    <!--<xsl:template name="para"  match="section/para">
    <xsl:variable name="count2">
    <xsl:value-of select="count[child::node()]"></xsl:value-of>
    </xsl:variable>    
    <xsl:choose>
                    <xsl:when test="$count2 &gt;=1">
                       <div class="para">
            <span class="phrase">
                <xsl:value-of select="current()/phrase"/>
            </span>

            <xsl:apply-templates/>
        </div>              
                    </xsl:when>
                    <xsl:when test="$count2 &lt; 1">
                     <span class="phrase">
                <xsl:value-of select="current()/phrase"/>
            </span>
                    <xsl:apply-templates mode="nr"/>
                    </xsl:when>
                </xsl:choose>


    </xsl:template>    -->







    <xsl:template name="para" match="section/para">
    <xsl:choose>
                    <xsl:when test="contains()">
                        <div class="para">
            <span class="phrase">
                <xsl:value-of select="current()/phrase"/>
            </span>

            <xsl:apply-templates/>
        </div>
                    </xsl:when>
                </xsl:choose>


    </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>

    </xsl:template>

    <!-- Table Templates  -->
    <xsl:template name ="table" match="table">

        <table style="frame-{current()/@frame} width-{translate(current()/@width,'%','')}"><colgroup></colgroup>

            <xsl:apply-templates/>

        </table>
    </xsl:template>
    <xsl:template name="tbody" match="tgroup/tbody">
        <tbody>
            <xsl:for-each select="current()/row">
                <xsl:call-template name="row"></xsl:call-template>
            </xsl:for-each>
        </tbody>
    </xsl:template>
    <xsl:template name="thead" match="tgroup/thead">
        <xsl:value-of select="name()"></xsl:value-of>
        <xsl:for-each select="current()/row">
            <xsl:value-of select="name()"></xsl:value-of>
            <tr>
                <xsl:for-each select="current()/entry">
                    <xsl:call-template name="headentry"></xsl:call-template>
                </xsl:for-each>
            </tr>
        </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:call-template>
            </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:value-of>
    </xsl:variable>
<xsl:choose>
    <xsl:when test="$count &lt; 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()"></xsl:value-of>
            </div>
        </td>
        </xsl:if>
    </xsl:when>
    <xsl:when test="$count &gt; 1">

        <td>
            <div class="para">

                <!--xsl:value-of select="current()"/-->  
               <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="orderedlist">

            <xsl:apply-templates/>

        </ol>
    </xsl:template>
    <xsl:template name="orderitem" match="orderlist/item">
        <li class="item">
            <xsl:apply-templates/>
        </li>
    </xsl:template>
    <xsl:template name="orderitempara" match="item/para">
        <xsl:variable name="itemnumber">
            <xsl:value-of select="parent::item[1]/@num"/>
        </xsl:variable><li class="item">
        <div class="para">
            <span class="item-num">
                <xsl:value-of select="parent::item[1]/@num"/>
            </span>

            <xsl:apply-templates></xsl:apply-templates>
        </div></li>
    </xsl:template>
    <!--List templates Complete -->

    <!-- Paragraph templates Complete -->



    <!-- Footnote Templates-->
    <xsl:template match="footnote"><sup>
        <a>
            <xsl:attribute name="name"><xsl:text>footnoteref</xsl:text><xsl:number level="any" count="footnote" format="1"/></xsl:attribute>
            <xsl:attribute name="href"><xsl:text>#footnote</xsl:text><xsl:number level="any" count="footnote" format="1"/></xsl:attribute>
            <xsl:attribute name="class">
                <xsl:text>tr_ftn</xsl:text><xsl:number level="any" count="footnote" format="1"/>
                </xsl:attribute>
                <xsl:number level="any" count="footnote" format="1"/>

        </a></sup>
    </xsl:template>
    <xsl:template match="footnote" mode="footnote"><sup>
        <li style="list-style-type:none;indent:0">
            <a>
                <xsl:attribute name="name"><xsl:text>footnote</xsl:text><xsl:number level="any" count="footnote" format="1"/></xsl:attribute>
                <xsl:attribute name="href"><xsl:text>#footnoteref</xsl:text><xsl:number level="any" count="footnote" format="1"/></xsl:attribute>
                <xsl:attribute name="class">
                <xsl:text>tr_ftn</xsl:text><xsl:number level="any" count="footnote" format="1"/>
                </xsl:attribute>
                    <xsl:number level="any" count="footnote" format="1"/>

            </a>
            <xsl:text> </xsl:text>
            <xsl:apply-templates/>
        </li></sup>
    </xsl:template>
    <xsl:template match="footnote/para/uri">
        <a>

        </a>
    </xsl:template>
    <!-- Footnote Templates Complete -->

    <xsl:template match="content-style">
        <xsl:choose>
            <xsl:when test="@format='smallcaps'">
                <xsl:value-of select="translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXZ','abcdefghijklmnopqrstuvwxyz')"/>
            </xsl:when>
            <xsl:when test="@format='superscript'">
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>



    <!-- Namespace ntw-->
    <ntw:nums num="01" word="first"></ntw:nums>
    <ntw:nums num="02" word="second"></ntw:nums>
    <ntw:nums num="03" word="third"></ntw:nums>
    <ntw:nums num="04" word="forth"></ntw:nums>
    <ntw:nums num="05" word="fifth"></ntw:nums>
    <ntw:nums num="06" word="sixth"></ntw:nums>
    <ntw:nums num="07" word="seventh"></ntw:nums>
    <ntw:nums num="08" word="eighth"></ntw:nums>
    <ntw:nums num="09" word="nighth"></ntw:nums>
    <ntw:nums num="10" word="tenth"></ntw:nums>
    <!-- Namespace ntw ends -->

</xsl:stylesheet>
<xsl:value-of select="count(//colspec)" />
<xsl:value-of select="count(colspec)" />
<xsl:value-of select="count(tgroup/colspec)" />

从您现在位于元素下方的路径中计算所有
元素:

    <?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:variable name="ThisDocument" select="document('')"/>
    <xsl:template match="/">


        <html>
            <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <title>
                    <xsl:value-of select="chapter/title"/>
                </title>
                <link rel="stylesheet" href="er:#css" type="text/css" />
            </head>

            <body>


                <xsl:apply-templates/>


                <hr />
                <section class="tr_footnotes">
                    <xsl:apply-templates select="//footnote" mode="footnote"/>
                </section>

            </body>
        </html>
    </xsl:template>



    <xsl:template match="chapter">
        <section>
            <div class="chapter">
                <a name="BVI-CH-{@num}" />
                <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="concat('Chapter ',$cnum,' ')"/>
</span>
                <xsl:apply-templates/>
            </div></div>
        </section>
    </xsl:template>

    <xsl:template match="chapter/para">
        <div class="para align-right">
            <span class="format-smallcaps">Para</span>.
        </div>
    </xsl:template>

    <!-- Index templates -->
    <xsl:template name="toc" match="chapter/toc">
        <div class="toc">
            <xsl:call-template name="toc-part"></xsl:call-template>
        </div>
    </xsl:template>
    <xsl:template name="toc-part" match="chapter/toc/toc-part">
        <div class="toc-part">
            <xsl:call-template name="toc-div"></xsl:call-template>
        </div>
    </xsl:template>
    <xsl:template name="toc-div" match="chapter/toc/toc-part/toc-div">
        <table class="toc-div">
            <tbody>
                <xsl:for-each select="current()/toc-part/toc-div/*">
                    <xsl:call-template name="toc-item"></xsl:call-template>
                </xsl:for-each>
            </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="itemlevel">
            <xsl:value-of select="$ThisDocument//ntw:nums[@num=$chapternumber]/@word"></xsl:value-of>
        </xsl:variable>
        <xsl:variable name="tocitemlevel">
            <xsl:value-of select="concat('toc-item-', $itemlevel,'-level')"></xsl:value-of>
        </xsl:variable>

        <table class="{$tocitemlevel}">
            <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="{$tocpgtag}">
                            <xsl:value-of select="current()/toc-pg"/>
                        </a>
                    </td>
                </tr>
            </tbody>
        </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="chapternumber">
            <!-- Get num attribute of parent node -->
            <xsl:value-of select="ancestor::chapter[1]/@num"/>
        </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-0', $sectnum)"/>
        </xsl:variable>
        <!-- Template Content  -->
        <div class="{$classname}">
            <a name="{$sectionname}"> </a>
            <div class="section-title">
                <span class="section-num">
                    <xsl:value-of select="@num"/>
                </span>
                <xsl:apply-templates/>
            </div>

        </div>
    </xsl:template>

    <!--<xsl:template name="para"  match="section/para">
    <xsl:variable name="count2">
    <xsl:value-of select="count[child::node()]"></xsl:value-of>
    </xsl:variable>    
    <xsl:choose>
                    <xsl:when test="$count2 &gt;=1">
                       <div class="para">
            <span class="phrase">
                <xsl:value-of select="current()/phrase"/>
            </span>

            <xsl:apply-templates/>
        </div>              
                    </xsl:when>
                    <xsl:when test="$count2 &lt; 1">
                     <span class="phrase">
                <xsl:value-of select="current()/phrase"/>
            </span>
                    <xsl:apply-templates mode="nr"/>
                    </xsl:when>
                </xsl:choose>


    </xsl:template>    -->







    <xsl:template name="para" match="section/para">
    <xsl:choose>
                    <xsl:when test="contains()">
                        <div class="para">
            <span class="phrase">
                <xsl:value-of select="current()/phrase"/>
            </span>

            <xsl:apply-templates/>
        </div>
                    </xsl:when>
                </xsl:choose>


    </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>

    </xsl:template>

    <!-- Table Templates  -->
    <xsl:template name ="table" match="table">

        <table style="frame-{current()/@frame} width-{translate(current()/@width,'%','')}"><colgroup></colgroup>

            <xsl:apply-templates/>

        </table>
    </xsl:template>
    <xsl:template name="tbody" match="tgroup/tbody">
        <tbody>
            <xsl:for-each select="current()/row">
                <xsl:call-template name="row"></xsl:call-template>
            </xsl:for-each>
        </tbody>
    </xsl:template>
    <xsl:template name="thead" match="tgroup/thead">
        <xsl:value-of select="name()"></xsl:value-of>
        <xsl:for-each select="current()/row">
            <xsl:value-of select="name()"></xsl:value-of>
            <tr>
                <xsl:for-each select="current()/entry">
                    <xsl:call-template name="headentry"></xsl:call-template>
                </xsl:for-each>
            </tr>
        </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:call-template>
            </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:value-of>
    </xsl:variable>
<xsl:choose>
    <xsl:when test="$count &lt; 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()"></xsl:value-of>
            </div>
        </td>
        </xsl:if>
    </xsl:when>
    <xsl:when test="$count &gt; 1">

        <td>
            <div class="para">

                <!--xsl:value-of select="current()"/-->  
               <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="orderedlist">

            <xsl:apply-templates/>

        </ol>
    </xsl:template>
    <xsl:template name="orderitem" match="orderlist/item">
        <li class="item">
            <xsl:apply-templates/>
        </li>
    </xsl:template>
    <xsl:template name="orderitempara" match="item/para">
        <xsl:variable name="itemnumber">
            <xsl:value-of select="parent::item[1]/@num"/>
        </xsl:variable><li class="item">
        <div class="para">
            <span class="item-num">
                <xsl:value-of select="parent::item[1]/@num"/>
            </span>

            <xsl:apply-templates></xsl:apply-templates>
        </div></li>
    </xsl:template>
    <!--List templates Complete -->

    <!-- Paragraph templates Complete -->



    <!-- Footnote Templates-->
    <xsl:template match="footnote"><sup>
        <a>
            <xsl:attribute name="name"><xsl:text>footnoteref</xsl:text><xsl:number level="any" count="footnote" format="1"/></xsl:attribute>
            <xsl:attribute name="href"><xsl:text>#footnote</xsl:text><xsl:number level="any" count="footnote" format="1"/></xsl:attribute>
            <xsl:attribute name="class">
                <xsl:text>tr_ftn</xsl:text><xsl:number level="any" count="footnote" format="1"/>
                </xsl:attribute>
                <xsl:number level="any" count="footnote" format="1"/>

        </a></sup>
    </xsl:template>
    <xsl:template match="footnote" mode="footnote"><sup>
        <li style="list-style-type:none;indent:0">
            <a>
                <xsl:attribute name="name"><xsl:text>footnote</xsl:text><xsl:number level="any" count="footnote" format="1"/></xsl:attribute>
                <xsl:attribute name="href"><xsl:text>#footnoteref</xsl:text><xsl:number level="any" count="footnote" format="1"/></xsl:attribute>
                <xsl:attribute name="class">
                <xsl:text>tr_ftn</xsl:text><xsl:number level="any" count="footnote" format="1"/>
                </xsl:attribute>
                    <xsl:number level="any" count="footnote" format="1"/>

            </a>
            <xsl:text> </xsl:text>
            <xsl:apply-templates/>
        </li></sup>
    </xsl:template>
    <xsl:template match="footnote/para/uri">
        <a>

        </a>
    </xsl:template>
    <!-- Footnote Templates Complete -->

    <xsl:template match="content-style">
        <xsl:choose>
            <xsl:when test="@format='smallcaps'">
                <xsl:value-of select="translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXZ','abcdefghijklmnopqrstuvwxyz')"/>
            </xsl:when>
            <xsl:when test="@format='superscript'">
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>



    <!-- Namespace ntw-->
    <ntw:nums num="01" word="first"></ntw:nums>
    <ntw:nums num="02" word="second"></ntw:nums>
    <ntw:nums num="03" word="third"></ntw:nums>
    <ntw:nums num="04" word="forth"></ntw:nums>
    <ntw:nums num="05" word="fifth"></ntw:nums>
    <ntw:nums num="06" word="sixth"></ntw:nums>
    <ntw:nums num="07" word="seventh"></ntw:nums>
    <ntw:nums num="08" word="eighth"></ntw:nums>
    <ntw:nums num="09" word="nighth"></ntw:nums>
    <ntw:nums num="10" word="tenth"></ntw:nums>
    <!-- Namespace ntw ends -->

</xsl:stylesheet>
<xsl:value-of select="count(//colspec)" />
<xsl:value-of select="count(colspec)" />
<xsl:value-of select="count(tgroup/colspec)" />

我不清楚您关于“HTML”的问题。请记住,HTML和XML有一些特殊字符,您永远无法在源代码中显示这些字符。请参阅下一步:

HTML特殊字符: XML特殊字符:


希望对您有所帮助!

我认为您的问题不正确且不完整。您说您想将“替换为”(相同)。您能回顾/编辑您的问题吗?您还说现在“替换为白色的蝴蝶结(空格?)。您也可以发布您当前的XSLT吗?嗨,马克,我已经更新了我的XSLT,很抱歉,我希望引用的方式像曲线引号一样时尚。