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>

我得到的输出是上诉人的“Gan Khong Aik、Tai Foong Lam 和 Ng Pok Yue (Abdullah Chan) 的副本以及以下行”,因为我希望它在第 4 点之后也只出现一次。即最后。请让我知道如何实现这一目标。

谢谢

4

2 回答 2

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 中,您选择了每个 Counsel.group;在您的 XML 片段中只有一个。你的 for-each 应该选择子节点 Counsel.line...否则它只运行一次并选择第一个 Counsel.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 回答
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>

我在错误的地方打电话给咨询组。再次感谢。

拉克什

于 2013-07-15T07:06:44.153 回答