XSLT 2.0 XPath 2.0 Saxon 8
I am creating an xml-fo file that has several options for table column
headers which are stored in variables like:
<xsl:variable name="colhead-size"
select="'1.5cm','1.5cm','1.5cm','proportional-column-width(1)','2cm','2cm','
2cm','2cm'"/>
Then, in the xslt I loop like this to create the fo:table-columns:
<xsl:for-each select="1 to count($colhead-names)">
<xsl:variable name="pos" select="position()"/>
<fo:table-column>
<xsl:attribute name="column-width"
select="$colhead-size[$pos]"/>
<xsl:attribute name="text-align"
select="$colhead-align[$pos]"/>
<xsl:attribute name="column-number"
select="$pos"/>
</fo:table-column>
</xsl:for-each>
This does work, however this does not work when I use the "position()"
directly:
<xsl:for-each select="1 to count($colhead-names)">
<fo:table-column>
<xsl:attribute name="column-width"
select="$colhead-size[position()]"/>
<xsl:attribute name="text-align"
select="$colhead-align[position()]"/>
<xsl:attribute name="column-number"
select="$pos"/>
</fo:table-column>
</xsl:for-each>
This gives me the entire node set so I get:
<fo:table-column column-width="1.5cm 1.5cm 1.5cm
proportional-column-width() 2cm etc." ...
My question is: why do I have to save position() to a variable to use it
properly in the for-each loop?
Rick
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--