Subject: Re: [xsl] Nodes get new IDs in function? From: Wolfgang Laun <wolfgang.laun@xxxxxxxxx> Date: Fri, 9 Apr 2010 07:23:27 +0200 |
The <xsl:copy-of> is the culprit; it does create a new node. Use <xsl:sequence select="..."/> instead. -W On Fri, Apr 9, 2010 at 2:15 AM, Martynas Jusevicius <martynas.jusevicius@xxxxxxxxx> wrote: > Hey list, > > still struggling with the level gap-infested ToC, but I think I > introduced a couple of functions, I'm now on the finish line: > > <xsl:function name="o2e:heading-level" as="xs:integer"> > <xsl:param name="heading" as="element()"/> > <xsl:value-of select="number(substring-after(local-name($heading), 'h'))"/> > </xsl:function> > > <xsl:function name="o2e:parent-heading" as="element()*"> > <xsl:param name="heading" as="element()"/> > <xsl:copy-of select="$heading/preceding-sibling::h:*[self::h:h1 or > self::h:h2 or self::h:h3 or self::h:h4 or self::h:h5 or > self::h:h6][o2e:heading-level(.) < > o2e:heading-level($heading)][1]"/> > </xsl:function> > > The problem is, it seems that nodes returned from the parent-heading() > function get different IDs than identical nodes in the source > document. Is this the specified behavior, i.e. functions construct new > nodes, which get new IDs? > > For that reason this expression won't work: > > following-sibling::h:*[self::h:h1 or self::h:h2 or self::h:h3 or > self::h:h4 or self::h:h5 or self::h:h6][o2e:parent-heading(.) is > current()] > > Because the IDs won't match in the 'is' operator, even though I can > see the nodes are (look) identical. If I change the operator to '=' it > starts giving the expected results, but it is not good enough, as > there can be several heading elements with the same string value. Is > it possible to retain the original ID value somehow? > > As for the source document, it could be any XHTML with any number and > order of headings, for example: > > <h1 class="Heading_20_1 ">Free Culture - How Big Media Uses Technology > and the Law to Lock Down Culture and Control Creativity,Lawrence > Lessig</h1> > <h4 class="Heading_20_4 ">Attribution</h4> > <p>...</p> > <h3 class="Heading_20_3 ">Preface</h3> > <h4 class="Heading_20_4 ">[Preface]</h4> > <p>...</p> > <h3 class="Heading_20_3 ">INTRODUCTION</h3> > <p>...</p> > > and so on > > Martynas > odt2epub.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Nodes get new IDs in func, Imsieke, Gerrit, le- | Thread | [xsl] Generating book index via att, Dave Carvell |
Re: [xsl] Nodes get new IDs in func, Imsieke, Gerrit, le- | Date | Re: [xsl] Nodes get new IDs in func, Martynas Jusevicius |
Month |