xsl looping and variable help please

Hi all

i have a child editor. I need to loop through the values and output a table. I am struggling to set a variable based on all the child values.

I have a field called Col1 - if any of the fields called Col1 (there could be up to 8) have a value, I want to set a variable. I have tried looping through all the fields and setting the variables. Then in another loop when trying to test the variable and produce the output - I get an error saying the variable has not been declared.

Basically what i am trying to do is, if any col1 has a value, set a flag. Then for each individual col1 value, check the flag - if the flag is true I either output the value for that col1 if there is one, or output an empty space. This ensures that my table displays correctly.

Can anybody help please.

thanks
michelle

Michelle,

As you probably already know, XSL is not big on Looping, and <xsl:variable> is not really a “variable” (it’s more like a constant). You cannot use for as a loop counter or temporary loop variable. This is one of the challenges of XSLT that led us to move to Velocity.

In 5.x, you include Child documents with the AddChildInfo extension. They become part of the main document, and you iterate over the added nodes with <xsl:apply-templates> in the usual manner.

To handle null conditions, you have 2 choices: you have have multiple <xsl:template> nodes (including one that matches on an “empty” node and renders an  ) or you can use <xsl:if> and <xsl:otherwise> (there is no “else” in XSL).

Without seeing your actual XML, I cannot give you any more details.

Dave

I am on Rhythmyx 6.5.2, so I don’t know how XSL worked in Rhythmyx 5.x, but it sounds like you could either use a recursive named template rather than xsl:for-each, or work up some complicated XPath to test without looping twice.

HI

ok i have worked this out now - need to loop within variable tag rather than variable tag within loop.

thanks
michelle