Hi,
> I have this structure in XML...
>
> <elements>
> <element>5</element>
> <element>3</element>
> <element>6</element>
> <element>1</element>
> </elements>
>
> With XSL, i have...
>
> <xsl:for-each select="element">
> <xsl:sort select="." order="ascending" data-type="number"/>
> ...
> </xsl:for-each>
>
> In this way, the elements have this order...
>
> position() = 1 --> element = 1
> position() = 2 --> element = 3
> position() = 3 --> element = 5
> position() = 4 --> element = 6
>
> But ...
>
> preceding of element = 1 is element = 6
> preceding of element = 3 is element = 5
> preceding of element = 5 is element = null
> preceding of element = 6 is element = 3
>
> Then, how i know that preceding of element=3 in the order is
> the element = 1?
> ¿?
Unfortenately, you don't. You can either do two passes, first sorting and then going through the elements and testing their preceding element, or sort the elements into a Result Tree Fragment, cast that into a node-set using an extension, and then process them.
> How i calculate the acumulated total?¿? (for the element = 5
> the total
> acumulated is 1 + 3 + 5 ...)
You don't need preceding axis for that, just use
<xsl:value-of select="sum(../element[. <= current()])"/>
Cheers,
Jarno
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|