2014-04-21 37 views
0

我有下面的XML。節點沒有被抓到,雖然路徑被給出

<?xml version="1.0" encoding="UTF-8"?> 
<case lang="en" type="Report" source="original"> 
    <case.head corrigendum="no"> 
     <party.line corrigendum="no" lang="en"> 
      <party role="Plaintiff">Da Costa</party> 
      <party role="Defendant">Yih Lorenzo</party> 
     </party.line> 
     <citation.group> 
      <primary.citation>[2014] 2 HKLRD 246</primary.citation> 
      <parallel.citation type="Unreported">[2014] HKEC 356</parallel.citation> 
      <parallel.citation type="West.serial">2032232950</parallel.citation> 
      <parallel.citation type="WL.cite">2014 WL 6334</parallel.citation> 
     </citation.group> 
     <court.line> 
      <court type="court">CA</court> 
     </court.line> 
     <case.ref.no.group> 
      <case.ref.no> 
       <prefix>HCMP</prefix> 
       <number>2696</number> 
       <year>2013</year> 
      </case.ref.no> 
     </case.ref.no.group> 

     <judge.line lang="en" type="court"> 
      <judge> 
       <name>Kwan</name> 
       <job.title prefix="no">JA</job.title> 
      </judge> 
      <judge> 
       <name>Macrae</name> 
       <job.title prefix="no">JA</job.title> 
      </judge> 
     </judge.line> 
     <publication_date yyyymmdd="20140304"/> 
     <date.group lang="en"> 
      <date.line>Date of Decision on Costs: <date yyyymmdd="20140124" significance="judgment" type="Report">24 January 2014</date></date.line> 
     </date.group> 
     <counsel.group lang="en"> 
      <counsel.line>Written submissions by Ms Elizabeth Cheung, instructed by Reed Smith Richards Butler, for the 1st plaintiff/respondent (Mr Jose Miranda Da Costa Junior).</counsel.line> 
      <counsel.line>Written submissions by Mr Norman Nip, instructed by Laracy &amp; Co, for the 1st defendant/applicant (Mr Lorenzo Yih).</counsel.line> 
     </counsel.group> 
    </case.head> 
    <catchwords.group> 
     <catchwords type="Report" lang="en"> 
      <catchword level="1" index="yes" italic="no">Civil procedure</catchword> 
      <catchword level="2" index="yes" italic="no">costs</catchword> 
      <catchword level="3" index="yes" italic="no">indemnity costs</catchword> 
      <catchword index="yes" italic="no">discretion to award indemnity costs not fettered or circumscribed beyond requirement that taxation on indemnity basis must be appropriate</catchword> 
     </catchwords> 
     <catchwords type="Report" lang="zh"> 
      <catchword level="1" index="yes" italic="no">民事訴訟程序</catchword> 
      <catchword level="2" index="yes" italic="no">訟費</catchword> 
      <catchword level="3" index="yes" italic="no">按彌償基準的訟費</catchword> 
      <catchword index="yes" italic="no">判給彌償訟費的酌情決定權不受束縛或規限以免偏離按彌償基準評定必須適當的規定</catchword> 
     </catchwords> 
    </catchwords.group> 
    <headnotes lang="en"> 
     <para>D1’s application for leave </para> 
     <para>7 HKCFAR 114 applied). (See paras.2–4.)</para> 
     <para.group> 
      <heading>Application</heading> 
      <para>This was an applic</para> 
     </para.group> 
    </headnotes> 
    <ref.group> 
     <other.mentioned> 
      <other.ref type="Miscellaneous"><author>Practice Direction 14.3 (Costs)</author><book.title></book.title><ed_vol>para.13</ed_vol></other.ref> 
     </other.mentioned> 
    </ref.group> 
    <judgment lang="en"> 
     <judge.block> 
      <heading align="left"><judgename>Kwan JA</judgename> (giving the decision of the Court)</heading> 
      <para><label>1.</label> In our decision 
      <para><label>3.</label> We do not agree that the court’s discretion to order indemnity costs should be fettered in the manner as contended. This discretion is not to be fettered or circumscribed beyond the requirement that taxation on an indemnity basis must be appropriate (
      <case.considered> 
        <case.ref BVtable="yes" annotation="applied"> 
         <citetitle type="case" full="Town Planning Board v Society for Protection of the Harbour Ltd (No 2)" legtype="ord">Town Planning Board v Society for Protection of the Harbour Ltd (No 2)</citetitle> 
         <citecitation full="(2004) 7 HKCFAR 114, [2004] 2 HKLRD 95">(2004) 7 HKCFAR 114</citecitation> 
        </case.ref> 
       </case.considered>, 124 [17]).</para> 

      <para><label>6.</label> On the b</para> 
      <para.group> 
       <heading align="right">Reported by Shin Su Wen</heading> 
      </para.group> 
     </judge.block> 
    </judgment> 
</case> 

及以下的XSLT。

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions"> 
    <xsl:output method="html"/> 
    <xsl:template match="/"> 
     <html> 
      <head> 
       <xsl:text disable-output-escaping="yes"><![CDATA[</meta>]]></xsl:text> 
       <link rel="stylesheet" href="C:\Users\u0138039\Desktop\Proview\Periodicals\XSLTS\NEW_289.css" type="text/css"></link> 
      </head> 
      <body> 
       <section class="tr_chapter"> 
        <div class="chapter"> 
         <xsl:apply-templates/> 
        </div> 
       </section> 
      </body> 
     </html> 
    </xsl:template> 

    <xsl:template match="case"> 
     <xsl:apply-templates select="case.head"/> 
    </xsl:template> 

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

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

    <xsl:template match="court.line"> 
     <hr></hr> 
     <br /> 
     <div class="align-center"> 
      <xsl:text>(</xsl:text> 
      <xsl:choose> 
       <xsl:when test="contains(./court/text(),'CFI')"> 
        <xsl:text>Court of First Instance</xsl:text> 
       </xsl:when> 
       <xsl:when test="contains(./court/text(),'CA')"> 
        <xsl:text>Court of Appeal</xsl:text> 
       </xsl:when> 
      </xsl:choose> 
      <xsl:text>)</xsl:text> 
     </div> 
    </xsl:template> 

    <xsl:template match="case.ref.no.group" name="new"> 
     <xsl:for-each select="case.ref.no"> 
      <div class="align-center"> 
       <xsl:text>(</xsl:text> 
       <xsl:choose> 
        <xsl:when test="contains(./prefix,'HCAJ')"> 
         <xsl:text>Admiralty Action No </xsl:text> 
        </xsl:when> 
        <xsl:when test="contains(./prefix,'HCAL')"> 
         <xsl:text>Constitutional and Administrative Law List No </xsl:text> 
        </xsl:when> 
        <xsl:when test="contains(./prefix,'CAAR')"> 
         <xsl:text>Application for Review No </xsl:text> 
        </xsl:when> 
        <xsl:when test="contains(./prefix,'CACV')"> 
         <xsl:text>Civil Appeal No </xsl:text> 
        </xsl:when> 
        <xsl:when test="contains(./prefix,'HCMP')"> 
         <xsl:text>Miscellaneous Proceedings No </xsl:text> 
        </xsl:when> 
        <xsl:when test="contains(./prefix,'HCMA')"> 
         <xsl:text>Magistracy Appeal No </xsl:text> 
        </xsl:when> 
       </xsl:choose> 
       <xsl:value-of select="./number"/> 
       <xsl:text> of </xsl:text> 
       <xsl:value-of select="./year"/> 
       <xsl:text>)</xsl:text> 
      </div> 
     </xsl:for-each> 
     <br /> 
     <hr></hr> 
    </xsl:template> 

    <xsl:template match="judge.line"> 
     <div class="section-sect3"> 
      <xsl:for-each select="judge"> 
       <xsl:value-of select="name"/> 
       <xsl:text> </xsl:text> 
       <xsl:value-of select="job.title"/> 
       <xsl:if test="not(position() = last())"> 
        <xsl:text>, </xsl:text> 
       </xsl:if> 
      </xsl:for-each> 
      <xsl:text> in </xsl:text> 
      <xsl:value-of select="concat(upper-case(substring(./@type,1,1)),substring(./@type,2))"/> 
     </div> 
     <xsl:apply-templates select="following-sibling::date.group"></xsl:apply-templates> 
    </xsl:template> 

    <xsl:template match="date.group"> 
     <div class="section-sect4"> 
      <div class="para"> 
       <xsl:value-of select="./date.line/date"/> 
      </div> 
     </div> 
     <xsl:apply-templates select="//catchwords.group/catchwords[@lang='en']"/> 
     <xsl:choose> 
            <xsl:when test="//ref.group/leg.mentioned"> 
            <xsl:apply-templates select="//ref.group" mode="x"/> 
            </xsl:when> 
            <xsl:otherwise> 
             <xsl:apply-templates select="//catchwords.group/catchwords[@lang='zh']"/> 
            </xsl:otherwise> 
           </xsl:choose> 

    </xsl:template> 

    <xsl:template match="catchwords.group/catchwords[@lang='en']"> 
     <div class="y"> 
      <xsl:for-each select="catchword"> 
       <xsl:choose> 
        <xsl:when test="@level=1"> 
         <br/> 
         <span class="font-style-bolditalic"> 
          <xsl:value-of select="."/> 
         </span> 
         <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()-1)"> 
           <xsl:text disable-output-escaping="yes"> – </xsl:text> 
          </xsl:if> 
         </xsl:for-each> 
        </xsl:otherwise> 
       </xsl:choose> 
      </xsl:for-each> 
     </div> 
    </xsl:template> 

    <xsl:template match="ref.group/leg.mentioned" mode="x"> 

    <div class="para"><xsl:text>[</xsl:text> 
     <xsl:for-each select="./leg.ref"> 
      <xsl:if test="./@considered='yes'"> 

        <xsl:value-of select="citetitle"/> 
        <xsl:text>, </xsl:text> 
        <xsl:for-each select="./leg.ptr.group/leg.ptr"> 
         <xsl:value-of select="."/> 
         <xsl:if test="not(position() = last())"> 
          <xsl:text disable-output-escaping="yes">, </xsl:text> 
         </xsl:if> 
         <xsl:text>; </xsl:text> 
        </xsl:for-each> 

      </xsl:if> 
     </xsl:for-each> 
     <xsl:text>]</xsl:text></div> 

     <xsl:apply-templates select="//catchwords.group/catchwords[@lang='zh']"/> 
    </xsl:template> 

    <xsl:template match="catchwords.group/catchwords[@lang='zh']"> 

     <div class="y"> 
      <xsl:for-each select="catchword"> 
       <xsl:choose> 
        <xsl:when test="@level=1"> 
         <br/> 
         <span class="font-style-bolditalic"> 
          <xsl:value-of select="."/> 
         </span> 
         <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()-1)"> 
           <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="../following-sibling::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"> 
     <div class="section-sect1"> 
      <xsl:value-of select="./heading"/> 
     </div> 
     <xsl:for-each select="./para"> 
      <div class="para"> 
       <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:choose> 
         <xsl:when test="./case.considered"> 
          <xsl:apply-templates/> 
         </xsl:when> 
         <xsl:otherwise> 
          <xsl:value-of select="."/> 
         </xsl:otherwise> 
        </xsl:choose> 
       </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="./counsel.line"> 
      <div class="para"> 
       <xsl:value-of select="."/> 
      </div> 
     </xsl:for-each> 
     <xsl:if test="../following-sibling::ref.group/leg.mentioned"> 
              <xsl:apply-templates select="../following-sibling::ref.group/leg.mentioned" mode="y"/> 
           </xsl:if> 

    </xsl:template> 

    <xsl:template match="ref.group/leg.mentioned" mode="y"> 
     <xsl:for-each select="./leg.ref"> 
      <xsl:if test="./@considered='no'"> 
       <div class="section-sect1"> 
        <xsl:text>Legislation mentioned in the judgment</xsl:text> 
       </div> 
       <div class="para"> 
        <xsl:value-of select="citetitle"/> 
        <xsl:text>, </xsl:text> 
        <xsl:for-each select="./leg.ptr.group/leg.ptr"> 
         <xsl:value-of select="."/> 
         <xsl:if test="not(position() = last())"> 
          <xsl:text disable-output-escaping="yes">, </xsl:text> 
         </xsl:if> 
        </xsl:for-each> 
       </div> 
      </xsl:if> 
     </xsl:for-each> 
     <xsl:choose> 
      <xsl:when test="following-sibling::other.mentioned"> 
       <div class="section-sect1"> 
        <xsl:text>Other materials mentioned in the judgment</xsl:text> 
       </div> 
       <xsl:apply-templates select="following-sibling::other.mentioned"/> 
      </xsl:when> 
      <xsl:otherwise> 
       <div class="section-sect1"> 
        <xsl:text>Case cited in the judgment</xsl:text> 
       </div> 
       <xsl:apply-templates select="case.considered"/> 
      </xsl:otherwise> 
     </xsl:choose> 
     <!-- <xsl:apply-templates select="../following-sibling::judgment"/>--> 
    </xsl:template> 

    <xsl:template match="other.mentioned"> 
     <xsl:for-each select="other.ref"> 
      <div class="para"> 
       <xsl:if test="./author/text()"> 
        <xsl:value-of select="./author"/> 
        <xsl:text>, </xsl:text> 
       </xsl:if> 
       <span class="font-style-italic"> 
        <xsl:value-of select="./book.title"/> 
       </span> 
       <xsl:text> </xsl:text> 
       <xsl:value-of select="./ed_vol"/> 
      </div> 
     </xsl:for-each> 
    </xsl:template> 

    <xsl:template match="case.considered"> 
     <xsl:for-each select="."> 
      <div class="para"> 
       <xsl:if test="./case.ref"> 
        <span class="font-style-italic"> 
         <xsl:value-of select="./case.ref/citetitle[@full]"/> 
        </span> 
        <xsl:text> </xsl:text> 
        <xsl:value-of select="./case.ref/citecitation/@full"/> 
       </xsl:if> 
      </div> 
     </xsl:for-each> 
    </xsl:template> 

    <xsl:template match="judgment"> 
     <div class="section-sect1"> 
      <xsl:value-of select="./judge.block/heading"/> 
     </div> 
     <xsl:for-each select="./judge.block/para"> 
      <div class="parax"> 
       <span class="new"> 
        <xsl:value-of select="./label"></xsl:value-of> 
       </span> 
       <xsl:apply-templates select="child::node()[not(self::label)]"/> 
      </div> 
     </xsl:for-each> 
     <xsl:for-each select="./judge.block/para.group"> 
      <xsl:if test="./heading"> 
      <xsl:choose> 
                <xsl:when test="./heading/@align"> 
                 <div class="{concat('para align-',./heading/@align)}"> 
       <span class="font-style-bold"> 
         <xsl:value-of select="./heading/text()"/>  
                </span> 

       </div> 
               </xsl:when> 
               <xsl:otherwise> 
                  <div class="para"> 
       <span class="font-style-bold"> 
         <xsl:value-of select="./heading/text()"/>  
                </span> 

       </div>        
                           </xsl:otherwise> 
               </xsl:choose> 

      </xsl:if> 
      <xsl:for-each select="para"> 
       <div class="parax"> 
        <span class="new"> 
         <xsl:value-of select="./label"></xsl:value-of> 
        </span> 
        <!--<xsl:value-of select="./text()"/>--> 
        <xsl:apply-templates select="child::node()[not(self::label)]"/> 
       </div> 
       <xsl:apply-templates select="./list"/> 
      </xsl:for-each> 
     </xsl:for-each> 
    </xsl:template> 

    <xsl:template match="block.quote"> 
     <xsl:choose> 
      <xsl:when test="./list"> 
       <xsl:apply-templates select="list"/> 
      </xsl:when> 
      <xsl:when test="./para"> 
       <xsl:for-each select="./para"> 
        <div class="extract"> 
         <xsl:apply-templates select="."/> 
        </div> 
       </xsl:for-each> 
      </xsl:when> 
      <xsl:when test="./para.group"> 
       <xsl:for-each select="./para.group"> 
        <div class="ali-itl"> 
         <xsl:value-of select="./heading"/> 
        </div> 
        <xsl:choose> 
         <xsl:when test="./para.group"> 
          <xsl:for-each select="./para.group"> 
           <xsl:if test="./para"> 
            <div class="ali-itl"> 
             <xsl:value-of select="./heading"/> 
            </div> 
            <div class="extract"> 
             <div class="para"> 
              <xsl:if test="./para/label"> 
               <div class="new"> 
                <xsl:value-of select="./para.group/para/label"/> 
               </div> 
              </xsl:if> 
              <xsl:apply-templates select="./para/text()"/> 
             </div> 
            </div> 
           </xsl:if> 
          </xsl:for-each> 
         </xsl:when> 
         <xsl:otherwise> 
          <div class="extract"> 
           <div class="para"> 
            <xsl:if test="./para/label"> 
             <div class="new"> 
              <xsl:value-of select="./para.group/para/label"/> 
             </div> 
            </xsl:if> 
            <xsl:apply-templates select="./para/text()"/> 
           </div> 
          </div> 
         </xsl:otherwise> 
        </xsl:choose> 
       </xsl:for-each> 
      </xsl:when> 
     </xsl:choose> 
    </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:when test="./@type"> 
       <xsl:variable name="fontStyle"> 
        <xsl:value-of select="concat('font-style-',@type)"/> 
       </xsl:variable> 
       <span class="{$fontStyle}"> 
        <xsl:apply-templates/> 
       </span> 
      </xsl:when> 
      <xsl:otherwise> 
       <xsl:apply-templates/> 
      </xsl:otherwise> 
     </xsl:choose> 
    </xsl:template> 

</xsl:stylesheet> 

這裏我把<xsl:apply-templates select="//case.considered"/>,也有這個模板,但模板沒有被調用,請讓我知道我要去哪裏錯了。

感謝

+1

是否有可能將XML和XSLT歸結爲非常重要?這個我們很多看!順便說一下:在上傳它之前,從這個看起來真實的生活樣本中刪除名字和數量也是一件好事! –

+0

嗨@MarcusRickert,謝謝你的迴應,我已經刪除了所有不需要的數據,但是使用了我的XML中的標籤。 – user2423959

回答

2

這是因爲你在節點ref.group/leg.mentioned下。您可以使用

<xsl:apply-templates select="../../judgment//case.considered"/> 
1

case.considered只在您的XML源出現一次,其背景:

/case[1]/judgment[1]/judge.block[1]/para[3] 

這意味着,如果你使用這些表達式,你可以選擇它:

  • //case.considered
  • case.considered./case.considered如果你在para的背景下。

在你的代碼中,你只能使用後者。你提到在你的問題中使用//case.considered。如果你這樣做,它會工作。如果在此塊替換爲case.considered//case.considered

<xsl:otherwise> 
    <div class="section-sect1"> 
     <xsl:text>Case cited in the judgment</xsl:text> 
    </div> 
    <xsl:apply-templates select="//case.considered"/> 
</xsl:otherwise> 

查找和插入您所期待的文本。

+0

我使用了 '但它沒有被調用。 – user2423959

+0

我無法重現您的問題。也許你應該回顧一下你的問題,並嘗試去適應它,把注意力集中在你正試圖解決的具體問題上 - 減少你包含的代碼量 - 並且包括你遇到問題的**實際**代碼(沒有' // case.considered'在你的代碼中)。 – helderdarocha

相關問題