我有以下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>—</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 & 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>	
<list>
<list.item>
<label>(a)</label>	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’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>	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’s commercial activities. On the contrary, it was the infringing trade mark that posed a threat towards Gardenia’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>	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号之后也只出现一次点。即在最后。请告诉我如何实现这一目标。
由于
答案 0 :(得分: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代码段未正确形成。最后的&lt; / list&gt; element没有与之匹配的开口。
答案 1 :(得分: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>
我把the counsel.group称为错误的地方。再次感谢。
勒凯什