2013-07-11 102 views
0

我有下面的xslt。for循環沒有按預期結束

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

輸出我越來越有一種「甘康元AIK,大欖永豐和Ng學樂(陳阿都拉)對上訴人的複製和下一行「,因爲我希望它在第四點之後也只出現一次。即結束。請讓我知道如何實現這一點。

感謝

回答

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> 

我打電話給counsel.group在錯誤的地方。再次感謝。

Rakesh

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> 

在換每個你選擇的每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>元素沒有與之匹配的開頭。

+0

嗨@akash感謝您的回覆,但這並沒有奏效。 :-( – user2423959

+0

我的建議改變了什麼? –

+0

nop,它是這樣的:-( – user2423959