Click to See Complete Forum and Search --> : XSLT : variable scope


tyris
July 12th, 2001, 11:53 AM
hi all,
i try to do this :

[declare a variable called x]

<!-- locate Product index and keep it in a variable -->
<xsl:template match="document/tables/table/columnHeaders/columnHeader">
<xsl:if test="@text[.='Project']">
[make x = position()]
</xsl:if>

</xsl:template>


<!-- make a comparison with each column index to know if it's a product-->
<xsl:template match="/">
<xsl:for-each select="document/tables/table/rows/row">
<xsl:for-each select="column">
[if position() = the x i have initialise before then display]

</xsl:for-each>
</xsl:for-each>

the problem is that it seems that in the last part (<xsl:template match="/">) x is unknown. what is the way to :
1. define a variable
2. give this variable a value in one template
3. red this value in an other template



regards ;-)

elise

tyris
July 13th, 2001, 04:23 AM
well i know that a variable used in a template will be only available in this template.
i have read that with recursivity i could manage to make work my problem. but i don't even know what to do, do you have an example of a good recursivity in XLST ?

thanks

ps : i also post the way my data are structured :

<document name="Marketing">
<tables count="1">
<table name="AllDocuments">
<columnHeaders count="3">
<columnHeader text="Site"/>
<columnHeader text="Status"/>
<columnHeader text="Account"/>
</columnHeaders>
<rows count="134">
<row>
<column>Paris</column>
<column>Project Completed</column>
<column>Microsoft (France)</column>
</row>
<row>
<column>Paris</column>
<column>Project Completed</column>
<column>Lionbridge Nortel</column>

</row>
</rows>
</table>
</tables>
</document>


regards ;-)

elise