This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Accessing the Next Node in the Current Node List


Thanks for the response Chris, however I have tried using the named
following-sibling axis before (I should have mentioned that), but that seems
to select the next sibling element in the source document, rather than the
next node in the context's current node list (which is what I want).

Here's a simple example to illustrate.  The following XSL:
<xsl:transform version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
    <xsl:output method="text" indent="no"/>

    <xsl:template match="document">
        <xsl:apply-templates select="section[@importance = 'high']"/>
    </xsl:template>

    <xsl:template match="section">
        <xsl:value-of select="."/><xsl:text> </xsl:text>
        Next Section Importance: <xsl:value-of
        select="following-sibling::node()/@importance"/>
        <xsl:text>&#xA;</xsl:text>
    </xsl:template>
</xsl:transform>

Applied to the following document:
<document>
    <section importance="high">Section 1</section>
    <section importance="low">Section 2</section>
    <section importance="high">Section 3</section>
</document>

Yields the following result document:
Section 1
    Next Section Importance: low
Section 3
    Next Section Importance:

The apply-templates instruction correctly selects the high importance
sections, but the following-sibling axis still returns the second (low
importance) section -- which isn't part of the current node list.

Does anyone have any ideas as to how to access/select the next node in the
current node list?

-- Sasha

---------------------
Date: Wed, 12 Dec 2001 01:13:20 -0000
From: "Chris Bayes" chris@bayes.co.uk
Subject: RE: [xsl] Accessing the Next or Previous Node in the Current
node-list

<xsl:if test="following-sibling::p">&#x0A;</xsl:if>


-----Original Message-----
From: owner-xsl-list@lists.mulberrytech.com
[mailto:owner-xsl-list@lists.mulberrytech.com] On Behalf Of Sasha Haghani
Sent: 12 December 2001 00:23
To: XSL List
Subject: [xsl] Accessing the Next or Previous Node in the Current node-list

How can I access the next or previous node in the current node-list?

I need to perform special whitespace (e.g.: "output a newline character if
the next element in the node-list is a paragraph") handling based on the
next element which is going
to be processed.



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]