xslt 1.0 - for loop not ending as expected -


i have below 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 , 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> , </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> , </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> 

when apply below xslt

  <case> <counsel.group>             <counsel.line>gan khong aik, tai foong lam , ng pok yue (abdullah chan) appellant</counsel.line>             <counsel.line>lim siew ming, ong yu jian , dhanial ahmad (raja, darryl &amp; loh) 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 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 correct in finding lian bee not person aggrieved, considering fact qaf registered proprietor of registered trade mark 10 years. gardenia&#x2019;s product sales using registered trade mark had reached rm50 million before lian bee started using infringing trade mark. apart that, lian bee had not taken steps register 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 tma provides exclusive rights in relation registered trade mark given registered proprietor. not provide protection or recognition common law users contended lian bee. considering fact registered trade mark lawfully registered , had been used registered user, unlikely registered trade mark threat lian bee&#x2019;s commercial activities. on contrary, infringing trade mark posed threat towards gardenia&#x2019;s usage of 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 facts, qaf registered proprietor of registered trade mark 10 years, i.e 2001 2011. virtue of licensing agreement between qaf , gardenia, gardenia has right use trade mark within same period. although registration done in 2004, virtue of s 48(1)(e) of tma, clear period of permitted use period determined proprietor of trade mark. there nothing in s 46 of tma , reg 81(2) of trade marks regulations 1997 may construed prevent date of use of registered trademark being enforced retrospectively date prior application registration. [<emphasis type="italic">see p 612 para 53 line 31 - p 613 para 56 line 26</emphasis>]</list.item>                   </para> </para.group></case> 

the output i'm getting there duplication of "gan khong aik, tai foong lam , ng pok yue (abdullah chan) appellant , following line" want appear once after 4th point. i.e. @ end. please let me know how achieve this.

thanks

the answer problem should right here:

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

in for-each selecting every counsel.group; in xml snippet there one. for-each should select child node counsel.line...otherwise runs once , selects first counsel.line. should like:

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

also, xml snippet provided isn't formed. final </list> element has no opening matches to.


Comments