Subject: Re: [xsl] howto convert node set into 2D table From: "Sam Carleton" <scarleton@xxxxxxxxxxxxxxxx> Date: Wed, 4 Jul 2007 12:00:28 -0400 |
> Any thoughts on all my rambling?
It's always _much_ easier to work with sample inputs and required outputs than ramblings, and someone is more likely to reply to a concise question which takes at most a few minutes to read.
a:1 b:2 c:3 d:4 f:6 h:8 k:11 nbsp nbsp nbsp
<category> <images> <image name="a" display="true">1</image> <image name="b" display="true">2</image> <image name="c" display="true">3</image> <image name="d" display="true">4</image> <image name="e" display="false">5</image> <image name="f" display="true">6</image> <image name="g" display="false">7</image> <image name="h" display="true">8</image> <image name="i" display="false">9</image> <image name="j" display="false">10</image> <image name="k" display="true">11</image> </images> </category>
I have most of the XSLT worked out, I just cannot figure out how to process the node set in the $imageNodes variable:
<xsl:template match="images"> <table border="3">
<xsl:variable name="imageNodes"> <xsl:apply-templates/> </xsl:variable>
<!-- The following line does not work, even though the $imageNodes contains a node set of image nodes. --> <xsl:for-each select="$imageNodes/image[position() mod 5 = 1]"> <tr> <xsl:for-each select=".|following-sibling::image[position() < 5]"> <td> <xsl:value-of select="concat(@name,':',.)"/> </td> </xsl:for-each> <xsl:call-template name="gen_blank_table_col"> <xsl:with-param name="col_num"> <xsl:value-of select="5 - (count(.|following-sibling::image[position() < 5]))"/> </xsl:with-param> </xsl:call-template> </tr> </xsl:for-each>
</table> </xsl:template>
<xsl:template match="image[@display='true']"> <xsl:copy-of select="."/> </xsl:template>
<xsl:template match="image[@display='false']"> </xsl:template>
<!-- ======================================================================= --> <!-- This template is used to generate blank table col.--> <!--======================================================================= --> <xsl:template name="gen_blank_table_col"> <xsl:param name="col_num"/> <xsl:if test="$col_num > 0"> <td><xsl:text disable-output-escaping="yes">&nbsp;</xsl:text></td> <xsl:call-template name="gen_blank_table_col"> <xsl:with-param name="col_num"> <xsl:value-of select="$col_num - 1"/> </xsl:with-param> </xsl:call-template> </xsl:if> </xsl:template>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] howto convert node set in, Andrew Welch | Thread | Re: [xsl] howto convert node set in, Tony Graham |
Re: [xsl] Problems with following-s, Martin Honnen | Date | Re: [xsl] Alternative for current-g, David Carlisle |
Month |