Subject: RE: [xsl] How to use arrays type of variable in XSLT? From: <Jarno.Elovirta@xxxxxxxxx> Date: Thu, 7 Oct 2004 09:26:30 +0300 |
Hi, > In XSLT, we declare some global variable like this.. > > <xsl:variable name="x1">10</xsl:variable> > <xsl:variable name="x2">100</xsl:variable> > <xsl:variable name="x3">151</xsl:variable> > > <xsl:output method="xml" encoding="UTF-8" > indent="yes"/> > <xsl:template match="/"> > <xsl:element name="layout"> > <xsl:call-template name="office-body"/> > </xsl:element> > </xsl:template> > > In other template, I am using position() to extract > the variable value using position() as index. > > <xsl:template name="table_row_traversing"> > <xsl:for-each select="table:table-row"> > <xsl:for-each select="table:table-cell"> > <xsl:variable name="col_width"> > <xsl:value-of select="position()"/> > </xsl:variable> > <xsl:value-of select="x[$col_width]"/> > </xsl:for-each> > </xsl:for-each> > </xsl:template> > > Here I need to get the value x1, x2, x3 etc based on > the position(). > > I didnt get any output using this code? (Inventing new functionality rarely works.) <xsl:value-of select="x[$col_width]"/> Extracts the string value of element "x", whose position is equal to $col_width variable. If I understood you correctly, you want to extract the value of variable $x*. You can't do this with vanilla XSLT, you need to use variable or use another approach. You can, e.g., declare <xsl:variable name="columns" select="document('')/*/x:columns"/> <x:columns> <column>10</column> <column>100</column> <column>151</column> </x:columns> as top-level elements and in your template use <xsl:value-of select="$columns/*[$col_width]"/> Cheers, Jarno - Neurotic Fish: M.F.A.P.L. (Intelligent Tribal Freak mix)
Current Thread |
---|
<- Previous | Index | Next -> |
---|---|---|
[xsl] How to use arrays type of var, Arulraj | Thread | [xsl] Include background colour in , James Steven |
[xsl] How to use arrays type of var, Arulraj | Date | RE: [xsl] Ampersand in attributes, Michael Kay |
Month |