[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Footnote generator
Hi,
I have a basic working footnote generator that takes an augmented XHTML and generates XHTML. Files are availiable here :- http://www.aarongray.org/Test/XSL/Footnotes/ I am using MSXSL Version 4.0 There are two issues that I would like to hopefully solve :- 1) <xsl:output indent="yes"> does not seem to work. 2) elements like <br/> are being output as <br></br> Any solutions or suggestions are welcome. Full code, input and output XHTML are below too...
<xsl:stylesheet version="2.0" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xhtml xsl xs"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()" mode="html"/> </xsl:copy> </xsl:template> <xsl:template match="xhtml:head" mode="html"> <head> <xsl:copy-of select="*"/> </head> </xsl:template> <xsl:template match="xhtml:body" mode="html"> <body> <xsl:apply-templates select="@*|node()" mode="body"/> </body> </xsl:template> <xsl:template match="@*|node()" mode="body"> <xsl:copy> <xsl:apply-templates select="@*|*|node()" mode="body"/> </xsl:copy> </xsl:template> <xsl:template match="xhtml:footnote" mode="body"> <xsl:variable name="footnoteNumber"><xsl:number/></xsl:variable> <xsl:element name="a"><xsl:attribute name="href">#fn<xsl:value-of select="$footnoteNumber"/></xsl:attribute><xsl:attribute name="name">#fr<xsl:value-of select="$footnoteNumber"/></xsl:attribute>[<xsl:value-of select="$footnoteNumber"/>]</xsl:element> </xsl:template> <xsl:template match="xhtml:footnotes" mode="body"> <xsl:for-each select="//xhtml:footnote"> <xsl:variable name="footnoteNumber"><xsl:number/></xsl:variable> <xsl:element name="a"><xsl:attribute name="name">#fn<xsl:value-of select="$footnoteNumber"/></xsl:attribute><xsl:attribute name="href">#fr<xsl:value-of select="$footnoteNumber"/></xsl:attribute><xsl:value-of select="$footnoteNumber"/></xsl:element>. <xsl:apply-templates select="." mode="footnote"/><br/> </xsl:for-each> </xsl:template> <xsl:template match="xhtml:footnote/*" mode="footnote"> <xsl:copy-of select="."/> </xsl:template> </xsl:stylesheet> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ footnote.html ~~~~~~~~~~~~~~~~~~~~ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Footnote test</title> </head> <body> Test <footnote>This is a footnote</footnote><br/> Test2 <footnote>This is another footnote</footnote><br/> <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/> <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/> <footnotes/> </body> </html> ~~~~~~~~~~~~~~~~~ output ~~~~~~~~~~~~~~~~~~~ <?xml version="1.0" encoding="UTF-8"?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Footnote test</title> </head> <body> Test <a href="#fn1" name="#fr1">[1]</a> <br></br> Test2 <a href="#fn2" name="#fr2">[2]</a> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <a name="#fn1" href="#fr1">1</a>. This is a footnote<br /> <a name="#fn2" href="#fr2">2</a>. This is another footnote<br /> </body> </html> Many thanks, Aaron
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|