0

以下の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:template match="/">
    <html>
      <head>
        <xsl:text disable-output-escaping="yes"><![CDATA[</meta>]]></xsl:text>
        <link rel="stylesheet" href="C:\Documents and Settings\u0138039\Desktop\Process\main.css" type="text/css"></link>
      </head>
      <body>
        <xsl:apply-templates/>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="case">
    <xsl:apply-templates select="case.head"/>
  </xsl:template>
  <xsl:template match="case.head">
    <section class="sect1">
      <div class="para">
        <xsl:value-of select="./party.line/party[@role='Plaintiff']"/>

      </div>
    </section>
    <section class="sect1">
      <div class="para">
        <xsl:text disable-output-escaping="yes">V</xsl:text>
      </div>
    </section>
    <section class="sect1">
      <div class="para">
        <xsl:value-of select="./party.line/party[@role='Defendant']"/>
      </div>
    </section>
    <xsl:apply-templates select="case.ref.no.group | judge.line"/>
  </xsl:template>
<xsl:template match="para">
<div class="para">
<xsl:apply-templates/>
</div>
</xsl:template>

  <xsl:template match="case.ref.no.group">
    <section class="sect2">
      <xsl:text>Court of Appeal</xsl:text>
    </section>

    <xsl:text> - </xsl:text>
    <xsl:value-of select="case.ref.no[1]/prefix" />
    <xsl:text> Nos. </xsl:text>

    <xsl:for-each select="case.ref.no">
      <xsl:value-of select="number" />
      <xsl:text>-</xsl:text>
      <xsl:value-of select="year" />
      <xsl:if test="not(position() = 2)">
        <xsl:text> and </xsl:text>
      </xsl:if>
    </xsl:for-each>
    <!--<xsl:apply-templates/>-->
  </xsl:template>
  <xsl:template match="judge.line">
    <section class="sect3">
      <xsl:for-each select="judge">
        <xsl:value-of select="name"/>
        <xsl:if test="not(position() = last())">
          <xsl:text>,</xsl:text>
        </xsl:if>
      </xsl:for-each>
      <xsl:text> JJCA</xsl:text>
    </section>
    <xsl:apply-templates select="following-sibling::date.group"></xsl:apply-templates>
  </xsl:template>
  <xsl:template match="date.group">
    <section class="sect4">
      <div class="para">
        <xsl:value-of select="./date.line/date"/>
      </div>
    </section>
    <xsl:apply-templates select="//catchwords.group"/>
  </xsl:template>
  <xsl:template match="catchwords.group">
    <div class="y">
      <xsl:for-each select="catchwords/catchword">
        <xsl:choose>
          <xsl:when test="@level=1">
            <section class="sect2">
              <xsl:value-of select="."/>
            </section>
            <xsl:text disable-output-escaping="yes">-</xsl:text>
          </xsl:when>
          <xsl:otherwise>
            <xsl:for-each select=".">
              <xsl:value-of select="."></xsl:value-of>
              <xsl:if test="not(position() = last()-2)">
                <xsl:text disable-output-escaping="yes">-</xsl:text>
              </xsl:if>
            </xsl:for-each>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:for-each>
    </div>
    <xsl:apply-templates select="//headnotes"/>
  </xsl:template>
  <xsl:template match="headnotes/para">
    <xsl:choose>
      <xsl:when test="position()=1">
        <div class="x">
          <xsl:apply-templates></xsl:apply-templates>
        </div>
      </xsl:when>
      <xsl:otherwise>
        <div class="m">
          <xsl:apply-templates/>
        </div>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:apply-templates select="para.group"/>
  </xsl:template>
  <xsl:template match="para.group">
    <section class="sect1"><xsl:value-of select="./heading"/>
    </section>
     <xsl:for-each select="./para">
     <div class="ital">
    <xsl:apply-templates select="node()[not(self::label)]"/></div></xsl:for-each>
  </xsl:template>
  <xsl:template name="orderedlist" match="list">
    <ol class="eng-orderedlist orderedlist">
      <xsl:apply-templates select="list.item/label"/>
    </ol>
  </xsl:template>
  <xsl:template name="orderitempara" match="list.item/label">
    <li class="item">
 <div class="para">
      <span class="item-num">
        <xsl:value-of select="."/>
      </span>
        <xsl:apply-templates select="parent::list.item"/>
      </div>
    </li>
  </xsl:template>
  <xsl:template match="list.item">
    <xsl:variable name="a">
      <xsl:value-of select="./label"/>
    </xsl:variable>
    <xsl:for-each select=".">
    <xsl:apply-templates select="child::node()[not(self::label)]"/></xsl:for-each>
   <xsl:apply-templates select="//counsel.group"/>
  </xsl:template>
<xsl:template match="counsel.group" name="j">
<xsl:for-each select=".">
<div class="para-align left">
<xsl:value-of select="counsel.line"/></div>
</xsl:for-each>
<xsl:apply-templates select="//history"/>
</xsl:template>
<xsl:template match="history">
<div class="para-align left">
      <xsl:value-of select="./action"/>
<xsl:text>—&lt;/xsl:text>
   <xsl:for-each select="case.ref.no.group/case.ref.no">
    <xsl:value-of select="prefix"/>
    <xsl:text>-</xsl:text>
      <xsl:value-of select="number" />
      <xsl:text>-</xsl:text>
      <xsl:value-of select="year" />
      <xsl:if test="not(position() = 2)">
        <xsl:text> and </xsl:text>
      </xsl:if>
    </xsl:for-each></div>
</xsl:template>
<xsl:template match="emphasis">
    <xsl:choose>
      <xsl:when test="citetitle">
        <span class="font-style-italic">
          <xsl:apply-templates select="list.item"/>
        </span>
</xsl:when>
      <xsl:otherwise>
        <xsl:variable name="fontStyle">
          <xsl:value-of select="concat('font-style-',@type)"/>
        </xsl:variable>
        <span class="{$fontStyle}">
          <xsl:apply-templates/>
        </span>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
    </xsl:stylesheet>

以下のxsltに適用すると

  <case>
<counsel.group>
            <counsel.line>Gan Khong Aik, Tai Foong Lam and Ng Pok Yue (Abdullah Chan) for appellant</counsel.line>
            <counsel.line>Lim Siew Ming, Ong Yu Jian and Dhanial Ahmad (Raja, Darryl &amp; Loh) for respondents</counsel.line>
        </counsel.group>
        <case.ref.no.group>
            <case.ref.no>
                <prefix>Civil Appeal</prefix>
                <number>W-02-887</number>
                <year>2008</year>
            </case.ref.no>
            <case.ref.no>
                <prefix>Civil Appeal</prefix>
                <number>W-02-888</number>
                <year>2008</year>
            </case.ref.no>
            <history>
                <action>Appeals from High Court, Kuala Lumpur</action>
                <case.ref.no.group>
                    <case.ref.no>
                        <prefix>Originating Summon</prefix>
                        <number>D5(IP)-24-94</number>
                        <year>2008</year>
                    </case.ref.no>
                    <case.ref.no>
                        <prefix>Originating Motion</prefix>
                        <number>D5(IP)-25-7</number>
                        <year>2008</year>
                    </case.ref.no>
                </case.ref.no.group>
            </history>
        </case.ref.no.group>
    <para.group>
    <para><list.item>
                            <label>3.</label>&#9;
    <list>
                                <list.item>
                                    <label>(a)</label>&#9;The High Court judge was correct in his finding that Lian Bee was not a person aggrieved, considering the fact that QAF was the registered proprietor of the registered trade mark for 10 years. Gardenia&#x2019;s product sales using the registered trade mark had already reached RM50 million before Lian Bee started using the infringing trade mark. Apart from that, Lian Bee had not taken any steps to register the infringing trade mark. [<emphasis type="italic">see p 611 para 47 lines 4-15</emphasis>]</list.item>
                                <list.item>
                                    <label>(b)</label>&#9;Section 35 of the TMA provides that exclusive rights in relation to the registered trade mark is given to the registered proprietor. It does not provide for any protection or recognition for common law users as contended by Lian Bee. Considering the fact that the registered trade mark was lawfully registered and had been used by the registered user, it was unlikely that the registered trade mark could be a threat to Lian Bee&#x2019;s commercial activities. On the contrary, it was the infringing trade mark that posed a threat towards Gardenia&#x2019;s usage of the registered trade mark. [<emphasis type="italic">see p 611 para 48 line 16 - para 49 line 41</emphasis>]</list.item>
                            </list>
                        </list.item>
                        <list.item>
                            <label>4.</label>&#9;On the facts, QAF was registered as the proprietor of the registered trade mark for 10 years, i.e from 2001 to 2011. By virtue of the licensing agreement between QAF and Gardenia, Gardenia has the right to use the trade mark within the same period. Although the registration was done in 2004, by virtue of s 48(1)(e) of the TMA, it was clear that the period of the permitted use is to be for a period determined by the proprietor of the trade mark. There is nothing in s 46 of the TMA and reg 81(2) of the Trade Marks Regulations 1997 that may be construed to prevent the date of use of a registered trademark from being enforced retrospectively to a date prior to the application for registration. [<emphasis type="italic">see p 612 para 53 line 31 - p 613 para 56 line 26</emphasis>]</list.item>
                  </para> </para.group></case>

私が得ている出力は、「控訴人と次の行のガンコンアイク、タイフーンラム、ンポクユエ(アブドゥラチャン)」の重複です。つまり最後に。どうすればこれを達成できるか教えてください。

ありがとう

4

2 に答える 2

0

この投稿を見てくれてありがとう、私は解決策を見つけました。以下の通りです。

     <xsl:template match="para.group">
    <section class="sect1">
      <xsl:value-of select="./heading"/>
    </section>

    <xsl:for-each select="./para">
      <div class="ital">
        <xsl:apply-templates select="node()[not(self::label)]"/>
      </div>
    </xsl:for-each>
    <xsl:apply-templates select="//counsel.group"/>
  </xsl:template>


  <xsl:template name="orderedlist" match="list">
    <ol class="eng-orderedlist orderedlist">
      <xsl:apply-templates select="list.item/label"/>
    </ol>
  </xsl:template>






  <xsl:template name="orderitempara" match="list.item/label">



    <li class="item">
      <div class="para">
        <span class="item-num">

          <xsl:value-of select="."/>

        </span>

        <xsl:apply-templates select="parent::list.item"/>
      </div>
    </li>
  </xsl:template>

  <xsl:template match="list.item">
    <xsl:variable name="a">
      <xsl:value-of select="./label"/>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="./label">
        <xsl:apply-templates select="child::node()[not(self::label|case.ref)]"/>
      </xsl:when>

    </xsl:choose>

  </xsl:template>

  <xsl:template match="counsel.group" name="j">

    <xsl:for-each select=".">
      <div class="para">
        <xsl:value-of select="counsel.line"/>
      </div>
    </xsl:for-each>
    <xsl:apply-templates select="//history"/>
  </xsl:template>

私は間違った場所で Council.group に電話しました。再度、感謝します。

ラケシュ

于 2013-07-15T07:06:44.153 に答える
0

あなたの問題に対する答えはここにあります:

<xsl:template match="//counsel.group" name="j">
    <xsl:for-each select=".">
        <div class="para-align left">
            <xsl:value-of select="counsel.line"/></div>
    </xsl:for-each>
    <xsl:apply-templates select="//history"/>
</xsl:template>

for-each では、すべての Council.group; を選択しています。XML スニペットには 1 つしかありません。for-each は、子ノードである Council.line を選択する必要があります。それ以外の場合は、一度だけ実行され、最初の Council.line が選択されます。次のようになります。

<xsl:template match="counsel.group" name="j">
    <xsl:for-each select="counsel.line">
        <div class="para-align left">
            <xsl:value-of select="."/></div>
    </xsl:for-each>
    <xsl:apply-templates select="//history"/>
</xsl:template>

また、提供された XML スニペットの形式が正しくありません。最後の </list> 要素には、一致する開始点がありません。

于 2013-07-11T13:38:30.670 に答える