Re: [xsl] Axis-Name help

Subject: Re: [xsl] Axis-Name help
From: Francis Norton <francis@xxxxxxxxxxx>
Date: Wed, 22 Jan 2003 23:36:50 +0000
Hi Bix,

bix xslt wrote:

I want to create a nodeset for a variable which contains each column of data.

My limited knowledge made me think this might work...but as testing will show, it does not:

No, it doesn't. You're not too far off - here's something that illustrates what I think you want do (you could make it shorter by eliminating the columnCells variables, but don't do that until you're comfortable with what's going on):


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:template match="/">
<matrix>
<xsl:for-each select="grandp/parent">
<xsl:variable name="pos" select="position()"/>
<xsl:variable name="columnCells" select="//parent/child[position() = $pos]"/>
<xsl:call-template name="column">
<xsl:with-param name="columnCells" select="$columnCells"/>
</xsl:call-template>
</xsl:for-each>
</matrix>
</xsl:template>


 <xsl:template name="column">
   <xsl:param name="columnCells"/>
   <column>
     <xsl:for-each select="$columnCells">
       <xsl:copy-of select="."/>
     </xsl:for-each>
   </column>
 </xsl:template>
</xsl:stylesheet>

As you realised, you have to "freeze" the current position, but you can then use it very simply.

Francis.


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread