[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: howto convert node set into 2D table
On 7/4/07, Andrew Welch <andrew.j.welch@xxxxxxxxx> wrote:
> Any thoughts on all my rambling? You win;) Here is where I am at: The desired output is a table that looks like this: a:1 b:2 c:3 d:4 f:6 h:8 k:11 nbsp nbsp nbsp Here is the input: <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>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|