RE: [xsl] Next Node

Subject: RE: [xsl] Next Node
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Thu, 14 Jun 2001 15:54:51 +0100
> I have this XML
> <PAGE>
> <partner name="Oops" image="3810.bin" url="">
>      <text>
>        <line>development tool</line>
>        <line>Integrated Development Environment.</line>
>      </text>
> </partner>
> </PAGE>
> Of course, this has a lot of partner elements.
> I´m using this XSL

I can't begin to understand this!
> <xsl:for-each select="//PAGE/partner">

Is PAGE the outermost element of your XML? Then write /PAGE, otherwise the
system has to search for all the PAGE elements anywhere in the document.

> <xsl:variable name="contador">
> <xsl:value-of select="count (//PAGE/partner)"/>
> </xsl:variable>

Do you really want to create a result tree fragment containing a single text
node, or do you want the integer value:

<xsl:variable name="contador" select="count(//PAGE/partner)"/>

And if that's what you want, you can get it far more efficiently as

<xsl:variable name="contador" select="last()"/>

> <xsl:if test="contador div //PAGE/partner[position()] = 1">

Are you trying to test against the variable? In that case you want
The predicate [position()] means [position()=position()] and is always true.
I've no idea what you thought it meant.


Where does //bwp_page come from? It's not in your source!
> As you see, I´m calling the same element in the same
> for-each, but I want
> to call "the next" element in the second if statement.

I'm afraid I don't see anything of the kind...

Mike Kay
Software AG

 XSL-List info and archive:

Current Thread