Click to See Complete Forum and Search --> : How to make print page in the best way using XSLT?
toplisek
01-03-2009, 01:30 AM
I have printing page and would like to make it XSLT page which uses header and footer from XSLT (title of article, footer is copyright) and body is from article content.
How to do link to print this page and using XSLT?
Output is to print media and PDF.
Scriptage
01-06-2009, 10:39 AM
XSLT only transforms one XML document into another; so you will need the input to be valid XML, i.e., XHTML.
The following is a bare bones example of converting an XHTML document into another XML document:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:output method="xml"
encoding="ISO-8859-1"
media-type="text/html"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" indent="yes"/>
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
You can add different templates to match different elements i.e.,
<xsl:template match="xhtml:a">
<xsl:value-of select="@href" />
</xsl:template>
This example replaces all links with their URI values.
Hope this helps.