Subject: Re: [xsl] Nodes get new IDs in function? From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx> Date: Sat, 10 Apr 2010 17:15:18 +0200 |
Thanks all for pointing out the xsl:copy-of, now it works like a charm.
As for the grouping approach, I'm considering it, but I can't see why it's so much better? Performance wise? But it's using recursion as well?
I think after I introduced parent-heading() function, my solution became quite elegant. It's also convenient to have this function in other situations.
Another question is, what is the desired output. You start at level 1, what if there are no h1 elements?
Also, in your solution<li class="level4"><p>Attribution</p></li> gets nested in an additional<ul>, which I think is unnecessary. In my version, it gets flattened to the same level as<li class="level3">.
I'm using the same approach not only for<ul> list in XHTML, but NCX table of contents as well. In Adobe Digital Editions, all top-level headings are collapsed by default (children not shown until clicked), so having empty nesting elements is not really a good idea.
==========8<------------------------------------------- <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:my="URN:my" version="2.0" exclude-result-prefixes="my xs" >
<xsl:template match="/"> <xsl:apply-templates/> </xsl:template>
<xsl:template match="body"> <xsl:copy> <xsl:sequence select="my:hierarchize-toc(*)" /> </xsl:copy> </xsl:template>
<xsl:function name="my:isHeading" as="xs:boolean"> <xsl:param name="elt" as="element(*)" /> <xsl:value-of select="matches(local-name($elt), '^h\d$')" /> </xsl:function>
</xsl:stylesheet> ==========8<-------------------------------------------
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Nodes get new IDs in func, Martynas Jusevicius | Thread | Re: [xsl] Nodes get new IDs in func, Wolfgang Laun |
Re: [xsl] Create Table, Eric J. Bowman | Date | [xsl] mixed content grouping by whi, James Cummings |
Month |