On 09/04/2024 06:23, Byomokesh Sahoo sahoo.byomokesh@xxxxxxxxx wrote:
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>
B B <div id="FNid000">
B B <p margin-left="123.25pt">8.3. In
B B B B <a name="_ftnref1"/>
B B B B <a href="#_ftn1"><sup>[1]</sup></a>, this analysed different<a
href="#_ftn2"><sup>[2]</sup></a> mean</p>
B B </div>
B B <div id="FNid001">
B B B B <p class="FootnoteText"
B B B B B B margin-left="94.95pt">
B B B B B B <sup>[1]</sup> 2001 9 SCC</p>
B B </div>
B B <div id="FNid002">
B B B B <p class="FootnoteText"
B B B B B B margin-left="94.95pt">
B B B B B B <sup>[2]</sup><b>2011 3 SCC 626</b>
B B B B </p>
B B </div>
</body>
Expected Output
---------------------------
<body>
B B <div id="FNid000">
B B <p margin-left="123.25pt">8.3. In
B B B B <p class="FootnoteText"
B B B B B B margin-left="94.95pt">
B B B B B B <sup>[1]</sup> 2001 9 SCC</p>, this analysed different<p
class="FootnoteText"
B B B B B B margin-left="94.95pt">
B B B B B B <sup>[2]</sup><b>2011 3 SCC 626</b>
B B B B </p> mean</p>
B B </div>
</body>
I think it might work to use a key e.g.
B <xsl:key name="ft" match="div/p[@class = 'FootnoteText']" use="sup"/>
B <xsl:template match="a[matches(@href, '#_ftn[0-9]+') and sup]">
B B B <xsl:copy-of select="key('ft', sup)"/>
B </xsl:template>
B <xsl:template match="div[p[@class = 'FootnoteText']]"/>
B <xsl:mode on-no-match="shallow-copy"/>
That would replace the <a href="#_ftnX"><sup>[X]</sup></a> elements with
the referenced p class="FootnotText".
I haven't been able to figure from the simple example sample why there
is also a <a name="_ftnref1"/> for the first footnote reference but not
for the second. Perhaps add an empty <xsl:template
match="a[matches(@name, '_ftnref[0-9]+')]"/>.
|