|
Subject: Re: [xsl] position() problem From: Graham Seaman <graham@xxxxxxxxx> Date: Wed, 7 Nov 2001 19:12:23 +0000 (GMT) |
On Tue, 6 Nov 2001, Graham Seaman wrote:
> Hi all,
>
> I have some input like this:
<snipped>
And I posted a completely messed up template to go along with it
(it had been hacked around too many times). Here's a working version,
which gets round the position() problem by storing the position as a
variable at a point where the context is the correct one. But I've just
seen Jeni post that the correct answer is to use preceding::sibling,
so I guess I'll have another go at writing it using that...
<xsl:template name="a-nav">
<xsl:param name="the-as"/>
<xsl:param name="level"/>
<xsl:choose>
<xsl:when test="$level = '0'"/>
<xsl:otherwise>
<xsl:for-each select="$the-as">
<xsl:variable name="pos" select="position() - 1"/>
<xsl:if test="contains(./@label, $level) and
contains($the-as[$pos]/@label, $level - 1)">
<strong><xsl:apply-templates
select="$the-as[$pos]"/></strong><p/>
</xsl:if>
<xsl:if test="contains(./@label, $level)">
<xsl:apply-templates select="."/><![CDATA[ . ]]>
</xsl:if>
</xsl:for-each>
<p/>
<xsl:call-template name="a-nav">
<xsl:with-param
name="the-as" select="$the-as[not(contains(@label,$level))]"/>
<xsl:with-param name="level" select="$level - '1'"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] position() problem, Graham Seaman | Thread | [xsl] PHP integration with XSLT, Alessio Mazzieri |
| Re: [xsl] Using position(), Graham Seaman | Date | RE: [xsl] (possible) strange behavi, Michael Kay |
| Month |