[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XHTML table of contents with XSLT
Daniel K. Schneider wrote:
(2) David Carlisle told me to replace the ugly "*[local-name()='xxx']" by "h:xxx" I think your stylesheet is supposed to generate XHTML output with result elements in the XHTML namespace so the stylesheet should have the XHTML namespace as the default namespace (at least for the easiest way to make sure all result elements are in that namespace). Then for XPath expressions and match patterns to be able to select/match elements in the XHTML namespace you need a declaration binding a prefix to the namespace too. To avoid that the prefix is later appearing in the output and making the markup invalid in terms of (rather limited) DTD validation use exclude-result-prefixes e.g. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://www.w3.org/1999/xhtml" exclude-result-prefixes="h"> Then you can use e.g. <xsl:template match="/h:html"> <html> <head> <title><xsl:value-of select="h:title"/></title> </head> <body bgcolor="#FFFFFF"> <xsl:apply-templates select="h:body"/> </body> </html> </xsl:template> <xsl:template match="h:body"> <strong><a name="toc">Contents</a></strong> <xsl:apply-templates select="h:h1 | h:h2" mode="toc"/> <xsl:apply-templates /> </xsl:template> <xsl:template match="h:h1" mode="toc"> <br/> <a href="#h1_{generate-id(.)}"><xsl:value-of select="."/></a><br/> </xsl:template> and so on. -- Martin Honnen http://JavaScript.FAQTs.com/
|
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
|