outputting Pairs of Nodes

A

awebguynow

I know its redundant but thats what this report calls for.
For every node except the first, I want to output a pair of nodes: the
current and prev one.
For sake of example, lets call the node <qsales> Quarterly Sales. (and
includes children)

If I could use an array syntax, it would be:
<qsales>[1]
<qsales>[2]

<qsales>[2]
<qsales>[3]

<qsales>[3]
<qsales>[4]

So I'm playing with preceding-sibling and hoping PHP5 is using XSLT
2.0 ie: max()
libxslt Version 1.1.7 phpinfo() notes
libxslt compiled against libxml Version 2.6.11 phpinfo() notes

Actually, doing some CL tests on WinXP, using jdk1.4.0
I'll have to research to find out what lib is being used there.

right now, I'm using a sort and then attempting something like this
(psuedo-code)
<xsl:variable name="ndx" select="position()" /> // having problems
defining var in root template
call-template <xsl:with-param name="node" select="." />
call-template <xsl:with-param name="node"
select="../qsales[position()=$ndx-1]" />

Another alternative, as I brainstorm
could I find the max() position() of preceding-sibling ?

One of the children of the nodes, is actually an index, but I'm
doubtful I can use it
Select node where <qsales>.index = 3 then use call-template

Re: Outputting Pairs - can I get a little help ?
 
P

Peter Flynn

awebguynow said:
I know its redundant but thats what this report calls for.
For every node except the first, I want to output a pair of nodes: the
current and prev one.
For sake of example, lets call the node <qsales> Quarterly Sales.
(and includes children)

If I could use an array syntax, it would be:
<qsales>[1]
<qsales>[2]

<qsales>[2]
<qsales>[3]

<qsales>[3]
<qsales>[4]

So I'm playing with preceding-sibling

<xsl:if test="position()>1">
<xsl:value-of select="preceding-sibling::qsales[1]"/>
</xsl:if>

A numeric abbreviated predicate on a 'preceding' axis counts backwards
from the context node, so [1] here means the immediately preceding
element node of the given type.

///Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top