[xml] XSLT question



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I realize this is the XML rather than an XSLT mailing list, but I figure
this isn't too off topic.

Here is a chunk of an XSLT file:

<xsl:template match="xform:form[ type='batch']">
~    <form method="{ method}" action="{ action}" name="{ name}">
~    <table class="{ type}">
        <!--
            Here we need to output the titles of each column.
            The logic here is this: Get the first record, and then
            go through and grab all xform:fields that have a 'title'
            element.
        -->
        <tr>
            <xsl:for-each
select="xform:records/xform:record[position()=1]/xform:field[ title]">
                <th><xsl:value-of select="@title" /></th>
            </xsl:for-each>
        </tr>

        <xsl:for-each select="xform:records">
            <!-- Then we need to write out each row. -->
            <xsl:for-each select="xform:record">
                <tr class="row{position() mod 2}">
                    <xsl:apply-templates mode="batch" />
                </tr>
            </xsl:for-each> <!-- record -->
        </xsl:for-each> <!-- records -->

        <xsl:for-each select="xform:actions">
            <tr><td align='center'

colspan="{count(xform:records/xform:record[position()=1]/xform:field[ title])}">
            <xsl:for-each select="xform:action">
                <input type="submit" name="{ name}" value="{ title}" />
            </xsl:for-each> <!-- action -->
            </td></tr>
        </xsl:for-each> <!-- actions -->

~    </table>
~    </form>
</xsl:template>

This template does almost exactly what I need except for one thing - The
first for-each selects on a slightly complicated query, the idea being
to create one table column title for each form field that has a title.
This works correctly.

However, the part near the bottom where I'm setting the colspan to be
the count of the same thing doesn't work - it sets the colspan to be 0.
The context of both queries should be the same, so why does the first
query work and the second not?

Thanks,
~  cf
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAUoW4oaQ1/feGlJoRAubBAKCSmie+OiG+ezs8523BjASEhEj8pACeM/Gp
N65MEp+m7deezcAD0O7jtLc=
=UW+H
-----END PGP SIGNATURE-----



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]