xsl-list
[Top] [All Lists]

Re: [xsl] Conditional in-context nodeset variables

2008-01-03 10:30:52
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(_at_)nag(_dot_)co(_dot_)uk> 
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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--