Question

I've the below XML document.

<case.considered>
    <case.ref BVtable="yes">
        <citetitle type="case" full="Lee Ting Lam v Leung Kam Ming" legtype="ord">Lee Ting Lam v Leung Kam Ming</citetitle>
        <citecitation full="[1980] HKLR 657">[1980] HKLR 657</citecitation>
    </case.ref>
</case.considered>
<case.considered>
    <case.ref BVtable="yes">
        <citetitle type="case" full="Chan Pui Ki v Leung On" legtype="ord">Chan Pui Ki v Leung On</citetitle>
        <citecitation full="[1996] 2 HKLR 401, [1996] 2 HKC 565">[1996] 2 HKLR 401</citecitation>
    </case.ref>
</case.considered>
<case.considered>
    <case.ref BVtable="yes" annotation="considered">
        <citetitle type="case" full="Sung Fuk Wah v Lam Wai Leuk" legtype="ord">Sung Fuk Wah v Lam Wai Leuk</citetitle>
        <citecitation full="(unrep., HCA 3676/1994, [1995] HKLY 527)">(unrep., HCA 3676/1994)</citecitation>
    </case.ref>
</case.considered>
<case.considered>
    <case.ref BVtable="yes" annotation="distinguished">
        <citetitle type="case" full="Blamire v South Cumbria Health Authority" legtype="ord">Blamire v South Cumbria Health Authority</citetitle>
        <citecitation full="[1993] PIQR Q1">[1993] PIQR Q1</citecitation>
    </case.ref>
</case.considered>
<case.considered>
    <case.ref BVtable="yes" annotation="distinguished">
        <citetitle type="case" full="W (A child) v Hammersmith Hospitals NHS Trust" legtype="ord">W (A child) v Hammersmith Hospitals NHS Trust</citetitle>
        <citecitation full="[2002] 3 QR 5, [2002] All ER (D) 397">[2002] All ER (D) 397</citecitation>
    </case.ref>
</case.considered>

and the below XSLT

    <xsl:template match="ref.group" name="ref.group">
        <xsl:if test="leg.mentioned">
            <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:if>
        <xsl:if test="//case.considered">
            <div class="section-sect1">
                <xsl:text>Case cited in the judgment</xsl:text>
            </div>
            <xsl:apply-templates select="//case.considered" mode="x"/>
        </xsl:if>
        <xsl:if test="./other.mentioned">
            <div class="section-sect1">
                <xsl:text>Other materials mentioned in the judgment</xsl:text>
            </div>
            <xsl:apply-templates select="./other.mentioned"/>
        </xsl:if>
        <xsl:apply-templates select="//judgment"/>
    </xsl:template>


  <xsl:template match="case.considered" mode="x">
        <div class="para">
            <xsl:apply-templates select="case.ref" mode="x"/>
        </div>
    </xsl:template>

    <xsl:template match="case.ref" mode="x">

        <span class="font-style-italic">
            <xsl:value-of select="./citetitle[@full]"/>
        </span>
        <xsl:text> </xsl:text>
        <xsl:value-of select="./citecitation/@full"/>
    </xsl:template>

here i'm unable to know how to sort the data based on the text in citetitle

please let me know how to sort the data.

Thanks

Was it helpful?

Solution

I am guessing it is the case.considered you wish to add the sorting to. Currently, you are doing this

<xsl:apply-templates select="//case.considered" mode="x"/>

To do sorting, you would need to change it to this

<xsl:apply-templates select="//case.considered" mode="x">
    <xsl:sort select="case.ref/citetitle" />
</xsl:apply-templates>

This does assume only one case.ref element per case.considered element though. If there are more than one, only the first one is used in the sorting.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top