[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: position() problem

Subject: Re: position() problem
From: Graham Seaman <graham@xxxxxxxxx>
Date: Wed, 7 Nov 2001 19:12:23 +0000 (GMT)
problem of seaman
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[&nbsp;.&nbsp;]]>
          </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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.