Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

XSLT Changing variable value in a loop....

macaronimacaroni Member Posts: 1
What I am attempting to do is to display the category heading if they are different from the previous record.
i.e.
Category Heading 1
Record
Record
Record
Category Heading 2
Record
Record
Category Heading 3
Record
.
.
So I figured to use 2 , one to keep track of the current record's category heading and another 1 to keep track of the previous record's category heading. The current record category heading is placed in a . This is found in the tag. This works correct however the problem is when the variable that keep tracks of the previous record category.
I figured to use :

where $d = position() -1;
Value of $d is correct but the value of prev_category is always set to the first category heading of the first record.

I am wondering why the code is not working of saving the state of previous record's category heading.

How can I implement this...

Thanks.

Comments

  • infidelinfidel Member Posts: 2,900
    : What I am attempting to do is to display the category heading if they are different from the previous record.
    : i.e.
    : Category Heading 1
    : Record
    : Record
    : Record
    : Category Heading 2
    : Record
    : Record
    : Category Heading 3
    : Record
    : .
    : .
    : So I figured to use 2 , one to keep track of the current record's category heading and another 1 to keep track of the previous record's category heading. The current record category heading is placed in a . This is found in the tag. This works correct however the problem is when the variable that keep tracks of the previous record category.
    : I figured to use :
    :
    : where $d = position() -1;
    : Value of $d is correct but the value of prev_category is always set to the first category heading of the first record.
    :
    : I am wondering why the code is not working of saving the state of previous record's category heading.
    :
    : How can I implement this...

    As I understand it, xsl:variable is more like a constant, once it has a value you can't change it. Do you know about axes? You may be able to use the "preceding" axis in this situation. Something like:

    [code]

    [/code]

    Not sure if that is exact, but it'd be something like that.


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

Sign In or Register to comment.