Include Header And Footer In Html Created With Xslt Transformation
Solution 1:
Is the XSL generating more than one HTML file? If so, you can definitely include a header and footer in each HTML file.
If you’re only generating one HTML document, there isn’t really the concept of a “page”, unless you mean the series of screens a user sees as they scroll down. In that case, you’d need to use CSS to make the header and footer stay visible.
Or is this HTML being used to generate a PDF? Please explain further.
Solution 2:
Let's say I had an XML structure like this:
<?xml version="1.0" encoding="UTF-8"?><documentElement><header/><body><!-- omitted for brevity --></body></documentElement>
and a stylesheet to transform the above XML:
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheetversion="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:importhref="imported.xsl"/><xsl:outputmethod="html"encoding="UTF-8"omit-xml-declaration="yes"doctype-system="about:blank"indent="no"media-type="text/html"
/><xsl:templatematch="/"><xsl:apply-templates/></xsl:template><xsl:templatematch="documentElement"><HTMLdir="ltr"><xsl:apply-templates/></HTML></xsl:template><xsl:templatematch="body"><BODY><!-- content of other element --><xsl:apply-templatesselect="footer"/></BODY></xsl:template></xsl:stylesheet>
which imports another stylesheet:
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheetversion="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><!-- imported.xsl --><xsl:outputmethod="html"encoding="UTF-8"indent="no"media-type="text/html"
/><xsl:templatematch="header"><!-- content of header --><HEAD><METAcharset="UTF-8"/></HEAD></xsl:template><xsl:templatename="footer"><FOOTER><!-- content of footer --></FOOTER></xsl:template></xsl:stylesheet>
would result in:
<!DOCTYPE HTML><HTMLdir="ltr"><HEAD><METAcharset="UTF-8"></HEAD><BODY><!-- content of other element --><FOOTER><!-- content of footer --></FOOTER></BODY></HTML>
Notice the document has the <header/> element but not the <footer/> element and how the stylesheet(s) transform(s) them differently; e.g, <xsl:template match="header"/> versus <xsl:template name="footer"/>!
I don't know if this clears your doubt; in case you need in-depth explanation, do not hesitate to let me know :)
Post a Comment for "Include Header And Footer In Html Created With Xslt Transformation"