Re: [xsl] XHTML table of contents with XSLT

Subject: Re: [xsl] XHTML table of contents with XSLT
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 23 Feb 2007 17:16:42 GMT
as has been said, you can use {generate-id()} rather than {.} to
generate ids.

Also don't do  
 <xsl:template match="/*[local-name()='html']">
etc, instead add

                 xmlns:h="http://www.w3.org/1999/xhtml";
to your xsl:stylesheet, then you can write that as

 <xsl:template match="/h:html">

and similarly replace

       <xsl:apply-templates select="*[local-name()='body']"/>


by

       <xsl:apply-templates select="h:body"/>

etc.

<!-- A default rule will just copy all the rest -->

<xsl:template match="*">
     <xsl:element name="{name(.)}">
       <xsl:for-each select="@*">
         <xsl:attribute name="{name(.)}">
           <xsl:value-of select="."/>
         </xsl:attribute>
       </xsl:for-each>
       <xsl:apply-templates/>
     </xsl:element>
   </xsl:template>


can be

<!-- A default rule will just copy all the rest -->

<xsl:template match="*">
     <xsl:copy>
         <xsl:copy-of select="@*"/>
       <xsl:apply-templates/>
 </xsl:copy>
   </xsl:template>


David

Current Thread