Subject: [xsl] Optimizing preceding-sibling & following-sibling axes (with key()?) From: Martynas Jusevicius <martynas.jusevicius@xxxxxxxxx> Date: Wed, 7 Apr 2010 20:56:30 +0200 |
Hey, I have such a variable definition (quite cumbersome): <xsl:variable name="descendant-headings" select="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:heading-level(.) > o2e:heading-level(current())][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(current())][1] is current()]"/> Basically, I need to select all descendant (level-wise, not as in descendant axis) headings for the current() one, meaning all following headings with lower level which go before the next heading one the same level as current(). This expression gives me what I need. o2e:heading-level() function simply extracts the level number from elements name, like 'h3'. Now, I've read multiple times that preceding-sibling/following-sibling are slow. I wonder if this expression could be optimized? I also have a key definition which I use for similar purposes: <xsl:key name="heading-by-level" match="h:h1 | h:h2 | h:h3 | h:h4 | h:h5 | h:h6" use="number(substring-after(local-name(), 'h'))"/> I just can't figure out how combine this key with the sibling axes to get the same result and improve performance, i.e. that instead of traversing the whole document it would be enough to traverse key() values, like in key('heading-by-level', 1 to 6). Does it make sense? Thanks, Martynas odt2epub.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] writing to a file in xslt, David Carlisle | Thread | Re: [xsl] Optimizing preceding-sibl, G. Ken Holman |
Re: [xsl] writing to a file in xslt, David Carlisle | Date | Re: [xsl] Optimizing preceding-sibl, G. Ken Holman |
Month |