1. Write the expected HTML manually.
2. Write an XSLT that converts the XML into that HTML
Sounds quite simple and straight forward, I think.
If you struggle with writing the expected HTML, ask a respective question.
If you struggle with generating the anchor
name, look at the
generate-id()[
^] function.
BTW: your XML is badly structured for my taste. If you have that under control, I would strongly suggest to get a better structure (i.e. so that you can use the link id instead of generate-id() function to make the links), e.g.
="1.0"="utf-8"
<Text>
<Section>
<Clause>
<Para>
Some <Footnote Ref="1">text</Footnote> and so on.
</Para>
</Clause>
<Explanation>
Some other <Footnote Ref="2">text</Footnote> etc.
</Explanation>
</Section>
<Footnotes>
<Note Id="1">dated January 6, 1994 :</Note>
<Note Id="2">Inserted by Act.</Note>
</Footnotes>
</Text>
With the following XSLT, you get a linked HTML as shown further down:
="1.0"="utf-8"
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<head><xsl:call-template name="SetStyles"/></head>
<body>
<xsl:call-template name="WriteText"/>
<xsl:call-template name="WriteFootnotes"/>
</body>
</html>
</xsl:template>
<xsl:template match="Footnote">
<xsl:variable name="Id" select="@Ref"/>
<xsl:variable name="Link" select="concat('#', $Id)"/>
<xsl:variable name="Tip" select="/Text/Footnotes/Note[@Id=$Id]"/>
<xsl:value-of select="."/>
<sup><a class="footnoteref" href="{$Link}" title="{$Tip}"><xsl:value-of select="concat('[',$Id,']')"/></a></sup>
</xsl:template>
<xsl:template match="Para">
<p><xsl:apply-templates/></p>
</xsl:template>
<xsl:template name="SetStyles">
<style type="text/css">
<xsl:comment>
.footnote { font-size:8pt; }
.footnoteref { text-decoration:none; color:black;}
</xsl:comment>
</style>
</xsl:template>
<xsl:template name="WriteText">
<xsl:for-each select="/Text/Section">
<xsl:apply-templates/>
</xsl:for-each>
</xsl:template>
<xsl:template name="WriteFootnotes">
<xsl:if test="count(/Text/Footnotes/Note) != 0">
<hr/>
<table border="0" class="footnote">
<xsl:for-each select="/Text/Footnotes/Note">
<xsl:sort select="@Id"/>
<xsl:variable name="Id" select="@Id"/>
<tr>
<td><a name="{$Id}"><xsl:value-of select="concat('footnote [', $Id, ']: ')"/></a></td>
<td><xsl:value-of select="."/></td>
</tr>
</xsl:for-each>
</table>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css"><!--
.footnote { font-size:8pt; }
.footnoteref { text-decoration:none; color:black;}
--></style>
</head>
<body>
<p>
Some text<sup><a class="footnoteref" href="#1" title="
 dated January 6, 1994 :
 ">[1]</a></sup> and so on.
</p>
Some other text<sup><a class="footnoteref" href="#2" title="
 Inserted by Act.
 ">[2]</a></sup> etc.
<hr>
<table border="0" class="footnote">
<tr>
<td><a name="1">footnote [1]: </a></td>
<td>
dated January 6, 1994 :
</td>
</tr>
<tr>
<td><a name="2">footnote [2]: </a></td>
<td>
Inserted by Act.
</td>
</tr>
</table>
</body>
</html>
|
Cheers
Andi