Re: [xsl] Conditional in-context nodeset variables

Subject: Re: [xsl] Conditional in-context nodeset variables
From: "Vyacheslav Sedov" <vyacheslav.sedov@xxxxxxxxx>
Date: Thu, 3 Jan 2008 20:30:22 +0300
thanks

i solve problem for case with properly "nested" h-tags & have space to
grow into healing mode :)

here my code (here some "unemployment" yet variables - it for future
"healing" purposes)

<xsl:template match="*[string-length(local-name()) =2 and
starts-with(local-name(),'h')]">
        <xsl:variable name="this-level-name" select="local-name()"/>
        <xsl:variable name="level" select="substring($this-level-name,2)"/>
        <xsl:variable name="next-level"
select="concat('h',xs:string(xs:integer($level) + 1))"/>
        <xsl:variable name="following-any-section-element"
            select="following-sibling::*[string-length(local-name())
=2 and (substring(local-name(),1,1) = 'h')][1]"/>
        <xsl:variable name="following-next-level-section-item"
            select="following-sibling::*[local-name() = $next-level][1]"/>
        <xsl:variable name="following-same-level-section-item"
            select="following-sibling::*[string-length(local-name())
=2 and (substring(local-name(),1,1) = 'h') and
(substring(local-name(),2) = $level)][1]"/>
        <xsl:variable name="following-any-other-level-section-item"
            select="following-sibling::*[string-length(local-name())
=2 and (substring(local-name(),1,1) = 'h') and (not(local-name() =
($this-level-name, $next-level)))][1]"/>
        <xsl:variable name="next-margin" select="if
($following-any-section-element) then ($following-any-section-element)
else (following-sibling::*[last()])"/>

        <xsl:element name="sect{$level}">
            <xsl:apply-templates mode="sect-title"/>
            <xsl:apply-templates select="following-sibling::node()[.
&lt;&lt; $next-margin]"/>
            <xsl:if test="$next-margin is $following-next-level-section-item">
                <xsl:apply-templates select="$next-margin"/>
            </xsl:if>
        </xsl:element>
        <xsl:apply-templates select="$following-same-level-section-item"/>
    </xsl:template>

with best wishes,
Slav

On Jan 3, 2008 7:54 PM, David Carlisle <davidc@xxxxxxxxx> wrote:
>
> > well... group h1 must include all h2 groups and same with any other  h level,
> > also i must get chance to any other elements
> > not only to be just copied but "touched" by others templates,
>
> sounds like the same problem addressed in the thread:
>
> http://www.biglist.com/lists/xsl-list/archives/200711/msg00487.html
> http://www.biglist.com/lists/xsl-list/archives/200711/msg00488.html
>
> David

Current Thread