Forum

How about adding support for including content of HEADER.html or READEME.html and FOOTER.html in ind

Balwinder S Dheeman
1 April 2015, 09:06
I attempted to customize the directory indexing by tweaking /etc/hiawatha/index.xslt, but could not find how do I include files HEADER.html or READEME.html and, or FOOTER.html in the index listing of a directory.

I know how to add a common header or footer, but some directories may need to have their own distinct header and, or footer :-(

FYI, I transformed the output into HTML5 and use bootstrap CSS for responsive display and, or presentation :-)

See also: http://bdheeman.ddns.net/pub/Linux/ports/
Hiawatha version: v9.12, cache, IPv6, reverse proxy, SSL (1.3.10), URL toolkit, XSLT (locally patched build)
Operating System: Ubuntu 14.04.2 LTS
Hugo Leisink
1 April 2015, 10:33
You can use the <xsl:include href="some_file.xslt" /> tag for that.
Balwinder S Dheeman
3 April 2015, 12:44
Sorry, neither
<xsl:include href="HEADER.html" />
nor
<xsl:include href="HEADER.html" />
worked.

I also attempted to try:

<header>
<xsl:for-each select="files/file">
<xsl:variable name="fn" select="." />
<xsl:if test="contains($fn, 'HEADER.xslt')">
<xsl:import href="{.}" />
</xsl:if>
</xsl:for-each>
</header>

But, to a no avail.
Hugo Leisink
3 April 2015, 12:59
body.xslt:
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="header.xslt" />

<xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD HTML 4.01//EN" doctype-system="http://www.w3.org/TR/html4/strict.dtd" />

<xsl:template match="/output">
<html>
<xsl:call-template name="header" />
<body>
<p>Body</p>
</body>
</html>
</xsl:template>

</xsl:stylesheet>


header.xslt:
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template name="header">
<head>
<title>Title</title>
</head>
</xsl:template>

</xsl:stylesheet>


data.xml:
<output>
</output>


The result:
# xsltproc body.xslt data.xml
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Title</title>
</head>
<body><p>Body</p></body>
</html>
Balwinder S Dheeman
3 April 2015, 13:03
<header>
<xsl:for-each select="files/file">
<xsl:variable name="fn" select="." />
<xsl:if test="contains($fn, 'HEADER.xslt')">
<xsl:include href="{.}" />
</xsl:if>
<xsl:if test="contains($fn, 'LICENSE.xslt')">
<xsl:include href="{.}" />
</xsl:if>
</xsl:for-each>
</header>

and the above (using xsl:include) does not work :-(
Hugo Leisink
3 April 2015, 13:59
Read some more about XSLT and the include tag. You're trying to use it in a way that is not allowed. Look at my example above. The usage of the call-template tag is the right approach.
This topic has been closed.