The context here is formatting a XML file with an XSL:stylesheet producing a html report.
Most things are working but i am having trouble getting the following to work :
- I want to set a variable to a dummy value then using this value in the code as the previous field value and then adjust teh variable to the new value. The idea is each time a column changes i want to provide a new heading, e.g.
if prev_category != category then ! category is a column in the XML file.
new heading category
This isn't as easy as you would think because XSL does not allow you to set a variable in 2 places and aborts if you reference a variable before it is initialised.
I have tried several variants based on some examples on the net and here but to no avail. Typically end up with "A reference to variable or parameter 'prev_section' cannot be resolved"
>> So i am wanting the good oil on how to set a parameter, variable, anything and then access this information in an 'if' test ? For any other language this would be simple but xsl has its own way...
nb: Points only awarded for a working example, i have burned so much time i don't want to still not be across the line after assigning points ,.
<!-- Do anything that allows a var / param to be initialised -->
<xsl:variable name="prev_section" select="$previous" />
<xsl:for-each select="DocumentElement/Results[section != 'Help']">
<xsl:if test="section != $prev_section">
<!-- do stuff in here -->
<!-- Other stuff in here -->
<!-- Try to update something we can use -->
<xsl:with-param name="previous" select="section"/>