[xsl] Move Text

Subject: [xsl] Move Text
From: "Byomokesh Sahoo sahoo.byomokesh@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 9 Apr 2024 04:22:54 -0000
Hi,

I am trying to move text to paragraph based on SUP value matching. Please
find the below xml, output xml and xsl.

XML
--------
<body>
    <div id="FNid000">
    <p margin-left="123.25pt">8.3. In
        <a name="_ftnref1"/>
        <a href="#_ftn1"><sup>[1]</sup></a>, this analysed different<a
href="#_ftn2"><sup>[2]</sup></a> mean</p>
    </div>
    <div id="FNid001">
        <p class="FootnoteText"
            margin-left="94.95pt">
            <sup>[1]</sup> 2001 9 SCC</p>
    </div>
    <div id="FNid002">
        <p class="FootnoteText"
            margin-left="94.95pt">
            <sup>[2]</sup><b>2011 3 SCC 626</b>
        </p>
    </div>

</body>

Expected Output
---------------------------
<body>
    <div id="FNid000">
    <p margin-left="123.25pt">8.3. In
        <p class="FootnoteText"
            margin-left="94.95pt">
            <sup>[1]</sup> 2001 9 SCC</p>, this analysed different<p
class="FootnoteText"
            margin-left="94.95pt">
            <sup>[2]</sup><b>2011 3 SCC 626</b>
        </p> mean</p>
    </div>
</body>

XSL:
--------
<xsl:template match="sup">
            <xsl:variable name="div-id1"
select="..//ancestor::body/div/p[@class='FootnoteText']//text()"/>
            <xsl:choose>
                <xsl:when

test="following::p[not(@class='ListParagraph')][parent::div//sup/current()
= $div-id1]/node()">

                            <xsl:apply-templates

select="following::p[not(@class='ListParagraph')][parent::div/@id =
$div-id1]//node()"/>

                </xsl:when>
                <xsl:otherwise>
                    <xsl:element name="sup">
                        <xsl:apply-templates/>
                    </xsl:element>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:template>

Please Suggest.

Thanks

Current Thread