On 7/4/07, Andrew Welch <andrew(_dot_)j(_dot_)welch(_at_)gmail(_dot_)com> wrote:
> 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.
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[(_at_)display='true']">
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="image[(_at_)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>
--~------------------------------------------------------------------
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>
--~--