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\Per\NEW.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">V</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="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">
    <div class="section-sect3">
      <span class="font-style-bold">Court of Appeal</span>
      <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:if>
      </xsl:for-each>
    </div>
  </xsl:template>
  <xsl:template match="judge.line">
    <div class="section-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> JC</xsl:text>
    </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"/>
  </xsl:template>
  <xsl:template match="catchwords.group">
    <div class="y">
      <xsl:for-each select="catchwords/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="//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">
        <xsl:apply-templates select="node()[not(self::label)]"/>
    </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="following-sibling::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">
<div class="ital">
    <xsl:for-each select="./counsel.line">
      <div class="para">
        <xsl:value-of select="."/>
      </div>
    </xsl:for-each>
    <xsl:text disable-output-escaping="yes">Judgment received: December 4, 2008</xsl:text>
    </div>
    <xsl:apply-templates select="//ref.group"/>
  </xsl:template>

  <xsl:template match="ref.group/leg.mentioned">
    <div class="section-sect1">
      <xsl:text>Legislation mentioned in the judgment</xsl:text>
    </div>
    <xsl:for-each select="./leg.ref">
    <div class="nomar">
<xsl:value-of select="./@country"/>    
    </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:for-each>
    <div class="section-sect1">
    <xsl:text>Cases cited in the judgment</xsl:text>
    </div>
    <xsl:apply-templates select="//case.considered"/>
     <div class="section-sec1">
    <xsl:apply-templates select="//other.mentioned"/>
    </div>
  </xsl:template>

<xsl:template match="case.considered">
<xsl:for-each select=".">
      <xsl:if test="./case.ref">
      <div class="para">
        <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"/>


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

</xsl:template>

<xsl:template match="other.mentioned/other.ref">
<div class="para">
<xsl:value-of select="./author"/>
<xsl:text>, </xsl:text>
<span class="font-style-italic">
<xsl:value-of select="./book.title"/>
</span>
<xsl:text>, </xsl:text>
<xsl:value-of select="ed_vol"/>
<xsl:value-of select="./ref_grp/reference/pageno"/>
</div>
<xsl:apply-templates select="//judgment"/>
</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.group">
      --><!--<div class="para">
        <span class="new">
          <xsl:value-of select="./label"></xsl:value-of>
        </span>
        <xsl:value-of select="./text()"/>
      </div>
      <xsl:apply-templates select="./list"/>--><!--
      <xsl:apply-templates/>
    </xsl:for-each>-->
<xsl:apply-templates select="./judge.block/para.group"/>
</xsl:template>

<xsl:template match="judge.block/para.group">

<div class="section-sect1">
      <xsl:apply-templates select="./heading"/>
    </div>
    <xsl:for-each select="./para">
    <div class="para">
<span class="new">
    <xsl:value-of select="./label"/></span>
       <xsl:apply-templates select="./text()"/>
        </div>


        <xsl:if test="./block.quote">
        <xsl:for-each select="./block.quote/para.group">
        <div class="ali-itl">
            <xsl:value-of select="./heading"/>
        </div>
        <xsl:for-each select="./para.group">
        <div class="ali-itl">
            <xsl:value-of select="./heading"/>
        </div>
        <div class="extract">
        <div class="para">
            <xsl:apply-templates select="./para"/>
        </div></div>
        </xsl:for-each>
        </xsl:for-each>
        </xsl:if>
    </xsl:for-each>
<xsl:for-each select="./para.group">
<xsl:if test="./para.group">

<xsl:choose>
    <xsl:when test="not(./para)">
        <div class="ital">
            <xsl:apply-templates select="./heading"/>
        </div></xsl:when>
        <xsl:otherwise>
        <div class="ali-itl">
            <xsl:value-of select="./heading"/>
        </div>

        <div class="para">
            <span class="new">
            <xsl:value-of select="./para/label"/>
        </span>

            <xsl:value-of select="./para/text()"/>
        </div>
        </xsl:otherwise>
</xsl:choose>






        </xsl:if>
     </xsl:for-each>
    <xsl:if test="./block.quote">
        <xsl:for-each select="./block.quote/para.group">
        <div class="ali-itl">
            <xsl:value-of select="./heading"/>
        </div>
        <xsl:for-each select="./para.group">
        <div class="ali-itl">
            <xsl:value-of select="./heading"/>
        </div>
        <div class="extract">
        <div class="para">
        <div class="new">
        <xsl:value-of select="./para/label"/>
        </div>
            <xsl:apply-templates select="./para/text()"/>
        </div></div>
        </xsl:for-each>
        </xsl:for-each>
        </xsl:if>



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

当我在我的 xml 上使用它时,输出会跳过中间的内容(例如,我能够看到带有数字 [12] 的内容,然后它直接跳转到数字 [16] 中的内容,中间的内容是跳过)。xml 可以在以下链接中找到。 XML 文档。请让我知道我哪里出错了。

谢谢

4

1 回答 1

0

从您提供的信息中很难分辨,但我认为您的问题来自这样一个事实,即带有“标签”13-15 的“para”元素实际上位于第一个嵌套的第二个para.group 元素中。您的模板可能只匹配直接在“para.group”元素中的“para”元素,而不是嵌套的“para.group”元素。

作为一个局外人,如果不花太多时间来分析你提供的大量输入,基本上是不可能的,这可能就是为什么你直到现在还没有收到另一个答案的原因。

于 2013-07-17T16:39:02.697 回答