0

私は以下のxmlを持っています。

XML ドキュメント

そして以下の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:variable name="ThisDocument" select="document('')"/>
    <xsl:output method="html"/>
    <xsl:template match="/">

        <xsl:text disable-output-escaping="yes">&lt;!DOCTYPE html&gt;</xsl:text>
        <html>
            <head>

                <title>
                    <xsl:value-of select="concat('Appendix ', substring-before(substring-after(part/chapter/title, ' '),' '))"></xsl:value-of>
                </title>
                <link rel="stylesheet" href="C:\Documents and Settings\u0138039\Desktop\XML COnversion\Book 5\Book-5(original)\assets\main.css" type="text/css"/>
            </head>
            <body>
            <xsl:apply-templates/>

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


<xsl:template match="part/chapter/title">

<xsl:variable name="check">
<xsl:value-of select="string-length(substring-before(substring-after(.,' '),' '))"/>
</xsl:variable>

<section class="tr_chapter">
<div class="cha_app chapter">
<xsl:choose>
    <xsl:when test="$check=1">
    <a name="{concat('CHA_APP_0', substring-before(substring-after(., ' '),' '))}" class="tr_toc_anchor"> </a>
    </xsl:when>
    <xsl:otherwise>
<a name="{concat('CHA_APP_', substring-before(substring-after(., ' '),' '))}" class="tr_toc_anchor">  </a>  
    </xsl:otherwise>
</xsl:choose>

<div class="chapter-title">
<xsl:value-of select="concat('Appendix ', substring-before(substring-after(., ' '),' '))"></xsl:value-of>
</div>
<div class="chapter-subtitle">
<xsl:value-of select="substring-after(substring-after(.,' '),' ')"></xsl:value-of>

</div>
<div class="chapter-subtitle">
<xsl:value-of select="following-sibling::subtitle"/>
</div>
<xsl:apply-templates select="following-sibling::section"/>
</div>

        </section>
</xsl:template>

<xsl:template match="section">
<div class="section-sect1">
<a name="{concat('APP_01-SEC-',substring-before(substring-after(./title,' '), ' '))}">
</a>

<div class="section-title">


<xsl:value-of select="concat('Chapter ',substring-before(substring-after(./title,' '),' '),' ')"/>
 <xsl:text disable-output-escaping="yes">&lt;br/&gt;</xsl:text>
<xsl:value-of select="substring-after(substring-after(./title,' '),' ')"/>
</div>
<xsl:apply-templates select="child::node()[not(self::title)]"/>
</div>

</xsl:template>
<xsl:template match="para">
<div class="para">

<xsl:apply-templates/>
</div>
</xsl:template>


<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">
        <xsl:choose>
    <xsl:when test="parent::item/@num">
         <div class="para">

            <xsl:choose>
                <xsl:when test="position()=1">

                    <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/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:apply-templates/>
                </xsl:otherwise>
            </xsl:choose>

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

<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: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:stylesheet>

この xslt を xml で実行しているとき。ループを使用していませんが、コンテンツの繰り返しがあります。私は本当に混乱していて、どこが間違っているのか理解できません。私にお知らせください。

このテキストを使用して、「この法律は、経済紛争が公平かつ迅速に仲裁され、保護されるようにするために制定された」を検索できます。

ありがとう

4

1 に答える 1