1

I've the below XML in my XSLT.

 <section level="sect4" number-type="manual" num="(ii)">
        <title>
            Non-Hong Kong companies
            <footnote num="123">
                <para>The venerable statutory .</para>
            </footnote> with a place of business in Hong Kong
            <footnote num="124">
                <para>It may be noted in this context of English judgments.</para>
            </footnote>
        </title>
        <para>
            <phrase>3.039</phrase> Companies incorporal Companies,
            <footnote num="125">
                <para>Registration of the information specified in this
                 section must be effected</para>
            </footnote>
            of which three are relevant for present purposes:
        </para>
    </section>

here i want to apply-templates but ignore the footnotes, when i use the below.

    <xsl:template name="IndexItem">
    <xsl:if test="not(contains(@level,'sect1'))"><!--changed fron @num to sect2-->
        <xsl:variable name="tocpg">
            <xsl:value-of select="concat('#P',descendant::phrase[1])"/>
        </xsl:variable>
        <xsl:variable name="nu">
        <xsl:number format="(i)"/>
        </xsl:variable>
        <xsl:variable name="tocpgtag" select="translate($tocpg,'.', '-')"/>
        <xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'"/>
        <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
        <xsl:variable name="text" select="current()/title/text()"/>
        <xsl:variable name="Brac">
            <xsl:choose>
                <xsl:when test="contains(current()/@num,$nu)">
                    <xsl:value-of select="3"/>
                </xsl:when>
                <xsl:when test="contains(current()/@num,'(')">
                    <xsl:value-of select="2"/>
                </xsl:when>
                <xsl:otherwise>
                                    <xsl:value-of select="1"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="d">
        <xsl:value-of select="concat('toc-item-',$ThisDocument//ntw:nums[@num=$Brac]/@word,'-level')"/>
</xsl:variable>
        <table class="{$d}">
            <tbody>
                <tr>
                    <td class="toc-item-num">
                        <xsl:value-of select="@num"/>
                    </td>
                    <td class="toc-title">
                     <xsl:apply-templates select="node() except child::footnote"/>
                    </td>
                    <td class="toc-pg">
                        <a href="{$tocpgtag}">
                            <xsl:value-of select="descendant::phrase[1]"/><![CDATA[ ]]>
                        </a>
                    </td>
                </tr>
            </tbody>
        </table>
        </xsl:if>
    </xsl:template>

the output is

Non-Hong Kong companies <sup>123</sup>  with a place of business in Hong Kong <sup>124</sup>

and when i use this

<xsl:apply-templates select="./title[not(./footnote)]"/>

it is not displaying anything, the expected output is, just

Non-Hong Kong companies with a place of business in Hong Kong

and also if there are anymore other childs(like content style), they should be applied, only footnote is to be ignored.

please let me know how can i do this.

Thanks

user3872094
  • 3,269
  • 8
  • 33
  • 71

1 Answers1

1

you could try the except operator:

<xsl:template match="title">
    <xsl:apply-templates select="node() except child::footnote"/>
</xsl:template>

EDIT

I am inferring that you are calling this template from the section node. Try this instead:

<xsl:apply-templates select="title/node() except descendant::footnote"/>
Joel M. Lamsen
  • 7,143
  • 1
  • 12
  • 14
  • Hi @Joel, thanks for response, i'm actually creating toc from all the xml data, here i've created a template just to get data, and when i tried `` the result is same, and when i did , the rest of data in my XM is getting fetched, but i'm only trying for TOC, Thanks again – user3872094 Jul 28 '14 at 07:52
  • we could help better if you will post an input xml that has more information. – Joel M. Lamsen Jul 28 '14 at 07:54
  • 1
    Joel is there a function that i can use like `except` only on `content-style/@font-style` ? – user3872094 Jul 28 '14 at 14:40
  • 1
    If this answer has been helpful. Click the check mark (just below the arrowheads to make it appear green). This way, other users can know that this is the right answer. Per your 2nd question, I think it is best to formulate another question. – Joel M. Lamsen Jul 30 '14 at 04:07